An attribute that will show or hide a variable within the inspector based on another inspector exposed boolean.
Code example
public class ExampleClass : MonoBehaviour
{
[SerializeField] private bool isStatic;
#if UNITY_EDITOR
[ConditionalHide(nameof(isStatic), false, true)]
#endif
[SerializeField]
[Min(1f)]
private float speed = 1f;
public float GetSpeed => isStatic ? 0f : speed;
private void Update()
{
// Do something with GetSpeed
}
}
Abstract classes to provide singleton pattern logic for the derived class.
Note - If using the Awake()
function within the derived class. It must be overriden and call base.Awake()
within the derived class' Awake()
function.
Makes the object a singleton, and uses Unity's DontDestroyOnLoad()
function to provide persistence between scenes.
Only makes the object a singleton, and it will be destroyed on load by default.
Code example
public class ExamplePersistentSingletonClass : PersistentSingleton<ExamplePersistentSingletonClass>
{
protected override void Awake()
{
// Custom code here
base.Awake();
}
private void Start()
{
throw new NotImplementedException();
}
private void Update()
{
throw new NotImplementedException();
}
}
public class ExampleSingletonClass : Singleton<ExampleSingletonClass>
{
protected override void Awake()
{
// Custom code
base.Awake();
}
private void Start()
{
throw new NotImplementedException();
}
private void Update()
{
throw new NotImplementedException();
}
}