mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-13 15:52:03 +07:00
dirty only not overriden prefab properties. fix missed cached transform in IsoObject.
This commit is contained in:
@@ -48,8 +48,8 @@ namespace IsoTools.Internal {
|
||||
}
|
||||
|
||||
void DrawDetachedInspector() {
|
||||
var single_iso_object = targets.Length == 1 ? target as IsoObject : null;
|
||||
if ( single_iso_object && single_iso_object.IsActive() && !single_iso_object.isoWorld ) {
|
||||
var iso_object = targets.Length == 1 ? target as IsoObject : null;
|
||||
if ( iso_object && iso_object.IsActive() && !iso_object.isoWorld ) {
|
||||
EditorGUILayout.HelpBox(
|
||||
"Detached IsoObject\nNeed to be a child of IsoWorld",
|
||||
MessageType.Warning,
|
||||
@@ -148,10 +148,11 @@ namespace IsoTools.Internal {
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void DirtyTargetPosition() {
|
||||
if ( targets.Length == 1 && (target is IsoObject) && (target as IsoObject).IsActive() ) {
|
||||
void DirtyTargetPositions() {
|
||||
var iso_object = targets.Length == 1 ? target as IsoObject : null;
|
||||
if ( iso_object && iso_object.IsActive() ) {
|
||||
var position_prop = serializedObject.FindProperty("_position");
|
||||
if ( position_prop != null ) {
|
||||
if ( position_prop != null && !position_prop.prefabOverride ) {
|
||||
var last_value = position_prop.vector3Value;
|
||||
position_prop.vector3Value = last_value + Vector3.one;
|
||||
PrefabUtility.RecordPrefabInstancePropertyModifications(target);
|
||||
@@ -183,7 +184,7 @@ namespace IsoTools.Internal {
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
PrepareTargets();
|
||||
DirtyTargetPosition();
|
||||
DirtyTargetPositions();
|
||||
DrawDefaultInspector();
|
||||
DrawCustomInspector();
|
||||
}
|
||||
|
||||
@@ -221,21 +221,23 @@ namespace IsoTools {
|
||||
|
||||
public void FixTransform() {
|
||||
var iso_world = isoWorld;
|
||||
if ( iso_world ) {
|
||||
Internal.Transform.position = IsoUtils.Vec3ChangeZ(
|
||||
var cached_transform = FixCachedTransform();
|
||||
if ( iso_world && cached_transform ) {
|
||||
cached_transform.position = IsoUtils.Vec3ChangeZ(
|
||||
iso_world.IsoToScreen(position),
|
||||
Internal.Transform.position.z);
|
||||
cached_transform.position.z);
|
||||
FixScreenBounds();
|
||||
FixLastTransform();
|
||||
MartDirtyIsoWorld();
|
||||
}
|
||||
FixLastProperties();
|
||||
MartDirtyIsoWorld();
|
||||
}
|
||||
|
||||
public void FixIsoPosition() {
|
||||
var iso_world = isoWorld;
|
||||
if ( iso_world ) {
|
||||
var cached_transform = FixCachedTransform();
|
||||
if ( iso_world && cached_transform ) {
|
||||
position = iso_world.ScreenToIso(
|
||||
Internal.Transform.position,
|
||||
cached_transform.position,
|
||||
positionZ);
|
||||
}
|
||||
}
|
||||
@@ -255,17 +257,21 @@ namespace IsoTools {
|
||||
var r = iso_world.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
|
||||
var b = iso_world.IsoToScreen(position).y;
|
||||
var t = iso_world.IsoToScreen(position + size).y;
|
||||
Internal.ScreenBounds = new IsoRect(l, b, r, t);
|
||||
Internal.ScreenBounds.Set(l, b, r, t);
|
||||
} else {
|
||||
Internal.ScreenBounds = IsoRect.zero;
|
||||
Internal.ScreenBounds.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void FixCachedProperties() {
|
||||
Internal.Transform = transform;
|
||||
Transform FixCachedTransform() {
|
||||
var ret_value = Internal.Transform;
|
||||
if ( !ret_value ) {
|
||||
ret_value = Internal.Transform = transform;
|
||||
}
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
void FixLastProperties() {
|
||||
void FixLastTransform() {
|
||||
Internal.LastTrans = Internal.Transform.position;
|
||||
}
|
||||
|
||||
@@ -286,8 +292,8 @@ namespace IsoTools {
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void Awake() {
|
||||
FixCachedProperties();
|
||||
FixLastProperties();
|
||||
FixCachedTransform();
|
||||
FixLastTransform();
|
||||
FixIsoPosition();
|
||||
}
|
||||
|
||||
@@ -302,14 +308,13 @@ namespace IsoTools {
|
||||
|
||||
protected override void OnTransformParentChanged() {
|
||||
base.OnTransformParentChanged();
|
||||
FixCachedProperties();
|
||||
FixLastProperties();
|
||||
FixCachedTransform();
|
||||
FixLastTransform();
|
||||
FixTransform();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void Reset() {
|
||||
FixCachedProperties();
|
||||
size = Vector3.one;
|
||||
position = Vector3.zero;
|
||||
mode = Mode.Mode2d;
|
||||
@@ -317,7 +322,6 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnValidate() {
|
||||
FixCachedProperties();
|
||||
size = _size;
|
||||
position = _position;
|
||||
mode = _mode;
|
||||
@@ -325,22 +329,26 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnDrawGizmos() {
|
||||
if ( isoWorld && isoWorld.isShowIsoBounds ) {
|
||||
IsoUtils.DrawIsoCube(
|
||||
isoWorld,
|
||||
position + size * 0.5f,
|
||||
size,
|
||||
Color.red);
|
||||
}
|
||||
if ( isoWorld && isoWorld.isShowScreenBounds ) {
|
||||
IsoUtils.DrawRect(
|
||||
Internal.ScreenBounds,
|
||||
Color.green);
|
||||
var iso_world = isoWorld;
|
||||
if ( iso_world ) {
|
||||
if ( iso_world.isShowIsoBounds ) {
|
||||
IsoUtils.DrawIsoCube(
|
||||
iso_world,
|
||||
position + size * 0.5f,
|
||||
size,
|
||||
Color.red);
|
||||
}
|
||||
if ( iso_world.isShowScreenBounds ) {
|
||||
IsoUtils.DrawRect(
|
||||
Internal.ScreenBounds,
|
||||
Color.green);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected() {
|
||||
if ( isoWorld && isoWorld.isShowDepends ) {
|
||||
var iso_world = isoWorld;
|
||||
if ( iso_world && iso_world.isShowDepends ) {
|
||||
for ( int i = 0, e = Internal.SelfDepends.Count; i < e; ++i ) {
|
||||
IsoUtils.DrawLine(
|
||||
Internal.ScreenBounds.center,
|
||||
|
||||
Reference in New Issue
Block a user