Last active
March 13, 2023 22:41
-
-
Save feranmii/7ceaeef97be734eb08020b9ae87c6ba8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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