Many questions about selector, triggers and C

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
MaximeChaos
Posts: 3
Joined: Sun Feb 17, 2019 2:12 pm

Many questions about selector, triggers and C

Post by MaximeChaos »

Hi !
First of all, I'm not really good with C, I didn't put myself to it in years because I love bolt and can't do anything without it since it came out. I'm also not a native english speaker. So please be patient with me haha.
Anyway.
Here are my questions/requests, in priority order.

1.
TL;DR: Can every usables have a component that automaticly enable/disable when selected/deselected.
Spoiler
In the Inspector "Selector (script)" there is custom events where we can manage what is done when an usable is "selected".
Image
When an Usable is selected, does the selector send that specific gameobject a message?
If yes, which one and if no, could it ? Like it's done for the OnUse one but only for the selected state?
My idea would be to show a 3D ui over the usable being selected. To do so, I would need the usable to receive a signal so it knows that it has to enable the ui component, and disable it when deselected. But here it's the selector that get the custom events, and not the usable. Is there a way to switch things around?
[SOLVED]
Spoiler
A patch adds 3 inspector events to Usable: OnSelect(), OnDeselect(), and OnUse().
Image
2.
TL;DR: What is the code to listen to a message, and what is the code to send it?
Spoiler
How can I make it so the OnUse sent to the gameobject, does something completely different than start a dialogue?
In the Dialogue System Trigger script, we can chose Trigger as "On Use" but inside the script there is "On Use" absolutely nowhere (I ctrl+f many times to make sure haha). So what is the magic behind this ?
So in short, what is the code to listen to the "message" sent to the gameobject ? I just can't find it. I think it's a very basic unity/C thing, but hey, sometimes your path is blocked by little things.
If I find it, I then can start a bolt event instead of a Dialogue system one, and everybody is happy because I can control things again haha. I already read the bolt support manual, but there is nothing about starting an event outside a dialogue.
[SOLVED]
Spoiler
The Usable patch really solves everything about action on usable, I love it!
3.
TL;DR: Is there a way to make dialogue system variables always equal to bolt system variables?
Spoiler
Image
I did this bolt flowmachine to make equal every Lua variables to every Bolt variables, at the start and at the end of each conversation. Is this the intended way to make every Lua variables equal to every Bolt variables ? Is there a simpler method ? Cause I have 100+ variables, and will certainly have at least 1K once the game is finished. So it's quite tedious and I think that with 1000+ variables it will impact the framerate.
[ON HOLD]
Spoiler
I have to try the solution out!
4.
TL;DR: Could we get alphanumeric characters in emphasis settings?
Spoiler
Emphasis text is great ! I used TMP styles before, but I converted. And now I quite regret it because of one thing : Emphasis is only style and color ! In TMP style I could put alphanumerics. For example, if I want a style to be something like a skill check at the end of a choice, I would want [] around the skill check, so in my style I would put those brackets, and if after that I wanter () instead of [] I could just change them in the style property. Is there a way to do what I say, maybe with something else than Emphasis but with the same idea (having a style saved somewhere). Don't tell me TMP, since I updated I can't make TMP pro work with the dialogue system anymore, but I don't regret it, only for the styles that allowed a little bit more freedom.
[SOLVED]
Spoiler
Answer: no. Text Mesh Pro do it best. Now I have to make TMP works haha.
5.
TL;DR: Can each layer mask have its own reticle texture and Default message?
Spoiler
Reticle texture is a nice idea but if I want different reticle for different usable, is this possible ?
If I double or triple the selector script in the player gameobject, and put a different layer mask so each one have its own reticle texture, it should work (if I'm understand right) BUT it would also triple the amount of update event and impact the framerate so it's not a good idea I suppose.
Would it be possible to modify the script so that there is "In Range Layer Mask 1" "In Range Layer Mask 2", etc. ?
Like that I put many layer masks, but each layer has its own reticle texture.
Same goes for the Default Use Message, if I could have Default Use Message for each Layer mask that would make thing so much better. So I could make masks named "People", "Animals", "Doors", and there the possibilities are limitless.
Because if I use the object use message, It will be quite complicated once I want to change every message of the same type of object or even when I will have to localize the game.
[SOLVED in 19/03/19 update, many thanks]
Spoiler
Added to the roadmap, amazing!
old NB
Spoiler
Even If I did my research, maybe some of my questions are very basic and/or already answered somewhere, don't hesitate to copypaste a link as an answer to one of them, it's all I'm asking for!

Because I don't work in C# I started doing my own selector in bolt.
Spoiler
Image
It's a simple raycasting cursor, which set a scene variable equal to the game object the cursor is currently hovering.
But to be fair, I told myself "why doing 20 hours of work when the scripts are just here and you paid for them".
So if I can make everything work directly with the scripts, I'm all for it.

Also, I love the evolution of this asset! For example I love that node colors are now really custom, with a color picker and all ! I hated the old system where you had something like 8 colors (it becomes tedious very fast when you have 30+ characters).
Last edited by MaximeChaos on Tue Mar 19, 2019 9:57 am, edited 3 times in total.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Many questions about selector, triggers and C

Post by Tony Li »

Hi,

A quick note: Unity scripting uses a language named C#. It's different from C.
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pm1.... TL;DR: Can every usables have a component that automaticly enable/disable when selected/deselected.
Another quick note: The Dialogue System does not require you to use the Selector and Usable components. The Dialogue System only provides them as a convenience. However, as you said, you paid for it, so you might as well get to use it.

If you use the Selector, you will like the patch available on the Dialogue System Extras page. Expand "Updated support packages for 2.1.2". Download "Usable Patch 2019-02-16". This adds 3 inspector events to Usable: OnSelect(), OnDeselect(), and OnUse().
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pm2...TL;DR: What is the code to listen to a message, and what is the code to send it?
With the patch above, in the inspector assign actions to OnUse(). However, you can also add a script that has an OnUse() method, such as:
C# code

Code: Select all

void OnUse() {
    // Do something.
}
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pm3....TL;DR: Is there a way to make dialogue system variables always equal to bolt system variables?
You don't need to make that Bolt flow machine. Only use DialogueLua.GetVariable and DialogueLua.SetVariable when you actually need to access a Dialogue System variable.
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pm4....Don't tell me TMP, since I updated I can't make TMP pro work with the dialogue system anymore, but I don't regret it, only for the styles that allowed a little bit more freedom.
TL;DR: Could we get alphanumeric characters in emphasis settings?
TMP really is the best way. Let's get it working in your project. Please use these steps:

1. Use Unity's Package Manager to enable the TextMesh Pro package.

2. Select menu item Tools → Pixel Crushers → Dialogue System → Tools → Enable TextMesh Pro Support....

3. Right-click on Plugins ► Pixel Crushers ► Dialogue System ► Scripts and click Reimport. Then do the same for Plugins ► Pixel Crushers ► Dialogue System ► Wrappers.

4. Use the Standard Dialogue UI. To assign a TextMeshProUGUI to a dialogue UI element, unassign the UI Text. If it starts like this:
Image
unassign the field so it looks like this:
Image
Then you can assign the TextMeshProUGUI.

(summary)
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pm5....
Reticle texture is a nice idea but if I want different reticle for different usable, is this possible ?
You can add a Usable Unity UI to the usable GameObject. The basic prefab is in Plugins ► Pixel Crushers ► Dialogue System ► Prefabs ► Standard UI Prefabs ► Basic. It is a world space canvas. But you could make a screen space canvas if you prefer.
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pmWould it be possible to modify the script so that there is "In Range Layer Mask 1" "In Range Layer Mask 2", etc. ?
Like that I put many layer masks, but each layer has its own reticle texture.
Same goes for the Default Use Message, if I could have Default Use Message for each Layer mask that would make thing so much better. So I could make masks named "People", "Animals", "Doors", and there the possibilities are limitless.
Because if I use the object use message, It will be quite complicated once I want to change every message of the same type of object or even when I will have to localize the game.
TL;DR: Can each layer mask have its own reticle texture and Default message?
That's a good idea. I'll add it to the roadmap. Until then, you will need to use Usable Unity UI or do some C# scripting to make a subclass of Selector. I'll try to get your suggestion into the next release.
MaximeChaos wrote: Sun Feb 17, 2019 3:33 pmAlso, I love the evolution of this asset! For example I love that node colors are now really custom, with a color picker and all ! I hated the old system where you had something like 8 colors (it becomes tedious very fast when you have 30+ characters).
Thanks! Another Dialogue System user suggested the node color improvement. Everyone's suggestions help to make the Dialogue System better for all users.
MaximeChaos
Posts: 3
Joined: Sun Feb 17, 2019 2:12 pm

Re: Many questions about selector, triggers and C

Post by MaximeChaos »

Tony Li wrote: Sun Feb 17, 2019 6:03 pm If you use the Selector, you will like the patch available on the Dialogue System Extras page. Expand "Updated support packages for 2.1.2". Download "Usable Patch 2019-02-16". This adds 3 inspector events to Usable: OnSelect(), OnDeselect(), and OnUse().
P E R F E C T
Tony Li wrote: Sun Feb 17, 2019 6:03 pm You don't need to make that Bolt flow machine. Only use DialogueLua.GetVariable and DialogueLua.SetVariable when you actually need to access a Dialogue System variable.
I'm going to try that after fixing the other problems haha.
Tony Li wrote: Sun Feb 17, 2019 6:03 pmTMP really is the best way. Let's get it working in your project. Please use these steps:

1. Use Unity's Package Manager to enable the TextMesh Pro package.
That's what I was telling you, since I updated my project to the 2017.4.12f1 (LTS) I don't have the Unity's Package Manager anymore. Neither do I have the "reset package manager" in the Help menu. I still have TMP but when I try to make things with it, I get all sort of error messages sadly. So I lost hope since a quite long time haha. But if you tell me that TMP is the best way to do this, then I will try again and again to bring back that famous Unity's Package Manager.
Spoiler
Image
Tony Li wrote: Sun Feb 17, 2019 6:03 pmThat's a good idea. I'll add it to the roadmap. Until then, you will need to use Usable Unity UI or do some C# scripting to make a subclass of Selector. I'll try to get your suggestion into the next release.
Well if it's added to the roadmap I will wait for it haha! Thanks!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Many questions about selector, triggers and C

Post by Tony Li »

MaximeChaos wrote: Mon Feb 18, 2019 4:07 am...since I updated my project to the 2017.4.12f1 (LTS) I don't have the Unity's Package Manager anymore.
The missing Window > Package Manager may cause other problems in the future. Let's try to get it fixed.

First, make sure you have read/write permission to this folder:
  • Windows: C:\Users\yourname\AppData\Local\Unity\cache
  • MacOS: ~/Users/Library/Unity/cache
Then check your project's Packages folder. It should contain a file named manifest.json. If this file is missing or corrupt, Unity will not show the Window > Package Manager menu item. Try this:

1. Close your real project.
2. Back up your project.
3. Create a new, empty project.
4. Copy the manifest.json file from the new project to your real project.
5. Open your real project.

If that doesn't fix it, here are some other things to try:
  • Put the original manifest.json back. Remove the "package-manager-ui" entry.
  • If you're using Windows, try the solution in this bug report.
  • Remove and reinstall Unity 2017.4.12.
MaximeChaos
Posts: 3
Joined: Sun Feb 17, 2019 2:12 pm

Re: Many questions about selector, triggers and C

Post by MaximeChaos »

Spoiler
I tried everything you said, but the package manager don't appear in new project either. I even reinstaled .NET Framework 4.7.2. Then I did a new project with Unity 2018 and directly saw a Package manager. I did my research and found this :
In 2017.2 or 2017.3, the package manager is not used at all. Nothing should be populated. The intention was there to enable the feature but in the end we did not had the time to introduce a proper UI.
https://answers.unity.com/questions/147 ... ty-20.html
So apparently the reason I don't get to have a package manager, is because there is none for project done in Unity before the 2018.1 version. I must have get mixed up with an other project then.
Feeling strong with this new acquired knowledge, I tried to instal manualy the TMP asset, again, and follow your instructions (minus the package manager since I can't have it). And because I did a back up, I was not afraid to lose anything.

And I got this :
Spoiler
Image
So I told to myself "hey but you already tried adding TMP in the past, you should clean up everything for a fresh instal"
And so I did, and there was no more error. After that I was going to click on the "Enable TextMesh Pro Support" a second time.
But it was gray now :
Spoiler
Image
So I tought that it was because it's a one time thing.
Then I tried and...
IT WORKED.
To summarize (if someone had the same problem I got, we never know) what I did was:
Updating TMP files (that was certainly a mistake haha).
Enabling the Dialogue System TMP support.
Deleting absolutely every little pieces of TMP in the project folder and reimporting it.
Reimporting the Scripts and Wrappers folders.

Everythings works like before! And never again will I ever update the unity version of this project haha!

Thanks a very lot Tony! You're the BEST dev I ever had the chance to met!!!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Many questions about selector, triggers and C

Post by Tony Li »

Happy to help! I'm glad it's working now.
Post Reply