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