class joints{
var rightFoot : Transform;
var rightKnee : Transform;
var rightHip : Transform;
var leftFoot : Transform;
var leftKnee : Transform;
var leftHip : Transform;
}
var joints : joints;
The only purpose for doing that is so that then in the unity editor, when I look at all those Transforms in the inspector, they are all neatly collapsed under a ‘joints’ label.
What is the C# equivalent of doing that?
Would I make a class as well? So like outside of the main class that extends MonoBehavior in my C# script, would I make a new class that doesn’t extend MonoBehavior like this:
public class joints;
declare my variables in there and then in the main monobehavior extending class, would I go IKhandles IKhandles; ?
Or would I do something entirely different? Like use a struct inside of the main monobehavior extending class?
using UnityEngine;
using System.Collections;
public class joints{
public Transform rightHand;
}
public class playerControl : MonoBehaviour {
public struct IKHandles
{
public Transform rightLegIK;
}
public IKHandles IKhandles;
public joints joints;
}
but neither the transform in the joints class or the IKhandles struct is being exposed in the unity inspector UI
You need to make your class serializable. This is done automatically for all your classes in JS. C# does not, so you need to do this manually for all classes you want to expose in the inspector.
[System.Serializable]
public class joints{
public Transform rightHand;
}
Because the variables visible in the inspector are stored in the scene (there would not be much point to editing a variable in the inspector if it wouldn’t keep that value after closing Unity). Saving and loading the state of a class instance requires serialization.