Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Alignment Drop-down in a Component

Discussion in 'Scripting' started by alejobrainz, Apr 14, 2006.

  1. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Hello. excuse the stupid question, but i did not seem to find an example to learn from. I am writing a component and one of the public variable items is alignment (center, right, left). I'd like a drop down to appear in the editor to the user where he selects the appropiate alignment.

    As there is no alignment enumeration, I need to create one and have a public variable of tht kind (I think). How do I achieve this in javascript?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You have to use enum's for this. At the moment enum's are not supported in javascript. Enum's will be supported with the next major release.

    You can define enum's in C# though. See for example the MouseLook script in the standard assets.
     
  3. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    288
    Thanks. Will grab a C# book on the way home ;)