I’m looking to create a dropdown to organise my variables in the inspector, im not looking for an enum, I’m looking for something like the info and constraints tab in RigidBody. Is this possible?
If you don’t want to create a custom editor, then an easy way of doing this is to just group your variables into a struct;
public class TestClass : MonoBehaviour
{
[System.Serializable]
private struct VariableGroup
{
public float testFloat;
public int testInt;
public VariableGroup (float a_TestFloat, int a_TestInt)
{
testFloat = a_TestFloat;
testInt = a_TestInt;
}
}
[SerializeField] private VariableGroup m_Variables = new VariableGroup (4.5f, 2);
}
Hello. If you mean “a dropdown menu” just a way to group your variables and be able to hide/show them in inspector than take a look at this example:
public class TestClass : MonoBehaviour
{
public TransformData t_data;
private void Start()
{
t_data.x = 1;
t_data.y = 2;
t_data.z = 3;
}
}
[System.Serializable]
public class TransformData
{
public float x;
public float y;
public float z;
}