private void LoadSettings()
 {
     settings = AssetDatabase.LoadAssetAtPath <GridEditorSettings>(GridEditorSettings.SAVE_PATH);
     if (settings == null)
     {
         settings = ScriptableObject.CreateInstance <GridEditorSettings>();
         AssetDatabase.CreateAsset(settings, GridEditorSettings.SAVE_PATH);
         AssetDatabase.SaveAssets();
     }
 }
        public void Draw(GridEditorSettings settings, bool isDefaultState)
        {
            string  tempStr;
            Vector3 tempV3;

            EditorGUI.BeginChangeCheck();
            tempStr = EditorGUILayout.TextField("Name", name);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab State Name");
                if (!isDefaultState)
                {
                    name = tempStr;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(tempStr, rotation, shift));
                }

                settings.UpdatePrefabStatesPopupList();
            }

            EditorGUI.BeginChangeCheck();
            tempV3 = EditorGUILayout.Vector3Field("Rotation", rotation);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab Rotation");
                if (!isDefaultState)
                {
                    rotation = tempV3;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(name, tempV3, shift));
                }
            }

            EditorGUI.BeginChangeCheck();
            tempV3 = EditorGUILayout.Vector3Field("Shift", shift);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab Shift");
                if (!isDefaultState)
                {
                    shift = tempV3;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(name, rotation, tempV3));
                }
            }
        }
Пример #3
0
        public void Draw(GridEditorSettings settings, bool isDefaultState)
        {
            EditorGUI.BeginChangeCheck();
            string _name = EditorGUILayout.TextField("Name", name);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab State Name");
                if (!isDefaultState)
                {
                    name = _name;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(_name, rotation, shift));
                }

                settings.UpdatePrefabStatesPopupList();
            }

            EditorGUI.BeginChangeCheck();
            Vector3 _rotation = EditorGUILayout.Vector3Field("Rotation", rotation);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab Rotation");
                if (!isDefaultState)
                {
                    rotation = _rotation;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(name, _rotation, shift));
                }
            }

            EditorGUI.BeginChangeCheck();
            Vector3 _shift = EditorGUILayout.Vector3Field("Shift", shift);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Prefab Shift");
                if (!isDefaultState)
                {
                    shift = _shift;
                }
                else
                {
                    settings.CreatePrefabStateForSelection(new PrefabState(name, rotation, _shift));
                }
            }
        }
Пример #4
0
        private void LoadSettings()
        {
            isEnabled  = EditorPrefs.GetBool(PREF_ENABLED, true);
            showGrids  = EditorPrefs.GetBool(PREF_SHOW_GRIDS, true);
            snapToGrid = EditorPrefs.GetBool(PREF_SNAP_TO_GRID, true);

            settings = AssetDatabase.LoadAssetAtPath <GridEditorSettings>(GridEditorSettings.SAVE_PATH);
            if (!settings)
            {
                System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(GridEditorSettings.SAVE_PATH));

                settings = CreateInstance <GridEditorSettings>();
                AssetDatabase.CreateAsset(settings, GridEditorSettings.SAVE_PATH);
                AssetDatabase.SaveAssets();
            }
        }
Пример #5
0
        private void LoadSettings()
        {
            // For backwards compatibility
            if (AssetDatabase.LoadAssetAtPath <GridEditorSettings>("Assets/Editor/GridEditorSettings.asset") != null)
            {
                // Move asset to new position
                AssetDatabase.MoveAsset("Assets/Editor/GridEditorSettings.asset", GridEditorSettings.SAVE_PATH);
                AssetDatabase.SaveAssets();
            }

            settings = AssetDatabase.LoadAssetAtPath <GridEditorSettings>(GridEditorSettings.SAVE_PATH);
            if (settings == null)
            {
                settings = ScriptableObject.CreateInstance <GridEditorSettings>();
                AssetDatabase.CreateAsset(settings, GridEditorSettings.SAVE_PATH);
                AssetDatabase.SaveAssets();
            }
        }
        public void Draw(GridEditorSettings settings)
        {
            string tempStr;
            Color  tempClr;
            float  tempFloat;
            int    tempInt;

            GridEditor.GridAlignment tempEnum;

            EditorGUI.BeginChangeCheck();
            tempStr = EditorGUILayout.TextField("Name", name);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change State Name");
                name = tempStr;

                settings.UpdateStatesPopupList();
            }

            EditorGUI.BeginChangeCheck();
            tempClr = EditorGUILayout.ColorField("Gridline Color", gridlineColor);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Color");
                gridlineColor = tempClr;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField("Grid Size", gridSize);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Size");
                gridSize = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempInt = EditorGUILayout.IntField("Gridline Count", gridlineCount);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Count");
                gridlineCount = tempInt;
            }

            EditorGUI.BeginChangeCheck();
            tempEnum = (GridEditor.GridAlignment)EditorGUILayout.EnumPopup("Grid Alignment", gridAlignment);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Alignment");
                gridAlignment = tempEnum;
            }

            string posLabel, shiftXLabel, shiftZLabel;

            if (gridAlignment == GridEditor.GridAlignment.XZ)
            {
                posLabel    = "Grid Y Pos";
                shiftXLabel = "Grid Shift X";
                shiftZLabel = "Grid Shift Z";
            }
            else if (gridAlignment == GridEditor.GridAlignment.XY)
            {
                posLabel    = "Grid Z Pos";
                shiftXLabel = "Grid Shift X";
                shiftZLabel = "Grid Shift Y";
            }
            else
            {
                posLabel    = "Grid X Pos";
                shiftXLabel = "Grid Shift Y";
                shiftZLabel = "Grid Shift Z";
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField(posLabel, gridPos);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Pos");
                gridPos = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField(shiftXLabel, gridShiftAxis1);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift Axis 1");
                gridShiftAxis1 = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField(shiftZLabel, gridShiftAxis2);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift Axis 2");
                gridShiftAxis2 = tempFloat;
            }
        }
Пример #7
0
        public void Draw(GridEditorSettings settings)
        {
            EditorGUI.BeginChangeCheck();
            string _name = EditorGUILayout.TextField("Name", name);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change State Name");
                name = _name;

                settings.UpdateStatesPopupList();
            }

            EditorGUI.BeginChangeCheck();
            Color _gridlineColor = EditorGUILayout.ColorField("Gridline Color", gridlineColor);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Color");
                gridlineColor = _gridlineColor;
            }

            EditorGUI.BeginChangeCheck();
            float _gridSize = EditorGUILayout.FloatField("Grid Size", gridSize);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Size");
                gridSize = _gridSize;
            }

            EditorGUI.BeginChangeCheck();
            int _gridlineCount = EditorGUILayout.IntField("Gridline Count", gridlineCount);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Count");
                gridlineCount = _gridlineCount;
            }

            EditorGUI.BeginChangeCheck();
            GridEditor.GridAlignment _gridAlignment = (GridEditor.GridAlignment)EditorGUILayout.EnumPopup("Grid Alignment", gridAlignment);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Alignment");
                gridAlignment = _gridAlignment;
            }

            string posLabel, shiftXLabel, shiftZLabel;

            if (gridAlignment == GridEditor.GridAlignment.XZ)
            {
                posLabel    = "Grid Y Pos";
                shiftXLabel = "Grid Shift X";
                shiftZLabel = "Grid Shift Z";
            }
            else if (gridAlignment == GridEditor.GridAlignment.XY)
            {
                posLabel    = "Grid Z Pos";
                shiftXLabel = "Grid Shift X";
                shiftZLabel = "Grid Shift Y";
            }
            else
            {
                posLabel    = "Grid X Pos";
                shiftXLabel = "Grid Shift Y";
                shiftZLabel = "Grid Shift Z";
            }

            EditorGUI.BeginChangeCheck();
            float _gridPos = EditorGUILayout.FloatField(posLabel, gridPos);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Pos");
                gridPos = _gridPos;
            }

            EditorGUI.BeginChangeCheck();
            float _gridShiftAxis1 = EditorGUILayout.FloatField(shiftXLabel, gridShiftAxis1);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift Axis 1");
                gridShiftAxis1 = _gridShiftAxis1;
            }

            EditorGUI.BeginChangeCheck();
            float _gridShiftAxis2 = EditorGUILayout.FloatField(shiftZLabel, gridShiftAxis2);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift Axis 2");
                gridShiftAxis2 = _gridShiftAxis2;
            }
        }
Пример #8
0
        public void Draw(GridEditorSettings settings)
        {
            string tempStr;
            Color  tempClr;
            float  tempFloat;
            int    tempInt;

            EditorGUI.BeginChangeCheck();
            tempStr = EditorGUILayout.TextField("Name", name);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change State Name");
                name = tempStr;

                settings.UpdateStatesPopupList();
            }

            EditorGUI.BeginChangeCheck();
            tempClr = EditorGUILayout.ColorField("Gridline Color", gridlineColor);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Color");
                gridlineColor = tempClr;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField("Grid Size", gridSize);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Size");
                gridSize = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempInt = EditorGUILayout.IntField("Gridline Count", gridlineCount);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Gridline Count");
                gridlineCount = tempInt;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField("Grid Y Pos", gridYPos);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Y Pos");
                gridYPos = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField("Grid Shift X", gridShiftX);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift X");
                gridShiftX = tempFloat;
            }

            EditorGUI.BeginChangeCheck();
            tempFloat = EditorGUILayout.FloatField("Grid Shift Z", gridShiftZ);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(settings, "Change Grid Shift Z");
                gridShiftZ = tempFloat;
            }
        }