Good afternoon. I want to make the class for variables which would be visible in the inspector of game object properties to whom I will add a script. This script will have to contain the reference to my class with variables. I.e. I want to receive the same result, such as at Vector3 variable creation when in the inspector her variables are grouped and it is necessary to press a triangle for their disclosure. Thanks in advance for any help.
Just set the Serializable (namespace System) metatag to your class. In my example CustomModel is a nested class but that don’t has to be nested:
using UnityEngine;
using System;
public class InspectorExample : MonoBehaviour
{
[Serializable]
public class CustomModel
{
public float x;
public float y;
public bool isActive;
}
public CustomModel myModel;
}