Playmaker Forum

Playmaker Feedback => Action Requests => Topic started by: westingtyler on August 14, 2018, 08:16:22 PM

Title: Get Color Variable's Hex Value as a String?[SOLVED]
Post by: westingtyler on August 14, 2018, 08:16:22 PM
Hello. I need this. I know that 'Set Hex Color' is an action, but I need one to GET it from a color variable. Thank you!

Basically, my FSM has color variables you can set, then at runtime it needs to build the tags and instert them into strings, to display the colors in a Text Mesh Pro.
Title: Re: Get Color Variable's Hex Value as a String?
Post by: krmko on August 15, 2018, 05:22:06 AM
Unity has a neat function for that called ToHtmlStringRGBA, so i might make an action, but i will be unable to in the next following days.
Title: Re: Get Color Variable's Hex Value as a String?
Post by: krmko on August 15, 2018, 12:25:09 PM
No need for action actually. Here you go.

(https://s26.postimg.cc/t5zym1ai1/screenshot_195.png)

If you need # before the string, use build string to add it. If you need only RGB without alpha, omit A from method name.
Title: Re: Get Color Variable's Hex Value as a String?
Post by: Broken Stylus on September 21, 2018, 01:21:21 PM
Ah very nice!
But... you coded.   :'(
Title: Re: Get Color Variable's Hex Value as a String?
Post by: Broken Stylus on September 21, 2018, 02:29:53 PM
Tested the TryParseHtmlString (https://docs.unity3d.com/2017.4/Documentation/ScriptReference/ColorUtility.TryParseHtmlString.html) static method; doesn't work.
In the code example it parses a string variable but looks like it may be wanting something like a htmlString (wut???) or isn't happy with parsing a FsmString...
Title: Re: Get Color Variable's Hex Value as a String?
Post by: krmko on October 30, 2018, 04:05:08 PM
Ah very nice!
But... you coded.   :'(

Not really, calling method with parameters can hardly be called coding   ;D
Title: Re: Get Color Variable's Hex Value as a String?
Post by: westingtyler on November 13, 2018, 12:41:25 PM
well, fancy coding or not, it requires users to understand more than just how playmaker works, which partially defeats the point of using playmaker, but also presents a potential learning opportunity.

does this work now? someone had an issue with it, but it would be cool to use if it works.
Title: Re: Get Color Variable's Hex Value as a String?
Post by: jeanfabre on November 15, 2018, 12:18:38 AM
Hi,

 ok, I made conversion actions from hex to color using the Unity 2017 ColorUtility class, the action are be flexible enough to let you add # and check if the hex if valid as well.

ConvertHexToColor

ConvertColorToHex

(https://twitter.com/JeanAtPlayMaker/status/1062967630473105408)

Bye,

 Jean