Variable Selector

i remember there being a variable that would allow you to select the options you want... that wasnt very descriptive but ill go further into detail. Once i drag my script onto a game object and than look into the inspector and i should see all of my variables. i want to be able to click one and select different options. as in example, if i was to create a weapon script and i didnt want to create multiple scripts for melee and range instead i could just click the variable and than select melee or range. I know that im probably not answering this question quite clearly but i just cant remember what it is.

You might be looking for an `enum`.

The `Standard Assets/Character Controllers/Sources/Scripts/MouseLook.cs` script makes use of these.

alt text

To declare an `enum` like in the Mouse Look script, use this (C#):

 public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
 public RotationAxes axes = RotationAxes.MouseXAndY;

and as also in the Mouse Look script, you can use `if` statements to check the current value of the `enum`:

 if (axes == RotationAxes.MouseXAndY)
      // do something
 else if (axes == RotationAxes.MouseX)
      // do something else
      // do something else

For JavaScript, it's pretty similar. See this answer for more info.

I think you're talking about an enum. Yes?

import UnityEngine.Debug;

enum Attack {Melee, Range}
var attack : Attack;

function Start () {
    Log(attack == Attack.Melee ? "Melee Attack!" : "Range Attack!");