diff --git a/Assets/IsoTools/Examples/Prefabs/Cube_1x1x1.prefab b/Assets/IsoTools/Examples/Prefabs/Cube_1x1x1.prefab index 9dfe527..c4f37d2 100644 --- a/Assets/IsoTools/Examples/Prefabs/Cube_1x1x1.prefab +++ b/Assets/IsoTools/Examples/Prefabs/Cube_1x1x1.prefab @@ -42,6 +42,8 @@ MonoBehaviour: m_EditorClassIdentifier: _size: {x: 1, y: 1, z: 1} _position: {x: 0, y: 0, z: 0} + _alignment: 1 + _showBounds: 0 --- !u!212 &21217528 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/IsoTools/Examples/Prefabs/Cube_1x1x3.prefab b/Assets/IsoTools/Examples/Prefabs/Cube_1x1x3.prefab index d5ee521..429c6ad 100644 --- a/Assets/IsoTools/Examples/Prefabs/Cube_1x1x3.prefab +++ b/Assets/IsoTools/Examples/Prefabs/Cube_1x1x3.prefab @@ -42,6 +42,8 @@ MonoBehaviour: m_EditorClassIdentifier: _size: {x: 1, y: 1, z: 3} _position: {x: 0, y: 0, z: 0} + _alignment: 1 + _showBounds: 0 --- !u!212 &21263702 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/IsoTools/Examples/Prefabs/Cube_1x3x1.prefab b/Assets/IsoTools/Examples/Prefabs/Cube_1x3x1.prefab index cad3744..f4efd7f 100644 --- a/Assets/IsoTools/Examples/Prefabs/Cube_1x3x1.prefab +++ b/Assets/IsoTools/Examples/Prefabs/Cube_1x3x1.prefab @@ -42,6 +42,8 @@ MonoBehaviour: m_EditorClassIdentifier: _size: {x: 1, y: 3, z: 1} _position: {x: 0, y: 0, z: 0} + _alignment: 1 + _showBounds: 0 --- !u!212 &21253620 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/IsoTools/Examples/Prefabs/Cube_3x1x1.prefab b/Assets/IsoTools/Examples/Prefabs/Cube_3x1x1.prefab index 9430c8e..7e784d2 100644 --- a/Assets/IsoTools/Examples/Prefabs/Cube_3x1x1.prefab +++ b/Assets/IsoTools/Examples/Prefabs/Cube_3x1x1.prefab @@ -42,6 +42,8 @@ MonoBehaviour: m_EditorClassIdentifier: _size: {x: 3, y: 1, z: 1} _position: {x: 0, y: 0, z: 0} + _alignment: 1 + _showBounds: 0 --- !u!212 &21262204 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/IsoTools/Examples/Prefabs/Floor_3x3.prefab b/Assets/IsoTools/Examples/Prefabs/Floor_3x3.prefab index 787a913..8bfc274 100644 --- a/Assets/IsoTools/Examples/Prefabs/Floor_3x3.prefab +++ b/Assets/IsoTools/Examples/Prefabs/Floor_3x3.prefab @@ -42,6 +42,8 @@ MonoBehaviour: m_EditorClassIdentifier: _size: {x: 3, y: 3, z: 0} _position: {x: 0, y: 0, z: 0} + _alignment: 1 + _showBounds: 0 --- !u!212 &21253404 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/IsoTools/Examples/Scenes/Scene5.unity b/Assets/IsoTools/Examples/Scenes/Scene5.unity index 9856638..37fd4db 100644 --- a/Assets/IsoTools/Examples/Scenes/Scene5.unity +++ b/Assets/IsoTools/Examples/Scenes/Scene5.unity @@ -279,11 +279,11 @@ Prefab: m_Modifications: - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.x - value: 0 + value: -3.59999847 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.y - value: 48 + value: 75.8300018 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z @@ -307,19 +307,27 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_RootOrder - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.x - value: 1 + value: .626875162 objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.y - value: 1 + value: .851875067 objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.z - value: 2 + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _alignment + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _showBounds + value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} diff --git a/Assets/IsoTools/Scripts/IsoFakeObject.cs b/Assets/IsoTools/Scripts/IsoFakeObject.cs index caefae3..3b82cae 100644 --- a/Assets/IsoTools/Scripts/IsoFakeObject.cs +++ b/Assets/IsoTools/Scripts/IsoFakeObject.cs @@ -1,5 +1,4 @@ using UnityEngine; -using System.Collections.Generic; namespace IsoTools { public class IsoFakeObject : MonoBehaviour { diff --git a/Assets/IsoTools/Scripts/IsoObject.cs b/Assets/IsoTools/Scripts/IsoObject.cs index 7356070..9b1348d 100644 --- a/Assets/IsoTools/Scripts/IsoObject.cs +++ b/Assets/IsoTools/Scripts/IsoObject.cs @@ -251,6 +251,16 @@ namespace IsoTools { } #if UNITY_EDITOR + void Reset() { + Size = Vector3.one; + Position = Vector3.zero; + } + + void OnValidate() { + Size = _size; + Position = _position; + } + void OnDrawGizmos() { if ( ShowBounds && IsoWorld ) { IsoUtils.DrawCube(IsoWorld, Position + Size * 0.5f, Size, Color.red); diff --git a/Assets/IsoTools/Scripts/IsoWorld.cs b/Assets/IsoTools/Scripts/IsoWorld.cs index c1dd754..44807d8 100644 --- a/Assets/IsoTools/Scripts/IsoWorld.cs +++ b/Assets/IsoTools/Scripts/IsoWorld.cs @@ -39,10 +39,6 @@ namespace IsoTools { } bool _dirty = true; - float _lastTileSize = 0.0f; - float _lastMinDepth = 0.0f; - float _lastMaxDepth = 0.0f; - List _sectors = new List(); List _objects = new List(); List _depends = new List(); @@ -155,10 +151,6 @@ namespace IsoTools { // ------------------------------------------------------------------------ bool IsIsoObjectVisible(IsoObject iso_object) { - var renderer = iso_object.GetComponent(); - if ( renderer && renderer.isVisible ) { - return true; - } var renderers = iso_object.GetComponentsInChildren(); return renderers.Any(r => r.isVisible); } @@ -189,9 +181,6 @@ namespace IsoTools { void ChangeSortingProperty() { MarkDirty(); FixAllTransforms(); - _lastTileSize = TileSize; - _lastMinDepth = MinDepth; - _lastMaxDepth = MaxDepth; } int SectorIndex(Vector3 num_pos) { @@ -386,11 +375,6 @@ namespace IsoTools { } void LateUpdate() { - if ( Application.isEditor ) { - if ( !Mathf.Approximately(_lastTileSize, _tileSize) ) TileSize = _tileSize; - if ( !Mathf.Approximately(_lastMinDepth, _minDepth) ) MinDepth = _minDepth; - if ( !Mathf.Approximately(_lastMaxDepth, _maxDepth) ) MaxDepth = _maxDepth; - } StepSort(); } @@ -401,5 +385,19 @@ namespace IsoTools { void OnDisable() { ResetAllIsoWorld(); } + + #if UNITY_EDITOR + void Reset() { + TileSize = 32.0f; + MinDepth = 0.0f; + MaxDepth = 100.0f; + } + + void OnValidate() { + TileSize = _tileSize; + MinDepth = _minDepth; + MaxDepth = _maxDepth; + } + #endif } } // namespace IsoTools \ No newline at end of file