I want that type of input where the user can tell you how many slots there are, then assign multiple variables for a slot. Like the input manager. How the heck do I do this?
Not sure, but it sounds like you’re just referring to an Array ?
Do you mean in the inspector?
Here’s how.
using UnityEngine;
using System.Collections;
[System.Serializable]
public class MyClass
{
public string[] myStuff;
}
public class InspectorGadget : MonoBehaviour {
public MyClass myClass;
}
Ahh, thanks! That’s exactly what I needed!
How would I use the variables stored in the arrays?
string myEntry = myStuff[0]; //first entry
string myEntry = myStuff[1]; //second entry
or if you want to loop through them:
for (int index = 0; index < myStuff.Length; index++)
{
string myEntry = myStuff[index];
}
or simpler:
foreach(string myEntry in myStuff)
{
//do stuff with each myEntry
}