mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-14 17:09:31 +07:00
Disable iso object snapping by children
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
###### Version 3.1.0
|
###### Version 3.1.0
|
||||||
|
|
||||||
* Fix Unity 5.6 warning
|
* Fix Unity 5.6 warning
|
||||||
|
* Disable iso object snapping by children
|
||||||
|
|
||||||
###### Version 3.0.2
|
###### Version 3.0.2
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace IsoTools.Internal {
|
|||||||
iso_world.snappingDistance,
|
iso_world.snappingDistance,
|
||||||
ref result_p_z, iso_object.sizeZ, other.positionZ, other.sizeZ)
|
ref result_p_z, iso_object.sizeZ, other.positionZ, other.sizeZ)
|
||||||
: false;
|
: false;
|
||||||
if ( new_snapping_z ) {
|
if ( new_snapping_z && IsSnapByObjectAllowed(iso_object, other) ) {
|
||||||
delta = result_p_z - iso_orig_z;
|
delta = result_p_z - iso_orig_z;
|
||||||
snapping_z = true;
|
snapping_z = true;
|
||||||
break;
|
break;
|
||||||
@@ -179,7 +179,7 @@ namespace IsoTools.Internal {
|
|||||||
iso_world.snappingDistance,
|
iso_world.snappingDistance,
|
||||||
ref result_pos_iso.y, iso_object.sizeY, other.positionY, other.sizeY)
|
ref result_pos_iso.y, iso_object.sizeY, other.positionY, other.sizeY)
|
||||||
: false;
|
: false;
|
||||||
if ( new_snapping_x || new_snapping_y ) {
|
if ( (new_snapping_x || new_snapping_y) && IsSnapByObjectAllowed(iso_object, other) ) {
|
||||||
if ( new_snapping_x ) {
|
if ( new_snapping_x ) {
|
||||||
snapping_x = true;
|
snapping_x = true;
|
||||||
iso_delta.x = result_pos_iso.x - iso_orig_p.x;
|
iso_delta.x = result_pos_iso.x - iso_orig_p.x;
|
||||||
@@ -371,5 +371,17 @@ namespace IsoTools.Internal {
|
|||||||
iso_world &&
|
iso_world &&
|
||||||
(iso_world.isSnapByObjects != Event.current.control);
|
(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user