add snapping check box

This commit is contained in:
2016-12-15 13:09:03 +07:00
parent 2d6f8d37f6
commit afd19224bb
3 changed files with 96 additions and 68 deletions

View File

@@ -16,7 +16,8 @@ namespace IsoTools.Internal {
public static readonly float SnappingDistance = 0.2f;
static bool IsSnappingEnabled() {
return !Event.current.control;
var iso_world = IsoWorld.Instance;
return iso_world && (iso_world.isSnappingEnabled != Event.current.control);
}
void GrabPositions() {
@@ -64,6 +65,7 @@ namespace IsoTools.Internal {
EditorGUILayout.PropertyField(so.FindProperty("_showIsoBounds"));
EditorGUILayout.PropertyField(so.FindProperty("_showScreenBounds"));
EditorGUILayout.PropertyField(so.FindProperty("_showDepends"));
EditorGUILayout.PropertyField(so.FindProperty("_snappingEnabled"));
if ( GUI.changed ) {
so.ApplyModifiedProperties();
}
@@ -281,6 +283,8 @@ namespace IsoTools.Internal {
}
void XYMoveRectangle() {
var iso_world = IsoWorld.Instance;
if ( iso_world ) {
Handles.color = new Color(
Handles.zAxisColor.r,
Handles.zAxisColor.g,
@@ -312,6 +316,7 @@ namespace IsoTools.Internal {
_otherObjects);
}
}
}
//
//

View File

@@ -38,6 +38,20 @@ namespace IsoTools.Internal {
.ToList();
}
void DrawWorldEditorProperties() {
var iso_world = IsoWorld.Instance;
if ( iso_world ) {
var so = new SerializedObject(iso_world);
EditorGUILayout.PropertyField(so.FindProperty("_showIsoBounds"));
EditorGUILayout.PropertyField(so.FindProperty("_showScreenBounds"));
EditorGUILayout.PropertyField(so.FindProperty("_showDepends"));
EditorGUILayout.PropertyField(so.FindProperty("_snappingEnabled"));
if ( GUI.changed ) {
so.ApplyModifiedProperties();
}
}
}
void XYMoveSlider(Color color, Vector3 dir) {
var iso_world = IsoWorld.Instance;
if ( iso_world ) {
@@ -64,6 +78,8 @@ namespace IsoTools.Internal {
}
void XYMoveRectangle() {
var iso_world = IsoWorld.Instance;
if ( iso_world ) {
Handles.color = new Color(
Handles.zAxisColor.r,
Handles.zAxisColor.g,
@@ -105,6 +121,7 @@ namespace IsoTools.Internal {
}
}
}
}
//
//
@@ -135,6 +152,7 @@ namespace IsoTools.Internal {
public override void OnInspectorGUI() {
DrawDefaultInspector();
GrabPositions();
DrawWorldEditorProperties();
}
}
}

View File

@@ -333,6 +333,11 @@ namespace IsoTools {
get { return _showDepends; }
set { _showDepends = value; }
}
[SerializeField] bool _snappingEnabled = true;
public bool isSnappingEnabled {
get { return _snappingEnabled; }
set { _snappingEnabled = value; }
}
#endif
// ---------------------------------------------------------------------