public override void OnInspectorGUI() { base.OnInspectorGUI(); HierachySeperator myTarget = (HierachySeperator)target; //Create a text input for header name string newHeaderName = EditorGUILayout.TextField(myTarget.headerName).ToUpper(); //Create prefix selection for header EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Prefix/Postfix Char", GUILayout.Width(Screen.width * 0.3f)); myTarget.selectedPrefix = (SELECTED_PREFIX)EditorGUILayout.Popup((int)myTarget.selectedPrefix, prefixOptions, GUILayout.Width(Screen.width * 0.3f)); EditorGUILayout.EndHorizontal(); float newPrefixLength = EditorGUILayout.Slider(myTarget.prefixLength, 0.1f, 0.9f); //Get the header prefix from the dropdown char newheaderPrefix = prefixOptions[(int)myTarget.selectedPrefix].ToCharArray()[0]; if (myTarget.headerName != newHeaderName || headerPrefix != newheaderPrefix || myTarget.prefixLength != newPrefixLength) { myTarget.headerName = newHeaderName; headerPrefix = newheaderPrefix; myTarget.prefixLength = newPrefixLength; myTarget.gameObject.name = GetHeaderName(myTarget.headerName, myTarget.prefixLength); } }
private static void CreateHeader() { GameObject newHeaderObj = new GameObject(); //Makes sure the header is not saved in the build and the transform component is not visable newHeaderObj.hideFlags = HideFlags.DontSaveInBuild; newHeaderObj.transform.hideFlags = HideFlags.DontSaveInBuild | HideFlags.NotEditable | HideFlags.HideInInspector; //Set the new name of the header HierachySeperator newHeader = newHeaderObj.AddComponent(typeof(HierachySeperator)) as HierachySeperator; newHeader.name = GetStaticHeaderName("New Header", 0.5f); Selection.SetActiveObjectWithContext(newHeaderObj, newHeaderObj); }