Page 1 of 1

Lua and Name Colors

Posted: Tue Jun 09, 2020 5:48 pm
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 472 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 472 times
Thanks for all your help thus far, you're response speed has been unbelievable!
- DC

Re: Lua and Name Colors

Posted: Tue Jun 09, 2020 5:52 pm
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 471 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 470 times
Thanks again!

Re: Lua and Name Colors

Posted: Tue Jun 09, 2020 6:17 pm
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!

Re: Lua and Name Colors

Posted: Tue Jun 09, 2020 8:58 pm
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.

Re: Lua and Name Colors

Posted: Wed Jun 10, 2020 12:43 pm
by dbclutis
Perfect, thank you!

Re: Lua and Name Colors

Posted: Wed Jun 10, 2020 1:15 pm
by Tony Li
Happy to help!