Disable iso object snapping by children

This commit is contained in:
2018-01-02 04:32:56 +07:00
parent 17a5f3461b
commit 82b2ef048c
2 changed files with 15 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
###### Version 3.1.0
* Fix Unity 5.6 warning
* Disable iso object snapping by children
###### Version 3.0.2

View File

@@ -101,7 +101,7 @@ namespace IsoTools.Internal {
iso_world.snappingDistance,
ref result_p_z, iso_object.sizeZ, other.positionZ, other.sizeZ)
: false;
if ( new_snapping_z ) {
if ( new_snapping_z && IsSnapByObjectAllowed(iso_object, other) ) {
delta = result_p_z - iso_orig_z;
snapping_z = true;
break;
@@ -179,7 +179,7 @@ namespace IsoTools.Internal {
iso_world.snappingDistance,
ref result_pos_iso.y, iso_object.sizeY, other.positionY, other.sizeY)
: false;
if ( new_snapping_x || new_snapping_y ) {
if ( (new_snapping_x || new_snapping_y) && IsSnapByObjectAllowed(iso_object, other) ) {
if ( new_snapping_x ) {
snapping_x = true;
iso_delta.x = result_pos_iso.x - iso_orig_p.x;
@@ -371,5 +371,17 @@ namespace IsoTools.Internal {
iso_world &&
(iso_world.isSnapByObjects != Event.current.control);
}
public static bool IsSnapByObjectAllowed(IsoObject iso_object, IsoObject other_object) {
var iso_object_trans = iso_object.transform;
var other_object_trans = other_object.transform;
while ( other_object_trans ) {
if ( other_object_trans.parent == iso_object_trans ) {
return false;
}
other_object_trans = other_object_trans.parent;
}
return true;
}
}
}