void OnEnable() { rootVisualElement.StyleBorderWidth(1); Color c = new Color32(58, 121, 187, 255); rootVisualElement.StyleBorderColor(c); // EditorHelpBox helpBox = new EditorHelpBox("This feature currently in preview state", MessageType.Info); // rootVisualElement.Add(helpBox); hierarchyLocalData = HierarchyEditor.Instance.GetHierarchyLocalData(Selection.activeGameObject.scene); gameObject = Selection.activeGameObject; Selection.activeGameObject = null; CustomRowItem customRowItem = null; if (hierarchyLocalData.TryGetCustomRowData(gameObject, out customRowItem) == false) { customRowItem = hierarchyLocalData.CreateCustomRowItemFor(gameObject); } DlfU.UIElements.Toggle useBackground = new DlfU.UIElements.Toggle("Use Background", customRowItem.useBackground, Justify.FlexStart, (evt) => { customRowItem.useBackground = evt.newValue; EditorApplication.RepaintHierarchyWindow(); }); rootVisualElement.Add(useBackground); EnumField backgroundStyle = new EnumField(customRowItem.backgroundStyle); backgroundStyle.label = "Background Style"; backgroundStyle.RegisterValueChangedCallback((evt) => { customRowItem.backgroundStyle = (CustomRowItem.BackgroundStyle)evt.newValue; EditorApplication.RepaintHierarchyWindow(); }); rootVisualElement.Add(backgroundStyle); EnumField backgroundMode = new EnumField(customRowItem.backgroundMode); backgroundMode.label = "Background Mode"; backgroundMode.RegisterValueChangedCallback((evt) => { customRowItem.backgroundMode = (CustomRowItem.BackgroundMode)evt.newValue; EditorApplication.RepaintHierarchyWindow(); }); rootVisualElement.Add(backgroundMode); ColorField backgroundColor = new ColorField("Background Color"); backgroundColor.value = customRowItem.backgroundColor; backgroundColor.RegisterValueChangedCallback((evt) => { customRowItem.backgroundColor = evt.newValue; EditorApplication.RepaintHierarchyWindow(); }); rootVisualElement.Add(backgroundColor); }
public CustomRowItem CreateCustomRowItemFor(GameObject go) { CustomRowItem customRowItem = new CustomRowItem(go); lCustomRowItems.Add(customRowItem); ClearNullRef(); ConvertToDic(); return(customRowItem); }
void OnEnable() { rootVisualElement.StyleMargin(4, 4, 2, 0); hierarchyLocalData = HierarchyEditor.Instance.GetHierarchyLocalData(Selection.activeGameObject.scene); gameObject = Selection.activeGameObject; Selection.activeGameObject = null; CustomRowItem customRowItem = null; if (hierarchyLocalData.TryGetCustomRowData(gameObject, out customRowItem) == false) { customRowItem = hierarchyLocalData.CreateCustomRowItemFor(gameObject); } IMGUIContainer iMGUIContainer = new IMGUIContainer(() => { customRowItem.useBackground = EditorGUILayout.Toggle("Background", customRowItem.useBackground); customRowItem.backgroundStyle = (CustomRowItem.BackgroundStyle)EditorGUILayout.EnumPopup("Background Style", customRowItem.backgroundStyle); customRowItem.backgroundMode = (CustomRowItem.BackgroundMode)EditorGUILayout.EnumPopup("Background Mode", customRowItem.backgroundMode); customRowItem.backgroundColor = EditorGUILayout.ColorField("Background Color", customRowItem.backgroundColor); customRowItem.overrideLabel = EditorGUILayout.Toggle("Override Label", customRowItem.overrideLabel); var wideMode = EditorGUIUtility.wideMode; EditorGUIUtility.wideMode = true; customRowItem.labelOffset = EditorGUILayout.Vector2Field("Label Offset", customRowItem.labelOffset); EditorGUIUtility.wideMode = wideMode; customRowItem.labelColor = EditorGUILayout.ColorField("Label Color", customRowItem.labelColor); if (GUI.changed) { EditorApplication.RepaintHierarchyWindow(); } }); rootVisualElement.Add(iMGUIContainer); }
public bool TryGetCustomRowData(GameObject go, out CustomRowItem customRowItem) { return(dCustomRowItems.TryGetValue(go, out customRowItem)); }