Author Topic: Access PlayMakerHashTableProxy from scipt  (Read 65 times)


  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Access PlayMakerHashTableProxy from scipt
« on: May 16, 2018, 03:43:08 PM »

First of all, I know this is more relative to a C# understanding than PlayMaker itself, even so, I would appreciate your help.

I've filled a playmaker hashtable with all NCS colors with their key names, now I need to access them from a script. I've managed to read all the values, but I cannot convert them to UnityEngine.Color32 to be able to operate them and to do all calculations I want to do with RGB, etc.

Code: [Select]
foreach (DictionaryEntry colorInTheList in NcsList.hashTable) {
     Debug.Log(colorInTheList.Value) //it prints RGBA(0,0,0,0) the color!
     Color32 colorValue = colorInTheList.Value

with this code, the console says "error CS0266: Cannot implicitly convert type `object' to `UnityEngine.Color32'. An explicit conversion exists (are you missing a cast?)"

Thank youuu!


  • Administrator
  • Hero Member
  • *****
  • Posts: 2952
    • View Profile
    • jinxtergames
Re: Access PlayMakerHashTableProxy from scipt
« Reply #1 on: May 18, 2018, 06:54:32 AM »

Is colorInTheList an fsm value?

Can you show more from the script?

As i believe that hash table values are not using fsmvariables.


  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: Access PlayMakerHashTableProxy from scipt
« Reply #2 on: May 18, 2018, 10:04:32 AM »
Finally I found a workarround: to parse the DictionaryEntry.Value. I know this is nonsense, but It works for me and I do not reach something better.
This is the entire function:

Code: [Select]
public void closestColor3(Color32 target){
float hue1 = getHue (target.r, target.g, target.b);
var num1 = ColorNum(target);
float minimaDiferenciaColores = 10000;
string key="";
int flag = 0;
int index = 0;
Color valor; Color32 valor32; Color colorParecido = new Color();
foreach (DictionaryEntry colorDeLaLista in listaNcs.hashTable) {
float Rvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (5, 5));
float Gvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (12, 5));
float Bvalor = float.Parse (colorDeLaLista.Value.ToString ().Substring (19, 5));
valor = new Color (Rvalor,Gvalor,Bvalor);
valor32 = (Color32)valor;
float diferenciaColores = Math.Abs(ColorNum(valor) - num1) + getHueDistance(getHue(valor32.r, valor32.g, valor32.b), hue1);
if (diferenciaColores < minimaDiferenciaColores) {
minimaDiferenciaColores = diferenciaColores;
key = colorDeLaLista.Key.ToString ();
index = flag;
colorParecido = valor;
img_NCS.color = colorParecido;
txt_NCS.text = key;

If you have any suggestion to improve it, please tell me. Thanks! :)