public static bool LoadPreferences()
        {
            _scaleSnapEnabled = EditorPrefs.HasKey("scaleSnapEnabled") ? EditorPrefs.GetBool("scaleSnapEnabled") : false;
            _gridColorX       = (EditorPrefs.HasKey("gridColorX")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorX")) : GRID_COLOR_X;
            _gridColorY       = (EditorPrefs.HasKey("gridColorY")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorY")) : GRID_COLOR_Y;
            _gridColorZ       = (EditorPrefs.HasKey("gridColorZ")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorZ")) : GRID_COLOR_Z;
            _alphaBump        = (EditorPrefs.HasKey("pg_alphaBump")) ? EditorPrefs.GetFloat("pg_alphaBump") : ALPHA_BUMP;
            _snapMethod       = System.Convert.ToInt32(
                (EditorPrefs.HasKey(pg_Constant.UseAxisConstraints)) ? EditorPrefs.GetBool(pg_Constant.UseAxisConstraints) : USE_AXIS_CONSTRAINTS
                );
            _BracketIncreaseValue = EditorPrefs.HasKey(pg_Constant.BracketIncreaseValue) ? EditorPrefs.GetFloat(pg_Constant.BracketIncreaseValue) : .25f;
            _GridUnits            = (SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0);
            _syncUnitySnap        = EditorPrefs.GetBool(pg_Constant.SyncUnitySnap, true);

            _IncreaseGridSize = EditorPrefs.HasKey("pg_Editor::IncreaseGridSize")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::IncreaseGridSize")
                                : KeyCode.Equals;
            _DecreaseGridSize = EditorPrefs.HasKey("pg_Editor::DecreaseGridSize")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::DecreaseGridSize")
                                : KeyCode.Minus;
            _NudgePerspectiveBackward = EditorPrefs.HasKey("pg_Editor::NudgePerspectiveBackward")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::NudgePerspectiveBackward")
                                : KeyCode.LeftBracket;
            _NudgePerspectiveForward = EditorPrefs.HasKey("pg_Editor::NudgePerspectiveForward")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::NudgePerspectiveForward")
                                : KeyCode.RightBracket;
            _NudgePerspectiveReset = EditorPrefs.HasKey("pg_Editor::NudgePerspectiveReset")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::NudgePerspectiveReset")
                                : KeyCode.Alpha0;
            _CyclePerspective = EditorPrefs.HasKey("pg_Editor::CyclePerspective")
                                ? (KeyCode)EditorPrefs.GetInt("pg_Editor::CyclePerspective")
                                : KeyCode.Backslash;

            return(true);
        }
        void OnGUI()
        {
            GUILayout.Label("Snap Settings", EditorStyles.boldLabel);

            float snap = editor.GetSnapIncrement();

            EditorGUI.BeginChangeCheck();

            snap = EditorGUILayout.FloatField("Snap Value", snap);

            if (EditorGUI.EndChangeCheck())
            {
                editor.SetSnapIncrement(snap);
            }

            editor.ScaleSnapEnabled = EditorGUILayout.Toggle("Snap On Scale", editor.ScaleSnapEnabled);

            SnapUnit _gridUnits = (SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0);

            bool snapAsGroup = editor.snapAsGroup;

            snapAsGroup = EditorGUILayout.Toggle(gc_snapAsGroup, snapAsGroup);
            if (snapAsGroup != editor.snapAsGroup)
            {
                editor.snapAsGroup = snapAsGroup;
            }

            EditorGUI.BeginChangeCheck();

            _gridUnits = (SnapUnit)EditorGUILayout.EnumPopup("Grid Units", _gridUnits);

            EditorGUI.BeginChangeCheck();
            editor.angleValue = EditorGUILayout.Slider("Angle", editor.angleValue, 0f, 180f);
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetInt(pg_Constant.GridUnit, (int)_gridUnits);
                editor.LoadPreferences();
            }

            bool tmp = editor.predictiveGrid;

            tmp = EditorGUILayout.Toggle(gc_predictiveGrid, tmp);
            if (tmp != editor.predictiveGrid)
            {
                editor.predictiveGrid = tmp;
                EditorPrefs.SetBool(pg_Constant.PredictiveGrid, tmp);
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Done"))
            {
                this.Close();
            }
        }
Esempio n. 3
0
        public static bool LoadPreferences()
        {
            s_GridColorX           = EditorUtility.GetColorFromJson(EditorPrefs.GetString(PreferenceKeys.GridColorX), Defaults.GridColorX);
            s_GridColorY           = EditorUtility.GetColorFromJson(EditorPrefs.GetString(PreferenceKeys.GridColorY), Defaults.GridColorY);
            s_GridColorZ           = EditorUtility.GetColorFromJson(EditorPrefs.GetString(PreferenceKeys.GridColorZ), Defaults.GridColorZ);
            s_AlphaBump            = EditorPrefs.GetFloat(PreferenceKeys.AlphaBump, Defaults.AlphaBump);
            s_BracketIncreaseValue = EditorPrefs.HasKey(PreferenceKeys.BracketIncreaseValue) ? EditorPrefs.GetFloat(PreferenceKeys.BracketIncreaseValue) : .25f;
            s_GridUnits            = (SnapUnit)EditorPrefs.GetInt(PreferenceKeys.GridUnit, 0);
            s_SyncUnitySnap        = EditorPrefs.GetBool(PreferenceKeys.SyncUnitySnap, true);
            s_SnapMethod           = (SnapMethod)EditorPrefs.GetInt(PreferenceKeys.SnapMethod, (int)Defaults.SnapMethod);

            s_IncreaseGridSize = EditorPrefs.HasKey(PreferenceKeys.IncreaseGridSize)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.IncreaseGridSize)
                                : KeyCode.Equals;
            s_DecreaseGridSize = EditorPrefs.HasKey(PreferenceKeys.DecreaseGridSize)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.DecreaseGridSize)
                                : KeyCode.Minus;
            s_NudgePerspectiveBackward = EditorPrefs.HasKey(PreferenceKeys.NudgePerspectiveBackward)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.NudgePerspectiveBackward)
                                : KeyCode.LeftBracket;
            s_NudgePerspectiveForward = EditorPrefs.HasKey(PreferenceKeys.NudgePerspectiveForward)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.NudgePerspectiveForward)
                                : KeyCode.RightBracket;
            s_NudgePerspectiveReset = EditorPrefs.HasKey(PreferenceKeys.ResetGridShortcutModifiers)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.ResetGridShortcutModifiers)
                                : KeyCode.Alpha0;
            s_CyclePerspective = EditorPrefs.HasKey(PreferenceKeys.CyclePerspective)
                                ? (KeyCode)EditorPrefs.GetInt(PreferenceKeys.CyclePerspective)
                                : KeyCode.Backslash;

            return(true);
        }
Esempio n. 4
0
        internal static float SnapUnitValue(SnapUnit su)
        {
            switch (su)
            {
            case SnapUnit.Meter:
                return(Defaults.Meter);

            case SnapUnit.Centimeter:
                return(Defaults.Centimeter);

            case SnapUnit.Millimeter:
                return(Defaults.Millimeter);

            case SnapUnit.Inch:
                return(Defaults.Inch);

            case SnapUnit.Foot:
                return(Defaults.Foot);

            case SnapUnit.Yard:
                return(Defaults.Yard);

            case SnapUnit.Parsec:
                return(Defaults.Parsec);

            default:
                return(Defaults.Meter);
            }
        }
Esempio n. 5
0
        public static float SnapUnitValue(SnapUnit su)
        {
            switch (su)
            {
            case SnapUnit.Meter:
                return(1f);

            case SnapUnit.Centimeter:
                return(0.01f);

            case SnapUnit.Millimeter:
                return(0.001f);

            case SnapUnit.Inch:
                return(0.025399987f);

            case SnapUnit.Foot:
                return(0.3048f);

            case SnapUnit.Yard:
                return(1.09361f);

            case SnapUnit.Parsec:
                return(5f);

            default:
                return(1f);
            }
        }
Esempio n. 6
0
    public void SetSnapValue(SnapUnit su, float val)
    {
                #if PRO
        snapValue = SnapUnitValue(su) * val;
        SceneView.RepaintAll();
        SetSharedSnapValues(snapEnabled, snapValue);

        EditorPrefs.SetInt(pg_Constant.GridUnit, (int)su);
        EditorPrefs.SetFloat(pg_Constant.SnapValue, val);

        // update gui (only necessary when calling with editorpref values)
        t_snapValue = val;
        snapUnit    = su;

        switch (su)
        {
        case SnapUnit.Inch:
            PRIMARY_COLOR_INCREMENT = 12;                       // blasted imperial units
            break;

        case SnapUnit.Foot:
            PRIMARY_COLOR_INCREMENT = 3;
            break;

        default:
            PRIMARY_COLOR_INCREMENT = 10;
            break;
        }
                #else
        Debug.LogWarning("Ye ought not be seein' this ye scurvy pirate.");
                #endif
    }
Esempio n. 7
0
    public float SnapUnitValue(SnapUnit su)
    {
        switch (su)
        {
        case SnapUnit.Meter:
            return(METER);

                        #if PRO
        case SnapUnit.Centimeter:
            return(CENTIMETER);

        case SnapUnit.Millimeter:
            return(MILLIMETER);

        case SnapUnit.Inch:
            return(INCH);

        case SnapUnit.Foot:
            return(FOOT);

        case SnapUnit.Yard:
            return(YARD);

        case SnapUnit.Parsec:
            return(PARSEC);
                        #endif
        default:
            return(METER);
        }
    }
Esempio n. 8
0
 public SnapSettings()
 {
     m_SnapValue        = Defaults.SnapValue;
     m_SnapUnit         = Defaults.SnapUnit;
     m_ScaleSnapEnabled = Defaults.SnapOnScale;
     m_SnapAsGroup      = Defaults.SnapAsGroup;
     m_SnapMultiplier   = Defaults.DefaultSnapMultiplier;
 }
Esempio n. 9
0
 public void SetSnapValue(SnapUnit su, float val)
 {
             #if PRO
     snapValue = SnapUnitValue(su) * val;
     SceneView.RepaintAll();
     SetSharedSnapValues(snapEnabled, snapValue);
             #else
     Debug.LogWarning("Ye ought not be seein' this ye scurvy pirate.");
             #endif
 }
Esempio n. 10
0
 public SnapUnit SnapUnitWithString(string str)
 {
     foreach (SnapUnit su in SnapUnit.GetValues(typeof(SnapUnit)))
     {
         if (su.ToString() == str)
         {
             return(su);
         }
     }
     return((SnapUnit)0);
 }
Esempio n. 11
0
        public static void PreferencesGUI()
        {
            if (!prefsLoaded)
            {
                prefsLoaded = LoadPreferences();
            }

            // EditorGUILayout.HelpBox("Changes will take effect on the next ProGrids open.", MessageType.Info);

            GUILayout.Label("Grid Colors per Axis", EditorStyles.boldLabel);
            _gridColorX = EditorGUILayout.ColorField("X Axis", _gridColorX);
            _gridColorY = EditorGUILayout.ColorField("Y Axis", _gridColorY);
            _gridColorZ = EditorGUILayout.ColorField("Z Axis", _gridColorZ);

            _alphaBump = EditorGUILayout.Slider(new GUIContent("Tenth Line Alpha", "Every 10th line will have it's alpha value bumped by this amount."), _alphaBump, 0f, 1f);

            // not used
            // _BracketIncreaseValue = EditorGUILayout.FloatField(new GUIContent("Grid Increment Value", "Affects the amount by which the bracket keys will increment or decrement that snap value."), _BracketIncreaseValue);

            _GridUnits = (SnapUnit)EditorGUILayout.EnumPopup("Grid Units", _GridUnits);

            _scaleSnapEnabled = EditorGUILayout.Toggle("Snap On Scale", _scaleSnapEnabled);

            // GUILayout.BeginHorizontal();
            // EditorGUILayout.PrefixLabel(new GUIContent("Axis Constraints", "If toggled, objects will be automatically grid aligned on all axes when moving."));

            _snapMethod = EditorGUILayout.IntPopup("Snap Method", _snapMethod, SnapMethod, SnapVals);

            _syncUnitySnap = EditorGUILayout.Toggle("Sync w/ Unity Snap", _syncUnitySnap);

            // GUILayout.EndHorizontal();

            GUILayout.Label("Shortcuts", EditorStyles.boldLabel);
            _IncreaseGridSize         = (KeyCode)EditorGUILayout.EnumPopup("Increase Grid Size", _IncreaseGridSize);
            _DecreaseGridSize         = (KeyCode)EditorGUILayout.EnumPopup("Decrease Grid Size", _DecreaseGridSize);
            _NudgePerspectiveBackward = (KeyCode)EditorGUILayout.EnumPopup("Nudge Perspective Backward", _NudgePerspectiveBackward);
            _NudgePerspectiveForward  = (KeyCode)EditorGUILayout.EnumPopup("Nudge Perspective Forward", _NudgePerspectiveForward);
            _NudgePerspectiveReset    = (KeyCode)EditorGUILayout.EnumPopup("Nudge Perspective Reset", _NudgePerspectiveReset);
            _CyclePerspective         = (KeyCode)EditorGUILayout.EnumPopup("Cycle Perspective", _CyclePerspective);

            if (GUILayout.Button("Reset"))
            {
                if (EditorUtility.DisplayDialog("Delete ProGrids editor preferences?", "Are you sure you want to delete these?, this action cannot be undone.", "Yes", "No"))
                {
                    ResetPrefs();
                }
            }

            if (GUI.changed)
            {
                SetPreferences();
            }
        }
Esempio n. 12
0
        public static bool LoadPreferences()
        {
            _scaleSnapEnabled = EditorPrefs.HasKey("scaleSnapEnabled") ? EditorPrefs.GetBool("scaleSnapEnabled") : false;
            _gridColorX = (EditorPrefs.HasKey("gridColorX")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorX")) : GRID_COLOR_X;
            _gridColorY = (EditorPrefs.HasKey("gridColorY")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorY")) : GRID_COLOR_Y;
            _gridColorZ = (EditorPrefs.HasKey("gridColorZ")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorZ")) : GRID_COLOR_Z;
            _alphaBump = (EditorPrefs.HasKey("pg_alphaBump")) ? EditorPrefs.GetFloat("pg_alphaBump") : ALPHA_BUMP;
            _snapMethod = System.Convert.ToInt32(
                (EditorPrefs.HasKey(pg_Constant.UseAxisConstraints)) ? EditorPrefs.GetBool(pg_Constant.UseAxisConstraints) : USE_AXIS_CONSTRAINTS
                );
            _BracketIncreaseValue = EditorPrefs.HasKey(pg_Constant.BracketIncreaseValue) ? EditorPrefs.GetFloat(pg_Constant.BracketIncreaseValue) : .25f;
            _GridUnits = (SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0);

            return true;
        }
Esempio n. 13
0
        public static bool LoadPreferences()
        {
            _scaleSnapEnabled = EditorPrefs.HasKey("scaleSnapEnabled") ? EditorPrefs.GetBool("scaleSnapEnabled") : false;
            _gridColorX       = (EditorPrefs.HasKey("gridColorX")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorX")) : GRID_COLOR_X;
            _gridColorY       = (EditorPrefs.HasKey("gridColorY")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorY")) : GRID_COLOR_Y;
            _gridColorZ       = (EditorPrefs.HasKey("gridColorZ")) ? pg_Util.ColorWithString(EditorPrefs.GetString("gridColorZ")) : GRID_COLOR_Z;
            _alphaBump        = (EditorPrefs.HasKey("pg_alphaBump")) ? EditorPrefs.GetFloat("pg_alphaBump") : ALPHA_BUMP;
            _snapMethod       = System.Convert.ToInt32(
                (EditorPrefs.HasKey(pg_Constant.UseAxisConstraints)) ? EditorPrefs.GetBool(pg_Constant.UseAxisConstraints) : USE_AXIS_CONSTRAINTS
                );
            _BracketIncreaseValue = EditorPrefs.HasKey(pg_Constant.BracketIncreaseValue) ? EditorPrefs.GetFloat(pg_Constant.BracketIncreaseValue) : .25f;
            _GridUnits            = (SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0);

            return(true);
        }
Esempio n. 14
0
    public void SetSnapValue(SnapUnit su, float val, int multiplier)
    {
        int clamp_multiplier = (int)(Mathf.Min(Mathf.Max(25, multiplier), 102400));

        float value_multiplier = clamp_multiplier / 100f;

        /**
         * multiplier is a value modifies the snap val.  100 = no change,
         * 50 is half val, 200 is double val, etc.
         */

                #if PRO
        snapValue = SnapUnitValue(su) * val * value_multiplier;
        SceneView.RepaintAll();
        SetSharedSnapValues(snapEnabled, snapValue);

        EditorPrefs.SetInt(pg_Constant.GridUnit, (int)su);
        EditorPrefs.SetFloat(pg_Constant.SnapValue, val);
        EditorPrefs.SetInt(pg_Constant.SnapMultiplier, clamp_multiplier);

        // Bugger.SetKey("Grid Unit", (int)su);
        // Bugger.SetKey("Snap Value", val);
        // Bugger.SetKey("Snap Multiplier", clamp_multiplier);

        // update gui (only necessary when calling with editorpref values)
        t_snapValue = val * value_multiplier;
        snapUnit    = su;

        switch (su)
        {
        case SnapUnit.Inch:
            PRIMARY_COLOR_INCREMENT = 12;                       // blasted imperial units
            break;

        case SnapUnit.Foot:
            PRIMARY_COLOR_INCREMENT = 3;
            break;

        default:
            PRIMARY_COLOR_INCREMENT = 10;
            break;
        }

        gridRepaint = true;
                #else
        Debug.LogWarning("Ye ought not be seein' this ye scurvy pirate.");
                #endif
    }
Esempio n. 15
0
    public void SetSnapValue(SnapUnit su, float val)
    {
                #if PRO
        snapValue = SnapUnitValue(su) * val;
        SceneView.RepaintAll();
        SetSharedSnapValues(snapEnabled, snapValue);

        EditorPrefs.SetFloat(k.SnapValueEditorPref, val);
        EditorPrefs.SetString(k.SnapUnitEditorPref, su.ToString());

        // update gui (only necessary when calling with editorpref values)
        t_snapValue = val;
        snapUnit    = su;
                #else
        Debug.LogWarning("Ye ought not be seein' this ye scurvy pirate.");
                #endif
    }
Esempio n. 16
0
        public static void PreferencesGUI(string searchContext)
        {
            if (!s_PrefsLoaded)
            {
                s_PrefsLoaded = LoadPreferences();
            }

            EditorGUI.BeginChangeCheck();

            GUILayout.Label("Snap Behavior", EditorStyles.boldLabel);
            s_AlphaBump     = EditorGUILayout.Slider(new GUIContent("Tenth Line Alpha", "Every 10th line will have it's alpha value bumped by this amount."), s_AlphaBump, 0f, 1f);
            s_GridUnits     = (SnapUnit)EditorGUILayout.EnumPopup("Grid Units", s_GridUnits);
            s_SnapMethod    = (SnapMethod)EditorGUILayout.EnumPopup("Snap Method", s_SnapMethod);
            s_SyncUnitySnap = EditorGUILayout.Toggle("Sync w/ Unity Snap", s_SyncUnitySnap);

            GUILayout.Label("Grid Colors", EditorStyles.boldLabel);
            s_GridColorX = EditorGUILayout.ColorField("X Axis", s_GridColorX);
            s_GridColorY = EditorGUILayout.ColorField("Y Axis", s_GridColorY);
            s_GridColorZ = EditorGUILayout.ColorField("Z Axis", s_GridColorZ);

            GUILayout.Label("Shortcuts", EditorStyles.boldLabel);
            s_IncreaseGridSize         = (KeyCode)EditorGUILayout.EnumPopup("Increase Grid Size", s_IncreaseGridSize);
            s_DecreaseGridSize         = (KeyCode)EditorGUILayout.EnumPopup("Decrease Grid Size", s_DecreaseGridSize);
            s_NudgePerspectiveBackward = (KeyCode)EditorGUILayout.EnumPopup("Nudge Perspective Backward", s_NudgePerspectiveBackward);
            s_NudgePerspectiveForward  = (KeyCode)EditorGUILayout.EnumPopup("Nudge Perspective Forward", s_NudgePerspectiveForward);
            s_NudgePerspectiveReset    = (KeyCode)EditorGUILayout.EnumPopup(s_ResetGridModifiers, s_NudgePerspectiveReset);
            s_CyclePerspective         = (KeyCode)EditorGUILayout.EnumPopup("Cycle Perspective", s_CyclePerspective);

            if (GUILayout.Button("Reset"))
            {
                if (UnityEditor.EditorUtility.DisplayDialog("Delete ProGrids editor preferences?", "Are you sure you want to delete these? This action cannot be undone.", "Yes", "No"))
                {
                    ResetPrefs();
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                SetPreferences();
            }
        }
Esempio n. 17
0
		public static void PreferencesGUI ()
		{
			if(!prefsLoaded)
			{
				prefsLoaded = LoadPreferences();
				OnWindowResize();
			}

			// EditorGUILayout.HelpBox("Changes will take effect on the next ProGrids open.", MessageType.Info);

			GUILayout.Label("Grid Colors per Axis", EditorStyles.boldLabel);
			_gridColorX = EditorGUILayout.ColorField("X Axis", _gridColorX);
			_gridColorY = EditorGUILayout.ColorField("Y Axis", _gridColorY);
			_gridColorZ = EditorGUILayout.ColorField("Z Axis", _gridColorZ);

			_alphaBump = EditorGUILayout.Slider(new GUIContent("Tenth Line Alpha", "Every 10th line will have it's alpha value bumped by this amount."), _alphaBump, 0f, 1f);

			// not used
			// _BracketIncreaseValue = EditorGUILayout.FloatField(new GUIContent("Grid Increment Value", "Affects the amount by which the bracket keys will increment or decrement that snap value."), _BracketIncreaseValue);

			_GridUnits = (SnapUnit)EditorGUILayout.EnumPopup("Grid Units", _GridUnits);

			_scaleSnapEnabled = EditorGUILayout.Toggle("Snap On Scale", _scaleSnapEnabled);

			// GUILayout.BeginHorizontal();
			// EditorGUILayout.PrefixLabel(new GUIContent("Axis Constraints", "If toggled, objects will be automatically grid aligned on all axes when moving."));

			_snapMethod = EditorGUILayout.IntPopup("Snap Method", _snapMethod, SnapMethod, SnapVals);

			// GUILayout.EndHorizontal();
			
			if(GUI.Button(resetRect, "Reset"))
			{
				if(EditorUtility.DisplayDialog("Delete ProGrids editor preferences?", "Are you sure you want to delete these?, this action cannot be undone.", "Yes", "No"))
					ResetPrefs();
			}

			if(GUI.changed)
				SetPreferences();
		}
Esempio n. 18
0
		public static float SnapUnitValue(SnapUnit su)
		{
			switch(su)
			{
				case SnapUnit.Meter:
					return pg_Constant.METER;
#if PRO
				case SnapUnit.Centimeter:
					return pg_Constant.CENTIMETER;
				case SnapUnit.Millimeter:
					return pg_Constant.MILLIMETER;
				case SnapUnit.Inch:
					return pg_Constant.INCH;
				case SnapUnit.Foot:
					return pg_Constant.FOOT;
				case SnapUnit.Yard:
					return pg_Constant.YARD;
				case SnapUnit.Parsec:
					return pg_Constant.PARSEC;
#endif
				default:
					return pg_Constant.METER;
			}
		}
Esempio n. 19
0
    public void OnGUI()
    {
        if (!EditorGUIUtility.isProSkin)
        {
            oldColor            = GUI.backgroundColor;
            GUI.backgroundColor = pgButtonColor;
        }

        GUI.skin.button.padding = pad;

        if (pgButton(gc_SnapToGrid))
        {
            SnapToGrid(Selection.transforms);
        }

        gc_SnapEnabled.image = (snapEnabled) ? gui_SnapOn : gui_SnapOff;
        if (pgButton(gc_SnapEnabled))
        {
            SetSnapEnabled(!snapEnabled);
        }

        gc_DrawGrid.image = (drawGrid) ? gui_VisOn : gui_VisOff;
        if (pgButton(gc_DrawGrid))
        {
            SetGridEnabled(!drawGrid);
        }


        EditorGUI.BeginChangeCheck();
        snapUnit = (SnapUnit)EditorGUILayout.EnumPopup(gc_SnapUnit, snapUnit,
                                                       GUILayout.MinWidth(BUTTON_SIZE),
                                                       GUILayout.MaxWidth(BUTTON_SIZE));

                #if !PRO
        GUI.enabled = false;
                #endif

        gc_DrawAngles.image = (drawAngles) ? gui_AnglesOn : gui_AnglesOff;
        if (GUILayout.Button(gc_DrawAngles, toggleStyle, GUILayout.MinWidth(BUTTON_SIZE)))
        {
            SetDrawAngles(!drawAngles);
        }

                #if PRO
        GUI.enabled = drawAngles;
                #endif

        GUILayout.Label("Angle");

        EditorGUI.BeginChangeCheck();
        angleValue = EditorGUILayout.FloatField(gc_AngleValue, angleValue,
                                                GUILayout.MinWidth(BUTTON_SIZE),
                                                GUILayout.MaxWidth(BUTTON_SIZE));
        if (EditorGUI.EndChangeCheck())
        {
            SceneView.RepaintAll();
        }
                #if PRO
        GUI.enabled = true;
                #endif

        GUILayout.Label("Snap");
        t_snapValue = EditorGUILayout.FloatField("", t_snapValue,
                                                 GUILayout.MinWidth(BUTTON_SIZE),
                                                 GUILayout.MaxWidth(BUTTON_SIZE));
        if (EditorGUI.EndChangeCheck())
        {
                        #if PRO
            SetSnapValue(snapUnit, t_snapValue);
                        #endif
        }

                #if !PRO
        GUI.enabled = true;

        GUI.backgroundColor = Color.cyan;
        if (GUILayout.Button("More", GUILayout.MinHeight(18)))
        {
            OpenProGridsPopup();
        }
        GUI.backgroundColor = Color.white;
                #endif

        if (!EditorGUIUtility.isProSkin)
        {
            GUI.backgroundColor = oldColor;
        }
        GUI.skin.button.padding = oldPad;
    }
Esempio n. 20
0
	public void SetSnapValue(SnapUnit su, float val)
	{
		#if PRO
		snapValue = SnapUnitValue(su) * val;
		SceneView.RepaintAll();
		SetSharedSnapValues(snapEnabled, snapValue);
		
		EditorPrefs.SetInt(pg_Constant.GridUnit, (int)su);
		EditorPrefs.SetFloat(pg_Constant.SnapValue, val);
		
		// update gui (only necessary when calling with editorpref values)
		t_snapValue = val;
		snapUnit = su;

		switch(su)
		{
			case SnapUnit.Inch:
				PRIMARY_COLOR_INCREMENT = 12;	// blasted imperial units
				break;

			case SnapUnit.Foot:
				PRIMARY_COLOR_INCREMENT = 3;
				break;

			default:
				PRIMARY_COLOR_INCREMENT = 10;
				break;
		}

		#else
		Debug.LogWarning("Ye ought not be seein' this ye scurvy pirate.");
		#endif
	}