public void ApplyDefaultStyles(OGWidget w) { foreach (OGDefault d in GetAllDefaults()) { if (d.widgetType == w.ToEnum()) { if (w.styles == null) { w.styles = new OGStyleSet(); } w.styles.basic = d.styleSet.basic; w.styles.active = d.styleSet.active; w.styles.hover = d.styleSet.hover; w.styles.thumb = d.styleSet.thumb; w.styles.ticked = d.styleSet.ticked; w.styles.Refresh(this); return; } } }
override public void OnInspectorGUI() { OGWidget widget = (OGWidget)target; if (!widget || !widget.root) { return; } // Check for hidden widgets if (widget.hidden) { EditorGUILayout.LabelField("This widget is rubbish that somehow didn't get deleted."); // Kill! if (GUILayout.Button("Fix")) { DestroyImmediate(target as GameObject); } } else { // Default inspector DrawDefaultInspector(); // OGCameraWindow, OGLineNode and OGTexture don't need styles if (target.GetType() != typeof(OGLineNode) && target.GetType() != typeof(OGTexture) && target.GetType() != typeof(OGCameraWindow)) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Style", EditorStyles.boldLabel); foreach (OGStyleType styleType in System.Enum.GetValues(typeof(OGStyleType)) as OGStyleType[]) { if (OGSkin.IsStyleUsed(styleType, widget.ToEnum())) { // Styles OGStyle wdStyle = widget.styles.GetStyle(styleType); int wdStyleIndex = GetStyleIndex(widget, wdStyle); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(styleType.ToString()); wdStyleIndex = EditorGUILayout.Popup(wdStyleIndex, GetStyles(widget)); widget.styles.SetStyle(styleType, widget.root.skin.styles [wdStyleIndex]); // ^ Edit if (GUILayout.Button("Edit", GUILayout.Width(40))) { Selection.activeObject = widget.root.skin; OGSkinInspector.SetCurrentStyle(wdStyleIndex); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.BeginHorizontal(); // Get defaults if (GUILayout.Button("Apply default styles")) { (target as OGWidget).ApplyDefaultStyles(); } // ^ Edit if (GUILayout.Button("Edit", GUILayout.Width(40))) { Selection.activeObject = widget.root.skin; OGSkinInspector.SetDefaultsMode(); } EditorGUILayout.EndHorizontal(); } } }
public void ApplyDefaultStyles ( OGWidget w ) { foreach ( OGDefault d in GetAllDefaults() ) { if ( d.widgetType == w.ToEnum () ) { if ( w.styles == null ) { w.styles = new OGStyleSet (); } w.styles.basic = d.styleSet.basic; w.styles.active = d.styleSet.active; w.styles.hover = d.styleSet.hover; w.styles.thumb = d.styleSet.thumb; w.styles.ticked = d.styleSet.ticked; w.styles.Refresh ( this ); return; } } }