mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
micro optimizations
This commit is contained in:
@@ -241,10 +241,11 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void FixTransform() {
|
public void FixTransform() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
|
if ( iso_world ) {
|
||||||
FixInternalTransform();
|
FixInternalTransform();
|
||||||
Internal.Transform.position = IsoUtils.Vec3ChangeZ(
|
Internal.Transform.position = IsoUtils.Vec3ChangeZ(
|
||||||
isoWorld.IsoToScreen(position),
|
iso_world.IsoToScreen(position),
|
||||||
Internal.Transform.position.z);
|
Internal.Transform.position.z);
|
||||||
FixScreenRect();
|
FixScreenRect();
|
||||||
}
|
}
|
||||||
@@ -253,9 +254,10 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void FixIsoPosition() {
|
public void FixIsoPosition() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
|
if ( iso_world ) {
|
||||||
FixInternalTransform();
|
FixInternalTransform();
|
||||||
position = isoWorld.ScreenToIso(
|
position = iso_world.ScreenToIso(
|
||||||
Internal.Transform.position,
|
Internal.Transform.position,
|
||||||
positionZ);
|
positionZ);
|
||||||
}
|
}
|
||||||
@@ -270,11 +272,12 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FixScreenRect() {
|
void FixScreenRect() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
var l = isoWorld.IsoToScreen(position + IsoUtils.Vec3FromY(size.y)).x;
|
if ( iso_world ) {
|
||||||
var r = isoWorld.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
|
var l = iso_world.IsoToScreen(position + IsoUtils.Vec3FromY(size.y)).x;
|
||||||
var b = isoWorld.IsoToScreen(position).y;
|
var r = iso_world.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
|
||||||
var t = isoWorld.IsoToScreen(position + size).y;
|
var b = iso_world.IsoToScreen(position).y;
|
||||||
|
var t = iso_world.IsoToScreen(position + size).y;
|
||||||
Internal.ScreenRect = new IsoUtils.Rect(l, b, r - l, t - b);
|
Internal.ScreenRect = new IsoUtils.Rect(l, b, r - l, t - b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,8 +294,9 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MartDirtyIsoWorld() {
|
void MartDirtyIsoWorld() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
isoWorld.MarkDirty(this);
|
if ( iso_world ) {
|
||||||
|
iso_world.MarkDirty(this);
|
||||||
}
|
}
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
EditorUtility.SetDirty(this);
|
EditorUtility.SetDirty(this);
|
||||||
@@ -311,15 +315,17 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
isoWorld.AddIsoObject(this);
|
if ( iso_world ) {
|
||||||
|
iso_world.AddIsoObject(this);
|
||||||
}
|
}
|
||||||
MartDirtyIsoWorld();
|
MartDirtyIsoWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable() {
|
void OnDisable() {
|
||||||
if ( isoWorld ) {
|
var iso_world = isoWorld;
|
||||||
isoWorld.RemoveIsoObject(this);
|
if ( iso_world ) {
|
||||||
|
iso_world.RemoveIsoObject(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user