예제 #1
0
        void DrawTargetIndex(int index)
        {
            GUILayout.Space(-4);
            EditorGUILayout.BeginVertical("helpbox");

            if (!serializedObject.isEditingMultipleObjects)
            {
                bool isIndex = current.valueType == ValueType.Boolean || current.valueType == ValueType.Index;
                EditorGUI.BeginDisabledGroup(!isIndex);
                // Draw each targets.
                foreach (var property in current.toggleProperties)
                {
                    bool enable = s_AvailableReflectedTypes.Contains(property.methodInfo.ReflectedType);
                    if (PropertyEditor.DrawPropertyField(property, index, enable))
                    {
                        if (0 != (current.maskValue & (1 << index)))
                        {
                            ResetToggleValue();
                        }

                        EditorUtility.SetDirty(current.gameObject);
                        serializedObject.Update();
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                EditorGUILayout.HelpBox("Multi-Properties editing is not supported.", MessageType.None);
            }

            // Draw external action.
            if (!spActions.hasMultipleDifferentValues && index < spActions.arraySize)
            {
                EditorGUILayout.PropertyField(spActions.GetArrayElementAtIndex(index), contentAction);
            }

            // Draw group toggle.
            if (!spGroupToggles.hasMultipleDifferentValues && index < spGroupToggles.arraySize)
            {
                var  spToggle = spGroupToggles.GetArrayElementAtIndex(index);
                Rect r        = EditorGUILayout.GetControlRect();
                using (new EditorGUI.PropertyScope(r, null, spToggle))
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUI.PropertyField(r, spToggle, GetLabelWithWarning("Grouping Toggle", spToggle.objectReferenceValue as CompositeToggle));
                    if (EditorGUI.EndChangeCheck())
                    {
                        UpdateMultipleRelations();
                    }
                }
            }

            // Draw activation.
            if (index < spActivations.arraySize)
            {
                EditorGUILayout.PropertyField(spActivations.GetArrayElementAtIndex(index), contentActivation);
            }

            EditorGUILayout.EndVertical();
        }
예제 #2
0
        /*
         * public static void DrawStyle(Style style, StyleAsset styleAsset)
         * {
         *      // Toolbar.
         *      EditorGUI.BeginChangeCheck();
         *      DrawStyleToolbar(style, styleAsset);
         *
         *      // Draw style detail.
         *      if (isShowProperties && styleAsset)
         *      {
         *              DrawProperties(styleAsset);
         *      }
         *
         *      // When style has changed, apply the style to gameObject.
         *      if (EditorGUI.EndChangeCheck() && styleAsset)
         *      {
         *              EditorUtility.SetDirty(styleAsset);
         *              PropertyEditor.onPropertyChanged();
         *      }
         * }*/

        /// <summary>
        /// Draws the style full.
        /// </summary>
        /// <returns>The style full.</returns>
        /// <param name="styleSheetAsset">Style sheet asset.</param>
        public static StyleAsset DrawProperties(StyleAsset styleAsset)
        {
            if (!styleAsset)
            {
                return(styleAsset);
            }

            StyleAsset ret = styleAsset;

            // Draw all sheet.
            int depth = 0;

            foreach (var validStyleAsset in styleAsset.GetStyleAssetEnumerator())
            {
                EditorGUI.BeginDisabledGroup(0 < depth);

                GUILayout.Space(-5);
                EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandWidth(true));

                IEnumerable <Property> properties = validStyleAsset.properties;
                HashSet <string>       ids        = new HashSet <string>(properties.Select(x => x.methodId));


                // Included all RectTransform common properties in style.
                if (s_RectTransformCommonProperties.All(ids.Contains))
                {
                    EditorGUILayout.LabelField("RectTransform Common Properties", EditorStyles.boldLabel);
                    PropertyEditor.abbreviation = true;
                    EditorGUI.indentLevel++;
                    // Draw RectTransform common properties.
                    foreach (var property in properties.Where(x => s_RectTransformCommonProperties.Contains(x.methodId)))
                    {
                        if (property.parameterList != null)
                        {
                            property.parameterList.FitSize(1);
                        }
                        PropertyEditor.DrawPropertyField(property, 0, true);
                    }
                    EditorGUI.indentLevel--;
                    PropertyEditor.abbreviation = false;
                    properties = properties.Where(x => !s_RectTransformCommonProperties.Contains(x.methodId));
                    GUILayout.Space(8);
                }

                // Draw all properties.
                foreach (var property in properties)
                {
                    if (property.parameterList != null)
                    {
                        property.parameterList.FitSize(1);
                    }
                    PropertyEditor.DrawPropertyField(property, 0, true);
                }

                // If current sheet is main, draw base style sheet.
                using (new EditorGUI.DisabledGroupScope(validStyleAsset != styleAsset))
                {
                    var so           = new SerializedObject(validStyleAsset);
                    var spStyleAsset = so.FindProperty("m_BaseStyleAsset");
                    if (validStyleAsset == styleAsset || spStyleAsset.objectReferenceValue)
                    {
                        so.Update();

                        GUILayout.Space(22);
                        DrawStyleAssetField(spStyleAsset,
                                            style =>
                        {
                            spStyleAsset.objectReferenceValue = style;
                            spStyleAsset.serializedObject.ApplyModifiedProperties();
                        });
                    }
                }
                EditorGUI.EndDisabledGroup();
                depth++;
            }

            while (0 < depth--)
            {
                EditorGUILayout.EndVertical();
            }

            return(ret);
        }