playMaker

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

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Get Color Variable's Hex Value as a String?[SOLVED]
« 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.
« Last Edit: November 15, 2018, 12:18:48 AM by jeanfabre »

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 847
    • View Profile
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #1 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.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 847
    • View Profile
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #2 on: August 15, 2018, 12: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, 04:05:33 PM by krmko »

Broken Stylus

  • Junior Playmaker
  • **
  • Posts: 89
    • View Profile
Re: Get Color Variable's Hex Value as a String?
« Reply #3 on: September 21, 2018, 01:21:21 PM »
Ah very nice!
But... you coded.   :'(

Broken Stylus

  • Junior Playmaker
  • **
  • Posts: 89
    • View Profile
Re: Get Color Variable's Hex Value as a String?
« Reply #4 on: September 21, 2018, 02: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...

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 847
    • View Profile
    • Fat Pug Studio
Re: Get Color Variable's Hex Value as a String?
« Reply #5 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

westingtyler

  • Full Member
  • ***
  • Posts: 210
    • View Profile
    • My Oculus Rift + Touch VR Game Using Playmaker
Re: Get Color Variable's Hex Value as a String?
« Reply #6 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.
« Last Edit: November 13, 2018, 08:43:24 PM by westingtyler »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13635
  • Official Playmaker Support
    • View Profile
Re: Get Color Variable's Hex Value as a String?
« Reply #7 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



Bye,

 Jean