public static void UpdateChangeListeners(StyleAsset asset, bool onChanged = true)
        {
            if (lastChecked == asset)
            {
                return;
            }

            targetSheets.Clear();
            lastChecked = asset;
            if (asset)
            {
                targetSheets = Resources.FindObjectsOfTypeAll <Style>()
                               .Where(x => x.styleAsset && x.styleAsset.Contains(asset))
                               .ToList();

                if (onChanged)
                {
                    PropertyEditor.onPropertyChanged();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
//			DrawStyle(null, target as StyleAsset);


            // Toolbar.
            EditorGUI.BeginChangeCheck();
            DrawStyleToolbar(null, target as StyleAsset);

            // Draw style detail.
            if (isShowProperties && target)
            {
                DrawProperties(target as StyleAsset);
            }

            // When style has changed, apply the style to gameObject.
            if (EditorGUI.EndChangeCheck() && target)
            {
                EditorUtility.SetDirty(target);
                PropertyEditor.onPropertyChanged();
            }
            serializedObject.ApplyModifiedProperties();
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(8);
            serializedObject.Update();

            // Style Asset.
            var spStyleAsset = serializedObject.FindProperty("m_StyleAsset");

            StyleAssetEditor.DrawStyleAssetField(spStyleAsset, style =>
            {
                spStyleAsset.objectReferenceValue = style;
                spStyleAsset.serializedObject.ApplyModifiedProperties();
                EditorApplication.delayCall += () => StyleAssetEditor.UpdateChangeListeners(style as StyleAsset);
            });

            // Style Properties.
            if (!spStyleAsset.hasMultipleDifferentValues)
            {
                EditorGUI.BeginChangeCheck();

                // Draw Toolbar.
                using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    using (var cc = new EditorGUI.DisabledGroupScope(!current.styleAsset))
                    {
                        // Save style property from target.
                        if (GUILayout.Button(new GUIContent("Save"), EditorStyles.toolbarButton))
                        {
                            foreach (var property in current.styleAsset.properties)
                            {
                                property.parameterList.FitSize(1);
                                PropertyEditor.FillArgumentsByGetter(current, property.methodInfo, property.parameterList);
                            }
                            PropertyEditor.onPropertyChanged();
                        }

                        // Load style property to target.
                        if (GUILayout.Button(new GUIContent("Load"), EditorStyles.toolbarButton))
                        {
                            current.LoadStyle();
                        }
                    }

                    GUILayout.FlexibleSpace();

                    // Default Toolbar.
                    StyleAssetEditor.DrawStyleToolbar(current, current.styleAsset);
                }

                // Draw style detail.
                if (StyleAssetEditor.isShowProperties && current.styleAsset)
                {
                    StyleAssetEditor.DrawProperties(current.styleAsset);
                }

                // When style has changed, apply the style to gameObject.
                if (EditorGUI.EndChangeCheck() && current.styleAsset)
                {
                    Debug.Log("hogehoge");
                    EditorUtility.SetDirty(current.styleAsset);
                    PropertyEditor.onPropertyChanged();
                }
            }
            // Not support multiple StyleAssets.
            else
            {
                EditorGUILayout.HelpBox("Multi-StyleAssets editing is not supported.", MessageType.None);
            }

            // Ignore Properties.
            GUILayout.Space(6);
            EditorGUILayout.LabelField("Ignore Properties", EditorStyles.boldLabel);
            roIgnoreProperties.serializedProperty = serializedObject.FindProperty("m_IgnoreProperties");
            roIgnoreProperties.DoLayoutList();

            serializedObject.ApplyModifiedProperties();
        }