public bool VisitTinyObject <TContainer>(ref TContainer container, UTinyObject tiny, UTinyType type, int index) where TContainer : IPropertyContainer
        {
            bool showProperties = true;

            // Root is [component|struct|enum], and recursive calls are [struct|enum]
            if (IsRoot)
            {
                GUILayout.Space(5);
                // Header
                showProperties = DoRootObject(tiny, type);
            }

            try
            {
                if (EditorGUILayout.BeginFadeGroup(showProperties ? 1.0f : 0.0f))
                {
                    GUI.enabled &= !type.HasAttribute <ReadonlyAttribute>();
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = s_Depth - 1;

                    try
                    {
                        switch (type.TypeCode)
                        {
                        case UTinyTypeCode.Configuration:
                        case UTinyTypeCode.Component:
                            return(VisitComponent(tiny, type));

                        case UTinyTypeCode.Struct:
                        case UTinyTypeCode.Enum:
                            return(VisitStructOrEnum(ref container, tiny, type, index));

                        default:
                            return(false);
                        }
                    }
                    finally
                    {
                        EditorGUI.indentLevel = indent;
                        if (IsRoot && tiny.Properties.PropertyBag.PropertyCount > 0)
                        {
                            GUILayout.Space(5);
                        }
                        EditorGUILayout.EndFadeGroup();
                    }
                }
            }
            finally
            {
                if (IsRoot)
                {
                    UTinyGUILayout.Separator(UTinyColors.Inspector.Separator, UTinyGUIUtility.ComponentSeperatorHeight);
                }
            }
            return(true);
        }
Beispiel #2
0
        public override void Header()
        {
            var entities = Targets.Cast <UTinyEntity>();

            var firstEntity = entities.FirstOrDefault();

            if (null == firstEntity)
            {
                return;
            }

            UTinyGUI.BackgroundColor(new Rect(0, 0, Screen.width, 15 + 2 * UTinyGUIUtility.SingleLineAndSpaceHeight), UTinyColors.Inspector.HeaderBackground);
            GUILayout.Space(10);
            var name = firstEntity.Name;

            name = entities.All(entity => entity.Name == name) ? name : "-";
            var enabled     = firstEntity.Enabled;
            var sameEnabled = entities.All(tiny => tiny.Enabled == enabled);

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginChangeCheck();
                var mixed = EditorGUI.showMixedValue;
                EditorGUI.showMixedValue = !sameEnabled;
                enabled = EditorGUILayout.ToggleLeft(GUIContent.none, enabled, GUILayout.Width(EditorGUIUtility.singleLineHeight));
                EditorGUI.showMixedValue = mixed;
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Enabled = enabled;
                        entity.View.gameObject.SetActive(enabled);
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                EditorGUI.BeginChangeCheck();
                name = EditorGUILayout.DelayedTextField(name, UTinyStyles.ComponentHeaderStyle);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Name = name;
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
            }

            var layer     = firstEntity.Layer;
            var sameLayer = entities.All(tiny => tiny.Layer == layer);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(50);
                EditorGUILayout.LabelField("Layer", GUILayout.Width(50));
                EditorGUI.BeginChangeCheck();
                var mixed = EditorGUI.showMixedValue;
                EditorGUI.showMixedValue = !sameLayer;
                layer = EditorGUILayout.LayerField(layer);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var entity in entities)
                    {
                        entity.Layer = layer;
                        entity.View.gameObject.layer = layer;
                    }
                    UTinyHierarchyWindow.InvalidateDataModel();
                    UTinyEditorUtility.RepaintAllWindows();
                }
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
                EditorGUI.showMixedValue = mixed;
            }
            GUILayout.Space(5);
            UTinyGUILayout.Separator(UTinyColors.Inspector.Separator, UTinyGUIUtility.ComponentHeaderSeperatorHeight);
        }
 public override void Header()
 {
     EditorGUILayout.LabelField("(Configurations)", EditorStyles.boldLabel, GUILayout.Height(25.0f));
     UTinyGUILayout.Separator(UTinyColors.Inspector.Separator, UTinyGUIUtility.ComponentHeaderSeperatorHeight);
 }