Search Unity

Hashes in the Inspector

Discussion in 'Scripting' started by madcalf, May 25, 2006.

  1. madcalf

    madcalf

    Joined:
    Jan 12, 2006
    Posts:
    56
    Is there a way to get a Hash to show up in the inspector like arrays do? But instead of seeing Element 0, Element 1... you would see the actual keys of your hash?

    As an example, check out the PixelInset property of a GUITexture component. Underneath the property name, you see Xmin, Ymin, Xmax, Ymax, and can enter values for each.

    How is this done? Can it be done via javascript?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
  3. madcalf

    madcalf

    Joined:
    Jan 12, 2006
    Posts:
    56
    Will the serializable attribute used in that Button example work in javascript or is that strictly C#?

    I don't know C# to really understand what's happening there. So I would be much more comfortable if I could somehow do this in javascript. If that's not possible, would I be able to just make the serializable class in C# and then just use it in javascripts...

    On a related note: How do you make classes in javascript? Like if I wanted to make a generic object that didn't derive from anything?

    thanks again!
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Code (csharp):
    1.  
    2. @System.Serializable
    3. class Foldout
    4. {
    5.     var a = 5;
    6.     var b = Color.white;
    7. }
    8.  
    9. var foldout : Foldout;
    10.  
    11. print(foldout.a);
    12.  
    13.  
     
  5. madcalf

    madcalf

    Joined:
    Jan 12, 2006
    Posts:
    56
    Sweet! That did the trick! Thanks much!