MyBox
MyBox is a set of tools and extensions for Unity. 99% of it made by me over the years of work with Unity and during The Final Station development.
Most of this stuff was made for specific cases and may or may not work for you. If you want to contribute or report a bug write me to andrew@deadcow.ru
To use MyBox you need to make sure your project supports C#7 features.
It's better to use Unity 2018.3+ version and "PlayerSettings/Player/Script Runtime Version" must be set to .NET 4.x
Entity Component System
ECS Tools, Helper Systems and Extentions
is not up to date and was commented out for better compatibility
Tools
Tools such as Logger and TimeTest
Attributes
ConditionalField:
public bool WanderAround;
[ConditionalField("WanderAround")] public float WanderDistance = 5;
public AIState NextState = AIState.None;
[ConditionalField("NextState", AIState.Idle)] public float IdleTime = 5;
DefinedValues:
[DefinedValues(1, 3, 5)]
public int AgentHeight;
DisplayInspector:
Displays one inspector inside of another. It's handy if you'd like to store some settings in scriptable objects.
[DisplayInspector(displayScriptField:false)] to hide object field once assigned (useful for "single instance" settings)
[CreateAssetMenu]
public class AgentAIContextSettings : ScriptableObject
{
public bool WanderAround;
public float WanderDistance = 5;
}
[DisplayInspector]
public AgentAIContextSettings Settings;
Set displayScriptField to false (by default it's true) to hide property field once
[DisplayInspector(displayScriptField:false)]
Layer:
public class InteractiveObject : MonoBehaviour
{
[Layer]
public int DefaultLayer;
}
MinMaxRange and RangedFloat:
by Richard Fine
RangedFloat may be used without MinMaxRange. Default is 0-1 range
public class RandomisedHealth : MonoBehaviour
{
[MinMaxRange(80, 120)]
public RangedFloat Health;
public RangedFloat Raito;
}
MustBeAssigned:
Previously I used a lot of Debug.Assert() in Awake to ensure that all desired values are assigned through inspector. Now I just use MustBeAssigned.
It triggers on value types with default values, null refs, empty arrays and strings
[MustBeAssigned]
public MonoBehaviour MyScript;
[MustBeAssigned]
public float MyFloat;
ReadOnly:
I use it in rare cases to debug things through inspector
public float InitialHealth = 100;
[ReadOnly]
public float CurrentHealth;
SearchableEnum:
by incredible Ryan Hipple
public float InitialHealth = 100;
[ReadOnly]
public float CurrentHealth;
Separator:
Decorative separator. May be with or without title