Skip to content

Instantly share code, notes, and snippets.

@feranmii
Last active March 13, 2023 22:41
Show Gist options
  • Save feranmii/7ceaeef97be734eb08020b9ae87c6ba8 to your computer and use it in GitHub Desktop.
Save feranmii/7ceaeef97be734eb08020b9ae87c6ba8 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
/// <summary>
/// This is a simple Editor Tool to create a divider for the Editor Hierarchy.
/// You can do this using ALT + D Keys
/// You can also go to Tools -> Hierarchy Divider
/// </summary>
public class HierarchyDividerEditor : ScriptableWizard
{
public string sectionName = "New Divider";
[MenuItem("Tools/Hierarchy Divider/Create Hierarchy Divider Wizard #&d")]
static void SelectAllOfTagWizard()
{
DisplayWizard<HierarchyDividerEditor>("Create Divider", "Create", "Apply");
}
void OnWizardCreate()
{
Init();
GameObject go = new GameObject
{
name = $"-----{sectionName}-----"
};
go.tag = "EditorOnly";
go.SetActive(false);
}
private void OnWizardOtherButton()
{
PlayerPrefs.SetString("HD_DEFAULT", sectionName);
}
[MenuItem("Tools/Hierarchy Divider/Create Divider &d")]
static void CreateDivider()
{
var prefName = PlayerPrefs.GetString("HD_DEFAULT");
var final = prefName == string.Empty ? "New Divider" : prefName;
GameObject go = new GameObject
{
name = $"-----{final}-----"
};
go.tag = "EditorOnly";
go.SetActive(false);
}
private void Init()
{
var def = PlayerPrefs.GetString("HD_DEFAULT");
if (def != null)
{
sectionName = def;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment