Exemplo n.º 1
0
        private void DrawVariable(Rect rect, IList list, int index)
        {
            var name       = _pool.Names[index];
            var variable   = _pool.Variables[index];
            var definition = _pool.Definitions[index];

            var labelRect = RectHelper.TakeWidth(ref rect, _labelWidth);

            labelRect = RectHelper.TakeHeight(ref labelRect, EditorGUIUtility.singleLineHeight);
            var editRect = RectHelper.TakeLeadingIcon(ref labelRect);

            if (GUI.Button(editRect, _editButton.Content, GUIStyle.none))
            {
                _editPopup.Setup(this, index);
                PopupWindow.Show(editRect, _editPopup);
            }

            EditorGUI.LabelField(labelRect, name);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                var value = VariableValueDrawer.Draw(rect, GUIContent.none, variable, definition, true);

                if (changes.changed)
                {
                    _pool.SetVariable(index, value);
                }
            }
        }
Exemplo n.º 2
0
        private void DrawAccessory(Rect rect, IList list, int index)
        {
            var accessory = _building.Accessories[index];

            var nameRect = RectHelper.TakeLine(ref rect);

            RectHelper.TakeWidth(ref rect, RectHelper.LeftMargin);
            var orderRect    = RectHelper.TakeLine(ref rect);
            var positionRect = RectHelper.TakeLine(ref rect);
            var spriteRect   = RectHelper.TakeLine(ref rect);

            var animationRect       = RectHelper.TakeLine(ref rect);
            var animationLabelRect  = RectHelper.TakeLabel(ref animationRect);
            var animationToggleRect = RectHelper.TakeLeadingIcon(ref animationRect);

            accessory.GameObject.name = EditorGUI.TextField(nameRect, accessory.GameObject.name);
            var position = EditorGUI.Vector2Field(positionRect, _accessoryPositionContent, accessory.Bounds.position);

            accessory.OrderOffset     = accessory.Renderer.sortingOrder = EditorGUI.IntSlider(orderRect, _orderOffsetContent, accessory.Renderer.sortingOrder, 0, _MaxOrderOffset);
            accessory.Renderer.sprite = EditorGUI.ObjectField(spriteRect, _spriteContent, accessory.Renderer.sprite, typeof(Sprite), false) as Sprite;

            EditorGUI.LabelField(animationLabelRect, _animationsContent);

            var hasAnimations         = accessory.Animation != null;
            var selectedHasAnimations = EditorGUI.Toggle(animationToggleRect, hasAnimations);

            if (selectedHasAnimations && !hasAnimations)
            {
                AddAnimations(accessory);
            }
            else if (!selectedHasAnimations && hasAnimations)
            {
                RemoveAnimations(accessory);
            }

            if (selectedHasAnimations)
            {
                accessory.Animation.Animation = EditorGUI.ObjectField(animationRect, accessory.Animation.Animation, typeof(AnimationClip), false) as AnimationClip;
            }

            UpdatePartTransform(accessory, position);
        }
Exemplo n.º 3
0
        private void DrawTrainer(Trainer trainer)
        {
            if (trainer && trainer.Roster != null && trainer.Roster.Creatures != null)
            {
                EditorGUILayout.LabelField("Roster");

                var rosterRect = EditorGUILayout.GetControlRect(false, RectHelper.LineHeight * trainer.Roster.Creatures.Count);
                RectHelper.TakeIndent(ref rosterRect);

                foreach (var creature in trainer.Roster.Creatures)
                {
                    var rect = RectHelper.TakeLine(ref rosterRect);
                    var icon = RectHelper.TakeLeadingIcon(ref rect);

                    if (GUI.Button(icon, _editCreatureButton.Content, GUIStyle.none))
                    {
                        Selection.activeObject = creature;
                    }

                    GUI.Label(rect, creature.Name);
                }
            }
        }