mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
new sorting wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
@@ -8,6 +9,10 @@ namespace IsoTools {
|
||||
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||
public class IsoObject : MonoBehaviour {
|
||||
|
||||
public bool Visited = false;
|
||||
public HashSet<IsoObject> SelfDepends = new HashSet<IsoObject>();
|
||||
public HashSet<IsoObject> TheirDepends = new HashSet<IsoObject>();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// size
|
||||
@@ -166,38 +171,35 @@ namespace IsoTools {
|
||||
IsoWorld _isoWorld = null;
|
||||
public IsoWorld isoWorld {
|
||||
get {
|
||||
if ( (object)_isoWorld == null ) {
|
||||
if ( !_isoWorld ) {
|
||||
_isoWorld = GameObject.FindObjectOfType<IsoWorld>();
|
||||
}
|
||||
if ( (object)_isoWorld == null ) {
|
||||
throw new UnityException("IsoObject. IsoWorld not found!");
|
||||
}
|
||||
return _isoWorld;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetIsoWorld() {
|
||||
_isoWorld = null;
|
||||
}
|
||||
|
||||
public void FixTransform() {
|
||||
#if UNITY_EDITOR
|
||||
if ( !Application.isPlaying && isAlignment ) {
|
||||
_position = tilePosition;
|
||||
}
|
||||
#endif
|
||||
transform.position = IsoUtils.Vec3ChangeZ(
|
||||
isoWorld.IsoToScreen(position),
|
||||
transform.position.z);
|
||||
if ( isoWorld ) {
|
||||
transform.position = IsoUtils.Vec3ChangeZ(
|
||||
isoWorld.IsoToScreen(position),
|
||||
transform.position.z);
|
||||
}
|
||||
FixLastProperties();
|
||||
MartDirtyIsoWorld();
|
||||
MarkEditorObjectDirty();
|
||||
}
|
||||
|
||||
public void FixIsoPosition() {
|
||||
position = isoWorld.ScreenToIso(
|
||||
transform.position,
|
||||
positionZ);
|
||||
if ( isoWorld ) {
|
||||
position = isoWorld.ScreenToIso(
|
||||
transform.position,
|
||||
positionZ);
|
||||
}
|
||||
}
|
||||
|
||||
void FixLastProperties() {
|
||||
@@ -209,7 +211,9 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void MartDirtyIsoWorld() {
|
||||
isoWorld.MarkDirty(this);
|
||||
if ( isoWorld ) {
|
||||
isoWorld.MarkDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
void MarkEditorObjectDirty() {
|
||||
@@ -230,9 +234,18 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
if ( isoWorld ) {
|
||||
isoWorld.AddIsoObject(this);
|
||||
}
|
||||
MartDirtyIsoWorld();
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
if ( isoWorld ) {
|
||||
isoWorld.RemoveIsoObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void Reset() {
|
||||
size = Vector3.one;
|
||||
@@ -245,7 +258,7 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnDrawGizmos() {
|
||||
if ( isShowBounds ) {
|
||||
if ( isShowBounds && isoWorld ) {
|
||||
IsoUtils.DrawCube(isoWorld, position + size * 0.5f, size, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user