public static void Init(StyleSheetAsset p_target) { var window = CreateInstance <StylePalleteWindow>(); window.m_target = p_target; window.OnEnable(); window.ShowUtility(); window.minSize = new Vector2(500, 250); window.titleContent = new GUIContent("Replace Style Assets"); }
protected virtual void DrawOtherStyleDataProperties() { bool v_oldGuiEnabled = GUI.enabled; var v_controlledByStyleGroup = StyleControledByStyleGroup(); if (v_controlledByStyleGroup) { EditorGUILayout.HelpBox("Some values driven by CanvasStyleGroup", MessageType.None); GUI.enabled = false; EditorGUILayout.PropertyField(m_styleGroup); GUI.enabled = v_oldGuiEnabled; EditorGUILayout.Space(); } var v_target = target as BaseStyleElement; var v_oldValue = m_supportStyleGroup.boolValue; EditorGUILayout.PropertyField(m_supportStyleGroup); //Property to control reset of cached initial values var v_needResetCachedValues = v_oldValue != m_supportStyleGroup.boolValue; //Draw Style Data Picker GUI.enabled = v_target.SupportStyleGroup; if (v_target.StyleGroup != null) { EditorGUI.showMixedValue = m_styleDataName.hasMultipleDifferentValues; var v_validNames = GetAllValidStyleDataNamesWithType(v_target.StyleGroup.StyleAsset, v_target.GetSupportedStyleAssetType(), false); var v_index = Mathf.Max(0, System.Array.IndexOf(v_validNames, m_styleDataName.stringValue)); v_validNames[0] = "<Empty>"; // We must set first position to empty after find index (to prevent that has a property with empty name) var v_newIndex = Mathf.Max(0, EditorGUILayout.Popup("Style Data Name", v_index, v_validNames)); if (v_index != v_newIndex || (v_validNames.Length > 1 && m_styleDataName.stringValue != v_validNames[v_newIndex] && v_newIndex > 0)) { m_styleDataName.stringValue = v_validNames.Length > v_newIndex ? v_validNames[v_newIndex] : ""; v_needResetCachedValues = true; } EditorGUI.showMixedValue = false; } else { EditorGUILayout.PropertyField(m_styleDataName); } GUI.enabled = v_oldGuiEnabled; if (v_needResetCachedValues) { _cachedAsset = null; _allValidStyleBehaviours = null; v_controlledByStyleGroup = StyleControledByStyleGroup(true); } }
protected virtual void InitOtherStyleDataPropertyStyles() { m_styleGroup = serializedObject.FindProperty("m_styleGroup"); m_supportStyleGroup = serializedObject.FindProperty("m_supportStyleGroup"); m_styleDataName = serializedObject.FindProperty("m_styleDataName"); //Styles Folder string v_prefKey = GetType().Name; m_StylesPrefKey = v_prefKey + "_Show_Styles"; m_ShowStyles = EditorPrefs.GetBool(m_StylesPrefKey, true); //Reset Important Properties _allValidStyleBehaviours = null; _cachedAsset = null; StyleControledByStyleGroup(true); }
protected virtual string[] GetAllValidStyleDataNamesWithType(StyleSheetAsset p_asset, System.Type p_validType, bool p_recalculate) { if (_cachedAsset != p_asset || _allValidStyleBehaviours == null || p_recalculate) { _cachedAsset = p_asset; var v_styleDatas = p_asset != null?p_asset.GetAllStyleDatasFromType(p_validType) : new List <StyleData>(); List <string> v_validNames = new List <string>() { "" }; foreach (var v_styleData in v_styleDatas) { v_validNames.Add(v_styleData.Name); } _allValidStyleBehaviours = v_validNames.ToArray(); } return(_allValidStyleBehaviours); }