コード例 #1
0
        private void RenderObjectGroupSelectionPopup()
        {
            ObjectGroupDatabase objectGroupDatabase = Octave3DWorldBuilder.ActiveInstance.PlacementObjectGroupDatabase;

            if (objectGroupDatabase.NumberOfGroups == 0)
            {
                EditorGUILayoutEx.InformativeLabel("No object groups are currently available.");
                return;
            }

            PrefabCategoryDatabase prefabCategoryDatabase = PrefabCategoryDatabase.Get();
            PrefabCategory         activeCategory         = prefabCategoryDatabase.ActivePrefabCategory;

            List <ObjectGroup> allObjectGroups = objectGroupDatabase.GetAllObjectGroups();

            if (activeCategory.ObjectGroup == null)
            {
                activeCategory.SetObjectGroup(allObjectGroups[0]);
            }

            int currentGroupIndex = allObjectGroups.FindIndex(0, item => item == activeCategory.ObjectGroup);

            if (currentGroupIndex < 0)
            {
                return;
            }

            int newGroupIndex = EditorGUILayoutEx.Popup(GetContentForObjectGroupSelectionPopup(), currentGroupIndex, objectGroupDatabase.GetAllObjectGroupNames());

            if (newGroupIndex != currentGroupIndex)
            {
                UndoEx.RecordForToolAction(activeCategory);
                activeCategory.SetObjectGroup(allObjectGroups[newGroupIndex]);
            }
        }
コード例 #2
0
        private void RenderActiveBrushSelectionPopup()
        {
            string newString = EditorGUILayoutEx.Popup(GetContentForActiveBrushSelectionPopup(), _database.ActiveBrush.Name, _database.GetAllBrushNames());

            if (newString != _database.ActiveBrush.Name)
            {
                UndoEx.RecordForToolAction(_database);
                _database.SetActiveBrush(_database.GetBrushByName(newString));
            }
        }
        private void RenderDestinationCategorySelectionPopup()
        {
            string newString = EditorGUILayoutEx.Popup(GetContentForDestinationCategorySelectionPopup(), _settings.DestinationCategory.Name, PrefabCategoryDatabase.Get().GetAllPrefabCategoryNames());

            if (newString != _settings.DestinationCategory.Name)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.DestinationCategory = PrefabCategoryDatabase.Get().GetPrefabCategoryByName(newString);
            }
        }
コード例 #4
0
        private void RenderActiveGroupSelectionPopup()
        {
            int newInt = EditorGUILayoutEx.Popup(GetContentForActiveGroupSelectionPopup(), _database.IndexOfActiveGroup, _database.GetAllObjectGroupNames());

            if (newInt != _database.IndexOfActiveGroup)
            {
                UndoEx.RecordForToolAction(_database);
                _database.SetActiveObjectGroup(_database.GetObjectGroupByIndex(newInt));
            }
        }
コード例 #5
0
        private void RenderDestinationCategoryForElementPrefabsSelectionPopup()
        {
            string newString = EditorGUILayoutEx.Popup(GetContentForDestinationCategoryForElementPrefabsSelectionPopup(), _brush.DestinationCategoryForElementPrefabs.Name, PrefabCategoryDatabase.Get().GetAllPrefabCategoryNames());

            if (newString != _brush.DestinationCategoryForElementPrefabs.Name)
            {
                UndoEx.RecordForToolAction(_brush);
                _brush.DestinationCategoryForElementPrefabs = PrefabCategoryDatabase.Get().GetPrefabCategoryByName(newString);
            }
        }
        private void RenderActiveConfigurationSelectionPopup()
        {
            ObjectPlacementPathTileConnectionConfigurationDatabase configurationDatabase = ObjectPlacementPathTileConnectionConfigurationDatabase.Get();
            string newString = EditorGUILayoutEx.Popup(GetContentForActiveConfigurationSelectionPopup(), configurationDatabase.ActiveConfiguration.Name, configurationDatabase.GetAllConfigurationNames());

            if (newString != configurationDatabase.ActiveConfiguration.Name)
            {
                ObjectPlacementPathTileConnectionConfiguration newActiveConfiguration = configurationDatabase.GetConfigurationByName(newString);
                if (newActiveConfiguration != null)
                {
                    UndoEx.RecordForToolAction(configurationDatabase);
                    PathObjectPlacement.Get().PathSettings.TileConnectionSettings.RecordAllTileConnectionTypeSettingsForUndo();
                    configurationDatabase.SetActiveConfiguration(newActiveConfiguration);
                    newActiveConfiguration.ApplyConfigurationDataToSettings(PathObjectPlacement.Get().PathSettings.TileConnectionSettings);
                }
            }
        }
コード例 #7
0
        private void RenderActionsView()
        {
            EditorGUILayout.BeginHorizontal();
            var content = new GUIContent();

            content.text    = "Move";
            content.tooltip = "Allows you to move prefabs to a destination category. The popup controls to the right allow you to choose what prefabs will be moved and to which category.";
            if (GUILayout.Button(content, GUILayout.Width(100.0f)))
            {
                if (ViewData.PrefabMoveType == PrefabMoveType.AllPrefabs)
                {
                    PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove;
                    if (destinationCategory != null)
                    {
                        UndoEx.RecordForToolAction(destinationCategory);
                        UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get().ActivePrefabCategory);
                        PrefabCategoryDatabase.Get().ActivePrefabCategory.TransferAllPrefabsToCategory(destinationCategory);
                    }
                }
                else
                if (ViewData.PrefabMoveType == PrefabMoveType.FilteredPrefabs)
                {
                    PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove;
                    if (destinationCategory != null)
                    {
                        PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory;
                        UndoEx.RecordForToolAction(destinationCategory);
                        UndoEx.RecordForToolAction(activePrefabCategory);

                        activePrefabCategory.TransferPrefabCollectionToCategory(activePrefabCategory.GetFilteredPrefabs(), destinationCategory);
                    }
                }
                else
                if (ViewData.PrefabMoveType == PrefabMoveType.ActivePrefab)
                {
                    Prefab activePrefab = PrefabCategoryDatabase.Get().ActivePrefabCategory.ActivePrefab;
                    if (activePrefab != null)
                    {
                        PrefabCategory destinationCategory = ViewData.DestinationCategoryForPrefabMove;
                        if (destinationCategory != null)
                        {
                            PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory;
                            UndoEx.RecordForToolAction(PrefabCategoryDatabase.Get());
                            UndoEx.RecordForToolAction(destinationCategory);
                            UndoEx.RecordForToolAction(activePrefabCategory);

                            activePrefabCategory.TransferPrefabToCategory(activePrefab, destinationCategory);
                            PrefabCategoryDatabase.Get().SetActivePrefabCategory(destinationCategory);
                            destinationCategory.SetActivePrefab(activePrefab);
                        }
                    }
                }
            }

            PrefabMoveType newPrefabMoveType = (PrefabMoveType)EditorGUILayout.EnumPopup(ViewData.PrefabMoveType);

            if (newPrefabMoveType != ViewData.PrefabMoveType)
            {
                UndoEx.RecordForToolAction(ViewData);
                ViewData.PrefabMoveType = newPrefabMoveType;
            }

            List <string> allPrefabCategoryNames = PrefabCategoryDatabase.Get().GetAllPrefabCategoryNames();
            string        newString = EditorGUILayoutEx.Popup(new GUIContent(), ViewData.DestinationCategoryForPrefabMove.Name, allPrefabCategoryNames);

            if (newString != ViewData.DestinationCategoryForPrefabMove.Name)
            {
                UndoEx.RecordForToolAction(ViewData);
                ViewData.DestinationCategoryForPrefabMove = PrefabCategoryDatabase.Get().GetPrefabCategoryByName(newString);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.BeginHorizontal();
            RenderSetPrefabOffsetFromGridSurfaceInActiveCategoryButton();
            RenderPrefabOffsetFromGridSurfaceField();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            RenderSetPrefabOffsetFromObjectSurfaceInActiveCategoryButton();
            RenderPrefabOffsetFromObjectSurfaceField();
            EditorGUILayout.EndHorizontal();
        }
コード例 #8
0
        protected override void RenderContent()
        {
            EditorGUILayoutEx.BeginVerticalBox();

            EditorGUILayout.BeginHorizontal();
            const float alignButtonWidth = 72.0f;
            var         content          = new GUIContent();

            content.text    = "Align X";
            content.tooltip = "Aligns the positions of the selected objects to the X axis.";
            if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth)))
            {
                ObjectSelectionActions.AlignSelectionToAxis(Axis.X);
            }

            content.text    = "Align Y";
            content.tooltip = "Aligns the positions of the selected objects to the Y axis.";
            if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth)))
            {
                ObjectSelectionActions.AlignSelectionToAxis(Axis.Y);
            }

            content.text    = "Align Z";
            content.tooltip = "Aligns the positions of the selected objects to the Z axis.";
            if (GUILayout.Button(content, GUILayout.Width(alignButtonWidth)))
            {
                ObjectSelectionActions.AlignSelectionToAxis(Axis.Z);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            RenderMakeSelectionStaticButton();
            RenderMakeSelectionDynamicButton();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            RenderInvertSelectionButton();
            content.text    = "Grab settings...";
            content.tooltip = "Opens up a new window which allows you to modify selection grab settings.";
            if (GUILayout.Button(content, GUILayout.Width(110.0f)))
            {
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ObjectGrabSettings = ObjectSelection.Get().SelectionGrabSettings;
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.SelectionGrabSettingsWindow.ShowOctave3DWindow();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            RenderAssignSelectionToLayerButton();
            RenderSelectionAssignmentLayerSelectionPopup();
            EditorGUILayout.EndHorizontal();

            if (ObjectGroupDatabase.Get().NumberOfGroups != 0)
            {
                if (string.IsNullOrEmpty(ViewData.DestObjectGroupName))
                {
                    ViewData.DestObjectGroupName = ObjectGroupDatabase.Get().GetObjectGroupByIndex(0).Name;
                }
                else
                {
                    if (ObjectGroupDatabase.Get().GetObjectGroupByName(ViewData.DestObjectGroupName) == null)
                    {
                        ViewData.DestObjectGroupName = ObjectGroupDatabase.Get().GetObjectGroupByIndex(0).Name;
                    }
                }

                EditorGUILayout.BeginHorizontal();
                content.text    = "Assign to group";
                content.tooltip = "Assigns the object selection to the specified object group.";
                if (GUILayout.Button(content, GUILayout.Width(110.0f)))
                {
                    ObjectGroup destObjectGroup = ObjectGroupDatabase.Get().GetObjectGroupByName(ViewData.DestObjectGroupName);
                    if (destObjectGroup != null)
                    {
                        ObjectActions.AssignObjectsToGroup(ObjectSelection.Get().GetAllSelectedGameObjects(), destObjectGroup);
                    }
                }

                string newGroupName = EditorGUILayoutEx.Popup(new GUIContent(), ViewData.DestObjectGroupName, ObjectGroupDatabase.Get().GetAllObjectGroupNames());
                if (newGroupName != ViewData.DestObjectGroupName)
                {
                    UndoEx.RecordForToolAction(ViewData);
                    ViewData.DestObjectGroupName = newGroupName;
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayoutEx.EndVerticalBox();
        }
コード例 #9
0
        protected override void RenderContent()
        {
            float newFloat; bool newBool; string newString;

            EditorGUILayout.LabelField("Object groups", EditorStyles.boldLabel);
            var content = new GUIContent();

            content.text    = "Attach to object group";
            content.tooltip = "If this is checked, any objects which are created via selection operations will be attached to a group of your choosing.";
            newBool         = EditorGUILayout.ToggleLeft(content, _settings.ObjectGroupSettings.AttachToObjectGroup);
            if (newBool != _settings.ObjectGroupSettings.AttachToObjectGroup)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.ObjectGroupSettings.AttachToObjectGroup = newBool;
            }

            ObjectGroupDatabase objectGroupDatabase = Octave3DWorldBuilder.ActiveInstance.PlacementObjectGroupDatabase;

            if (objectGroupDatabase.NumberOfGroups == 0)
            {
                EditorGUILayout.HelpBox("No object groups are currently available.", UnityEditor.MessageType.None);
            }
            else
            {
                if (_settings.ObjectGroupSettings.DestinationGroup == null)
                {
                    _settings.ObjectGroupSettings.DestinationGroup = objectGroupDatabase.GetAllObjectGroups()[0];
                }

                content.text    = "Object group";
                content.tooltip = "If \'Attach to object group\' is checked, any objects which are created via selection operations will be attached to this group.";
                newString       = EditorGUILayoutEx.Popup(content, _settings.ObjectGroupSettings.DestinationGroup.Name, objectGroupDatabase.GetAllObjectGroupNames());
                if (newString != _settings.ObjectGroupSettings.DestinationGroup.Name)
                {
                    UndoEx.RecordForToolAction(_settings);
                    _settings.ObjectGroupSettings.DestinationGroup = objectGroupDatabase.GetObjectGroupByName(newString);
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Rotation", EditorStyles.boldLabel);
            content.text    = "X rotation step";
            content.tooltip = "Allows you to specify how much rotation is applied to the selected objects when the X rotation key is pressed.";
            newFloat        = EditorGUILayout.FloatField(content, _settings.XRotationStep);
            if (newFloat != _settings.XRotationStep)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.XRotationStep = newFloat;
            }

            content.text    = "Y rotation step";
            content.tooltip = "Allows you to specify how much rotation is applied to the selected objects when the Y rotation key is pressed.";
            newFloat        = EditorGUILayout.FloatField(content, _settings.YRotationStep);
            if (newFloat != _settings.YRotationStep)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.YRotationStep = newFloat;
            }

            content.text    = "Z rotation step";
            content.tooltip = "Allows you to specify how much rotation is applied to the selected objects when the Z rotation key is pressed.";
            newFloat        = EditorGUILayout.FloatField(content, _settings.ZRotationStep);
            if (newFloat != _settings.ZRotationStep)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.ZRotationStep = newFloat;
            }

            content.text    = "Rotate around selection center";
            content.tooltip = "If this is checked, the rotation will happen around the selection's world center. Otherwise, each object will be rotated around its own center.";
            newBool         = EditorGUILayout.ToggleLeft(content, _settings.RotateAroundSelectionCenter);
            if (newBool != _settings.RotateAroundSelectionCenter)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.RotateAroundSelectionCenter = newBool;
            }

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Object 2 object snap", EditorStyles.boldLabel);
            content.text    = "Snap epsilon";
            content.tooltip = "The selected objects will always snap to nearby objects which are \'epsilon\' units away from the selected objects.";
            newFloat        = EditorGUILayout.FloatField(content, _settings.Object2ObjectSnapSettings.SnapEps);
            if (newFloat != _settings.Object2ObjectSnapSettings.SnapEps)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.Object2ObjectSnapSettings.SnapEps = newFloat;
            }

            content.text    = "Can hover objects";
            content.tooltip = "If this is checked, you will be able to hover other objects during a snap session. Otherwise, you will only be able to hover the grid surface.";
            newBool         = EditorGUILayout.ToggleLeft(content, _settings.Object2ObjectSnapSettings.CanHoverObjects);
            if (newBool != _settings.Object2ObjectSnapSettings.CanHoverObjects)
            {
                UndoEx.RecordForToolAction(_settings);
                _settings.Object2ObjectSnapSettings.CanHoverObjects = newBool;
            }

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Misc", EditorStyles.boldLabel);
            RenderAllowPartialOverlapToggle();
            RenderSelectionShapeTypeSelectionPopup();
            RenderSelectionUpdateModeSelectionPopup();
            RenderSelectionModeSelectionPopup();

            if (_settings.SelectionMode == ObjectSelectionMode.Paint)
            {
                _settings.PaintModeSettings.View.Render();
            }
        }