Example #1
0
        protected override void OnGUI()
        {
            PersistentGUILayout.PropertyField(target.Find("interactive"));
            var transition = target.Find("transition");

            PersistentGUILayout.PropertyField(transition);
            if (!transition.hasMultipleDifferentValues)
            {
                EditorGUI.indentLevel += 1;
                PersistentGUI.BeginLabelWidth(120f);
                PersistentGUILayout.PropertyField(target.Find("targetGraphic"));
                switch (transition.GetValue <Selectable.Transition>())
                {
                case Selectable.Transition.ColorTint:
                    var colorState = target.Find("colorState");
                    PersistentGUILayout.PropertyField(colorState.Find("normalColor"));
                    PersistentGUILayout.PropertyField(colorState.Find("focusedColor"));
                    PersistentGUILayout.PropertyField(colorState.Find("pressedColor"));
                    PersistentGUILayout.PropertyField(colorState.Find("disabledColor"));
                    break;

                case Selectable.Transition.SpriteSwap:
                    var spriteState = target.Find("spriteState");
                    PersistentGUILayout.PropertyField(spriteState.Find("focusedSprite"));
                    PersistentGUILayout.PropertyField(spriteState.Find("pressedSprite"));
                    PersistentGUILayout.PropertyField(spriteState.Find("disabledSprite"));
                    break;
                }
                PersistentGUI.EndLabelWidth();
                EditorGUI.indentLevel -= 1;
            }
        }
Example #2
0
 protected override void OnGUI()
 {
     base.OnGUI();
     PersistentGUILayout.PropertyField(target.Find("handleRect"));
     PersistentGUILayout.PropertyField(target.Find("direction"));
     PersistentGUILayout.FloatSlider(target.Find("value"), 0, 1);
     PersistentGUILayout.FloatSlider(target.Find("size"), 0, 1);
 }
Example #3
0
        protected virtual void OnGUI()
        {
            var children = target.ListChildren();

            EditorGUI.indentLevel += 1;
            foreach (var child in children)
            {
                var childLabel = new GUIContent(child.displayName);
                PersistentGUILayout.PropertyField(childLabel, child);
            }
            EditorGUI.indentLevel -= 1;
        }
Example #4
0
        protected override void OnGUI()
        {
            PersistentGUILayout.PropertyField(target.Find("sprite"));
            PersistentGUILayout.PropertyField(target.Find("color"));
            PersistentGUILayout.PropertyField(target.Find("raycastTarget"));
            var images = target.GetValues <Image>();

            if (images.Any(i => i.sprite != null))
            {
                if (GUILayout.Button("Set Native Size", GUILayout.MaxWidth(150)))
                {
                    var commands = images.Where(i =>
                                                i.sprite != null &&
                                                (i.node.size.x != i.sprite.rect.width || i.node.size.y != i.sprite.rect.height))
                                   .Select(i =>
                                           new UpdateMemberCommand(i.node, "size",
                                                                   new Vector2(i.sprite.rect.width, i.sprite.rect.height)));
                    if (commands.Any())
                    {
                        Command.Execute(new CombinedCommand(commands.ToArray()));
                    }
                }
            }
        }
Example #5
0
        protected override void OnGUI()
        {
            if (target == null)
            {
                EditorGUI.LabelField(nativeRect, Locale.L_Inspector, UserSetting.FrameTipsLabelStyle);
                return;
            }

            PersistentGUI.BeginLabelWidth(100);
            var brect   = EditorGUILayout.GetControlRect(false, EditorStyles.toolbarButton.fixedHeight);
            var tsize   = EditorStyles.toggle.CalcSize(GUIContent.none);
            var trect   = new Rect(brect.x + 5, brect.y + (brect.height - tsize.y) * 0.5f - 1, tsize.x, tsize.y);
            var lheight = EditorStyles.textField.CalcHeight(GUIContent.none, brect.width);
            var lrect   = new Rect(trect.xMax, brect.y + (brect.height - lheight) * 0.5f, brect.width - trect.xMax,
                                   lheight);

            PersistentGUI.PropertyField(trect, GUIContent.none, target.Find("enabled"));
            PersistentGUI.PropertyField(lrect, GUIContent.none, target.Find("name"));

            var nodes = target.GetValues <Node>();

            if (nodes.Length > 1)
            {
                PersistentGUILayout.PropertyField(target.Find("anchoredPosition"));
                PersistentGUILayout.PropertyField(target.Find("size"));
            }
            else
            {
                var node      = nodes[0];
                var anchorMin = node.anchorMin;
                var anchorMax = node.anchorMax;
                var labels    = new GUIContent[4];
                var props     = new PersistentProperty[4];
                if (anchorMin.x == anchorMax.x)
                {
                    labels[0] = new GUIContent("Pos X");
                    props[0]  = target.Find("anchoredPosition.x");
                    labels[2] = new GUIContent("Width");
                    props[2]  = target.Find("size.x");
                }
                else
                {
                    labels[0] = new GUIContent("Left");
                    props[0]  = target.Find("offsetMin.x");
                    labels[2] = new GUIContent("Right");
                    props[2]  = target.Find("offsetMax.x");
                }

                if (anchorMin.y == anchorMax.y)
                {
                    labels[1] = new GUIContent("Pos Y");
                    props[1]  = target.Find("anchoredPosition.y");
                    labels[3] = new GUIContent("Height");
                    props[3]  = target.Find("size.y");
                }
                else
                {
                    labels[1] = new GUIContent("Top");
                    props[1]  = target.Find("offsetMin.y");
                    labels[3] = new GUIContent("Bottom");
                    props[3]  = target.Find("offsetMax.y");
                }

                var position = EditorGUILayout.GetControlRect(false,
                                                              EditorGUIUtility.singleLineHeight * (EditorGUIUtility.wideMode ? 2 : 3));
                position.height = EditorGUIUtility.singleLineHeight;
                PersistentGUI.MultiPropertyField2x2(position, new GUIContent("Position"), labels, props, 50);
            }

            PersistentGUILayout.PropertyField(target.Find("anchorMin"));
            PersistentGUILayout.PropertyField(target.Find("anchorMax"));
            PersistentGUILayout.PropertyField(target.Find("pivot"));
            PersistentGUILayout.FloatSlider(target.Find("localAngle"), 0f, 360f);
            PersistentGUILayout.PropertyField(target.Find("localScale"));

            var leafTypes = new List <Type>();

            foreach (var node in nodes)
            {
                var leaves = node.GetAllLeaves();
                foreach (var leaf in leaves)
                {
                    var leafType = leaf.GetType();
                    if (!leafTypes.Contains(leafType))
                    {
                        leafTypes.Add(leafType);
                    }
                }
            }

            leafTypes = leafTypes.FindAll(t => nodes.All(n => n.GetLeaf(t) != null));
            leafTypes.Sort((t1, t2) => String.Compare(t1.Name, t2.Name, StringComparison.Ordinal));
            foreach (var leafType in leafTypes)
            {
                var leaves = Array.ConvertAll(nodes, n => n.GetLeaf(leafType));
                var obj    = new PersistentObject(leaves);
                PersistentGUILayout.UserDrawerLayout(obj);
                EditorGUILayout.Space();
            }

            if (nodes.Length > 1 && nodes.Any(n => n.GetAllLeaves(true).Count() != leafTypes.Count))
            {
                EditorGUILayout.Separator();
                PersistentGUI.BeginColor(Color.yellow);
                EditorGUILayout.LabelField(Locale.L_MultiEditLeavesTips);
                PersistentGUI.EndColor();
            }

            EditorGUILayout.Separator();
            if (GUILayout.Button(Locale.L_AddLeaf, GUILayout.MaxWidth(100)))
            {
                var allTypes = CoreUtil.FindSubTypes(typeof(Leaf));
                Array.Sort(allTypes, (t1, t2) => String.Compare(t1.Name, t2.Name, StringComparison.Ordinal));
                var menu = new GenericMenu();
                foreach (var type in allTypes)
                {
                    var leafType = type;
                    menu.AddItem(new GUIContent(leafType.Name), false, () => { UserUtil.AddLeaf(nodes, leafType); });
                }

                menu.ShowAsContext();
            }

            PersistentGUI.EndLabelWidth();
        }