You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.5 KiB

  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. namespace ProGrids
  5. {
  6. public class pg_ParameterWindow : EditorWindow
  7. {
  8. public pg_Editor editor;
  9. GUIContent gc_predictiveGrid = new GUIContent("Predictive Grid", "If enabled, the grid will automatically render at the optimal axis based on movement.");
  10. GUIContent gc_snapAsGroup = new GUIContent("Snap as Group", "If enabled, selected objects will keep their relative offsets when moving. If disabled, every object in the selection is snapped to grid independently.");
  11. void OnGUI()
  12. {
  13. GUILayout.Label("Snap Settings", EditorStyles.boldLabel);
  14. float snap = editor.GetSnapIncrement();
  15. EditorGUI.BeginChangeCheck();
  16. snap = EditorGUILayout.FloatField("Snap Value", snap);
  17. if(EditorGUI.EndChangeCheck())
  18. editor.SetSnapIncrement(snap);
  19. EditorGUI.BeginChangeCheck();
  20. int majorLineIncrement = EditorPrefs.GetInt(pg_Constant.MajorLineIncrement, 10);
  21. majorLineIncrement = EditorGUILayout.IntField("Major Line Increment", majorLineIncrement);
  22. majorLineIncrement = majorLineIncrement < 2 ? 2 : majorLineIncrement > 128 ? 128 : majorLineIncrement;
  23. if(EditorGUI.EndChangeCheck())
  24. {
  25. EditorPrefs.SetInt(pg_Constant.MajorLineIncrement, majorLineIncrement);
  26. pg_GridRenderer.majorLineIncrement = majorLineIncrement;
  27. pg_Editor.ForceRepaint();
  28. }
  29. editor.ScaleSnapEnabled = EditorGUILayout.Toggle("Snap On Scale", editor.ScaleSnapEnabled);
  30. SnapUnit _gridUnits = (SnapUnit)(EditorPrefs.HasKey(pg_Constant.GridUnit) ? EditorPrefs.GetInt(pg_Constant.GridUnit) : 0);
  31. bool snapAsGroup = editor.snapAsGroup;
  32. snapAsGroup = EditorGUILayout.Toggle(gc_snapAsGroup, snapAsGroup);
  33. if(snapAsGroup != editor.snapAsGroup)
  34. editor.snapAsGroup = snapAsGroup;
  35. EditorGUI.BeginChangeCheck();
  36. _gridUnits = (SnapUnit)EditorGUILayout.EnumPopup("Grid Units", _gridUnits);
  37. EditorGUI.BeginChangeCheck();
  38. editor.angleValue = EditorGUILayout.Slider("Angle", editor.angleValue, 0f, 180f);
  39. if(EditorGUI.EndChangeCheck())
  40. SceneView.RepaintAll();
  41. if( EditorGUI.EndChangeCheck() )
  42. {
  43. EditorPrefs.SetInt(pg_Constant.GridUnit, (int) _gridUnits);
  44. editor.LoadPreferences();
  45. }
  46. bool tmp = editor.predictiveGrid;
  47. tmp = EditorGUILayout.Toggle(gc_predictiveGrid, tmp);
  48. if( tmp != editor.predictiveGrid )
  49. {
  50. editor.predictiveGrid = tmp;
  51. EditorPrefs.SetBool(pg_Constant.PredictiveGrid, tmp);
  52. }
  53. GUILayout.FlexibleSpace();
  54. if( GUILayout.Button("Done"))
  55. this.Close();
  56. }
  57. }
  58. }