Пример #1
0
        public WorldPropertyInspector(WorldTreeExplorer treeExplorer)
            : base(treeExplorer)
        {
            _subWorldListControl = new ReorderableListControl(ReorderableListFlags.DisableDuplicateCommand |
                                                              ReorderableListFlags.ShowIndices);
            _subWorldListControl.ItemInserted += OnInsertSubworld;
            _subWorldListControl.ItemRemoving += OnRemoveSubworld;

            _scoreListControl = new ReorderableListControl(ReorderableListFlags.DisableDuplicateCommand |
                                                           ReorderableListFlags.ShowIndices);
            _scoreListControl.ItemInserted += OnInsertScore;
            _scoreListControl.ItemRemoving += OnRemoveScore;

            _missionListControl = new ReorderableListControl(ReorderableListFlags.DisableDuplicateCommand |
                                                             ReorderableListFlags.ShowIndices);
            _missionListControl.ItemInserted += OnInsertMission;
            _missionListControl.ItemRemoving += OnRemoveMission;

            Gate currentGate = treeExplorer.CurrentSelectedItem != null ?
                               (treeExplorer.CurrentSelectedItem as World).Gate : null;

            _gateView = new GatePropertyView(currentGate, true);
        }
Пример #2
0
        protected override float DoDrawItem(Rect rect, IItem item)
        {
            float yOffset = 0;
            float width   = rect.width;
            Score score   = item as Score;

            _isBasicPropertiesExpanded = EditorGUI.Foldout(new Rect(0, 0, width, 20),
                                                           _isBasicPropertiesExpanded, "Item");
            yOffset += 20;
            if (_isBasicPropertiesExpanded)
            {
                DrawIDField(new Rect(0, yOffset, width, 20), score, true, true);
                yOffset   += 20;
                score.Name = EditorGUI.TextField(new Rect(0, yOffset, width, 20), "Name", score.Name);
                yOffset   += 20;
            }
            yOffset += 20;

            EditorGUI.LabelField(new Rect(0, yOffset, 250, 20), "Belong to World",
                                 _currentWorldOfScore == null ? "NULL" : _currentWorldOfScore.ID);
            if (_currentWorldOfScore != null)
            {
                if (GUI.Button(new Rect(255, yOffset, 50, 20), "Edit"))
                {
                    WorldTreeExplorer worldTreeExplorer = (GameKitEditorWindow.GetInstance().GetTreeExplorer(
                                                               GameKitEditorWindow.TabType.Worlds) as WorldTreeExplorer);
                    GameKitEditorWindow.GetInstance().SelectTab(GameKitEditorWindow.TabType.Worlds);
                    worldTreeExplorer.SelectItem(_currentWorldOfScore);
                }
                yOffset += 20;
            }
            yOffset += 20;

            _isScorePropertiesExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20),
                                                           _isScorePropertiesExpanded, "Score Property");
            yOffset += 20;
            if (_isScorePropertiesExpanded)
            {
                score.EnableClamp = EditorGUI.Toggle(new Rect(0, yOffset, width, 20),
                                                     "Clamp Score", score.EnableClamp);
                yOffset += 20;
                if (score.EnableClamp)
                {
                    score.Min = EditorGUI.FloatField(new Rect(10, yOffset, width, 20),
                                                     "Mininum Value", score.Min);
                    yOffset  += 20;
                    score.Max = EditorGUI.FloatField(new Rect(10, yOffset, width, 20),
                                                     "Maximum Value", score.Max);
                    yOffset           += 20;
                    score.DefaultValue = EditorGUI.Slider(new Rect(0, yOffset, width, 20),
                                                          "Default Score", score.DefaultValue, score.Min, score.Max);
                }
                else
                {
                    score.DefaultValue = EditorGUI.FloatField(new Rect(0, yOffset, width, 20),
                                                              "Default Score", score.DefaultValue);
                }
                yOffset += 20;
                score.IsHigherBetter = EditorGUI.Toggle(new Rect(0, yOffset, width, 20),
                                                        "Is Higher Better", score.IsHigherBetter);
                yOffset += 20;
                bool isVirtualItemScore = !string.IsNullOrEmpty(score.RelatedVirtualItemID);
                isVirtualItemScore = EditorGUI.Toggle(new Rect(0, yOffset, width, 20), "Is Virtual Item Score", isVirtualItemScore);
                yOffset           += 20;
                if (isVirtualItemScore)
                {
                    if (_relatedVirtualItemIDProperty != null)
                    {
                        EditorGUI.PropertyField(new Rect(0, yOffset, width, 20), _relatedVirtualItemIDProperty,
                                                new GUIContent("Related Virtual Item"));
                        score.RelatedVirtualItemID = _relatedVirtualItemIDProperty.stringValue;
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(0, yOffset, width, 20), "ERROR");
                    }
                    yOffset += 20;
                }
                else
                {
                    score.RelatedVirtualItemID = string.Empty;
                }
                //EditorGUI.LabelField(new Rect(0, yOffset, width, 20), "Related Virtual Item ID", score.RelatedVirtualItemID);
            }

            return(yOffset);
        }
Пример #3
0
        protected override float DoDrawItem(Rect rect, IItem item)
        {
            float   yOffset = 0;
            float   width   = rect.width;
            Mission mission = item as Mission;

            _isBasicPropertiesExpanded = EditorGUI.Foldout(new Rect(0, 0, width, 20),
                                                           _isBasicPropertiesExpanded, "Item");
            yOffset += 20;
            if (_isBasicPropertiesExpanded)
            {
                DrawIDField(new Rect(0, yOffset, width, 20), mission, true, true);
                yOffset            += 20;
                mission.Name        = EditorGUI.TextField(new Rect(0, yOffset, width, 20), "Name", mission.Name);
                yOffset            += 20;
                mission.Description = EditorGUI.TextField(new Rect(0, yOffset, width, 20), "Desription", mission.Description);
                yOffset            += 20;
                mission.BadgeIcon   = EditorGUI.ObjectField(new Rect(0, yOffset, width, 50), "Badge Icon",
                                                            mission.BadgeIcon, typeof(Texture2D), false) as Texture2D;
                yOffset += 55;
            }
            yOffset += 20;

            if (_currentWorldOfMission != null)
            {
                EditorGUI.LabelField(new Rect(0, yOffset, 250, 20), "Belong to World",
                                     _currentWorldOfMission == null ? "NULL" : _currentWorldOfMission.ID);
                if (GUI.Button(new Rect(255, yOffset, 50, 20), "Edit"))
                {
                    WorldTreeExplorer worldTreeExplorer = (GameKitEditorWindow.GetInstance().GetTreeExplorer(
                                                               GameKitEditorWindow.TabType.Worlds) as WorldTreeExplorer);
                    GameKitEditorWindow.GetInstance().SelectTab(GameKitEditorWindow.TabType.Worlds);
                    worldTreeExplorer.SelectItem(_currentWorldOfMission);
                }
                yOffset += 20;
            }
            yOffset += 20;

            UpdateGateID(mission.Gate);
            _isGatePropertiesExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20),
                                                          _isGatePropertiesExpanded, "Gate");
            yOffset += 20;
            if (_isGatePropertiesExpanded)
            {
                float height = _gateDrawer.CalculateHeight(mission.Gate);
                yOffset += _gateDrawer.Draw(new Rect(0, yOffset, width, height), mission.Gate);
                yOffset += 20;
            }

            UpdateRewardsID();
            _isRewardsExpanded = EditorGUI.Foldout(new Rect(0, yOffset, width, 20),
                                                   _isRewardsExpanded, "Rewards");
            yOffset += 20;
            if (_isRewardsExpanded)
            {
                float height = _listControl.CalculateListHeight(_listAdaptor);
                _listControl.Draw(new Rect(0, yOffset, width, height), _listAdaptor);
                yOffset += height;
            }

            return(yOffset);
        }