Lua and Name Colors

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
dbclutis
Posts: 24
Joined: Tue Feb 25, 2020 7:01 pm

Lua and Name Colors

Post by dbclutis »

Hello again!

I am wanting to start getting a bit more advanced with my Lua usage. I have a question over lua usage.
It is about additional Actor information. I would like to give actors information in themselves such as a color for their name. What is the best way of doing this? I would love to access these variables in a way such as "Actor["Name"].Color.

Currently I'm doing it this way:
Lua and names 1.JPG
Lua and names 1.JPG (113.55 KiB) Viewed 468 times
but I'm not sure how to best initialize the value? I would like some sort of editor source such as with the description, shown here:
Lua and names 2.JPG
Lua and names 2.JPG (77.6 KiB) Viewed 468 times
Thanks for all your help thus far, you're response speed has been unbelievable!
- DC
Last edited by dbclutis on Tue Jun 09, 2020 6:14 pm, edited 1 time in total.
dbclutis
Posts: 24
Joined: Tue Feb 25, 2020 7:01 pm

Re: Lua and Name Colors

Post by dbclutis »

Oh, and one more thing:
Can I use files variables to get animator controllers for portraits? If so, how do they work, is it taking from the resources folder or from assets?

Something like this:
Lua and names 3.JPG
Lua and names 3.JPG (30.02 KiB) Viewed 467 times
or should I simply make it a string?

This is the custom sequencer command code I have right now, but I want to know how I can best use the file variable type:
Lua and names 4.JPG
Lua and names 4.JPG (20.11 KiB) Viewed 466 times
Thanks again!
dbclutis
Posts: 24
Joined: Tue Feb 25, 2020 7:01 pm

Re: Lua and Name Colors

Post by dbclutis »

Well, I solved one of my own problems, so I'll just leave it here to help anyone else who is confused. You can access the other variables through highlighting the actor you want in the "Actors" tab, then all the information will show up in the inspector. After that, just open "All Fields" and press "Template." Now that I've seen it, I realize this was a pretty intuitive solution :lol:
Oh well!

Still would love help on the second part though!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua and Name Colors

Post by Tony Li »

Hi,

Two common ways to handle colors are:

1. Wrap the actor's Display Name in rich text codes, such as:
  • Display Name: "<color=red>Red Sonja the Barbarian</color>"
2. Or add a Dialogue Actor component to the actor's GameObject and set the subtitle color there.

Under the hood, all fields, including the Files type, are just strings. You can define a new type with a custom appearance by writing a custom field type. For example, you could populate a popup menu with the names of all animator controllers found in Resources folder. Then your custom field type could show that popup menu instead of a plain text field.

Side note on Resources: If you happen to be using Addressables, you can mark the animator controller as an addressable. This way you don't have to put it in Resources. If you use DialogueManager.LoadAsset() instead of Resources.Load(), it will load the asset regardless of whether it's an addressable, an asset in an assetbundle, or an asset in a Resources folder.
dbclutis
Posts: 24
Joined: Tue Feb 25, 2020 7:01 pm

Re: Lua and Name Colors

Post by dbclutis »

Perfect, thank you!
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua and Name Colors

Post by Tony Li »

Happy to help!
Post Reply