/Unity-DrawIf-Attributes

Custom attributes to help you organize your inspector without having to write a whole custom editor script.

Primary LanguageC#Apache License 2.0Apache-2.0

Unity-DrawIf-Attributes

This Repository is very new and is being updated frequently

Join my Discord Server.

Credits to: Or-Aviram
Some of these files are created by Or-Aviram. Click here to see the original post.

Draw If | Preview

DrawIf.Preview.mp4

DrawIf Preview | Code

public class DrawIfDemo : MonoBehaviour
{
	public bool showInputs;
	[DrawIf("showInputs", true)] public string input  = "something...";
	[DrawIf("showInputs", true)] public string input2 = "something else...";
	[DrawIf("showInputs", true)] public string input3 = "something else else...";

	[DrawSpaceIf("showInputs", true)]

	[Range(0, 10)] public int number;
	[DrawIf("number", 8, ComparisonType.GreaterOrEqual)] public Vector3 vector = new Vector3(0.25f, 24.435f, 8.4f);

	[DrawHeaderIf("Read-Only?", "showInputs", true)]
	public bool readOnly;
	[DrawIf("readOnly", false, ComparisonType.Equals, DisablingType.ReadOnly)] public int int1 = 20;
	[DrawIf("readOnly", false, ComparisonType.Equals, DisablingType.ReadOnly)] public int int2 = 345;
	[DrawIf("readOnly", false, ComparisonType.Equals, DisablingType.ReadOnly)] public string string1 = "string 1";
	[DrawIf("readOnly", false, ComparisonType.Equals, DisablingType.ReadOnly)] public string string2 = "string 2";
}

Draw Header If | Preview

DrawHeaderIf.Preview.mp4

DrawHeaderIf Preview | Code

public class HeaderDemo : MonoBehaviour
{
	public bool someBool;
	[DrawHeaderIf("Input Header", "someBool", true)]
	public string input  = "something...";
	public string input2 = "something else...";
	public string input3 = "something else else...";

	[DrawHeaderIf("Number Header", "someBool", true)]
	[Range(0, 10)] [Tooltip(">= 8 | Draws Header")] public int number;

	[DrawHeaderIf("Vector Header", "number", 8, ComparisonType.GreaterOrEqual)]
	public Vector3 vector = new Vector3(0.25f, 24.435f, 8.4f);
	public Transform someTransform;
}