Foldout as a Decorator for group variables in Unity Script Inspector with options for:
- change foldout name.
- apply foldout to one or to many variables
- set variables as read only
- use styled or default editor versions
- hide group on editor mode
Download and copy the Editor and Inspector folders into your Project Assets.
Just put the decorator above the variable and set the options you want:
[Foldout("Name", foldEverything = true, styled = true, readOnly = true, hideOnEditor = false)]
Example (same as image above):
public class MyScript : MonoBehaviour
{
[Foldout("One styled with read only", foldEverything = false, styled = true, readOnly = true)]
public float speed = 1f;
public float retractSpeed = 1f;
[Foldout("Styled ones", styled = true)]
public float climbSpeed = 1f;
public float nodeDistance = 2f;
public float minDistance = 2f;
[Foldout("Only this", false)]
public int maxAmountNodes = 20;
public GameObject nodePrefab;
[Foldout("This and this", false)]
public LayerMask hookableLayer;
[Foldout("This and this", false)]
public LayerMask collibleLayer;
[Foldout("A group")]
public Vector2 direction;
public GameObject player;
public GameObject spawn;
[Foldout("Read only things", readOnly = true)]
public bool done = false;
public bool connected = false;
public bool retracting = false;
public bool climbing = false;
[Foldout("Playing only", hideOnEditor = true)]
public float runtimeVelocity;
}