playMaker

Author Topic: Get Color Variable's Hex Value as a String?[SOLVED]  (Read 4166 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Get Color Variable's Hex Value as a String?[SOLVED]
« on: August 14, 2018, 11: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.
« Last Edit: November 15, 2018, 02:18:48 AM by jeanfabre »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #1 on: August 15, 2018, 08: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.
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #2 on: August 15, 2018, 03:25:09 PM »
No need for action actually. Here you go.



If you need # before the string, use build string to add it. If you need only RGB without alpha, omit A from method name.
« Last Edit: October 30, 2018, 07:05:33 PM by krmko »
Available for Playmaker work

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Get Color Variable's Hex Value as a String?
« Reply #3 on: September 21, 2018, 04:21:21 PM »
Ah very nice!
But... you coded.   :'(

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Get Color Variable's Hex Value as a String?
« Reply #4 on: September 21, 2018, 05:29:53 PM »
Tested the TryParseHtmlString 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...

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #5 on: October 30, 2018, 07:05:08 PM »
Ah very nice!
But... you coded.   :'(

Not really, calling method with parameters can hardly be called coding   ;D
Available for Playmaker work

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Re: Get Color Variable's Hex Value as a String?
« Reply #6 on: November 13, 2018, 02: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.
« Last Edit: November 13, 2018, 10:43:24 PM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Color Variable's Hex Value as a String?
« Reply #7 on: November 15, 2018, 02: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



Bye,

 Jean