diff --git a/Assets/IsoTools/Editor/IsoObjectEditor.cs b/Assets/IsoTools/Editor/IsoObjectEditor.cs index 50cec7a..f19d440 100644 --- a/Assets/IsoTools/Editor/IsoObjectEditor.cs +++ b/Assets/IsoTools/Editor/IsoObjectEditor.cs @@ -25,18 +25,6 @@ namespace IsoTools { return AccIn + p.Value; }) / _positions.Count; } - - Vector3 XYMoveIsoObjects(Vector3 delta) { - Undo.RecordObjects(_positions.Keys.ToArray(), "Move"); - return _positions.Aggregate(Vector3.zero, (AccIn, pair) => { - var iso_object = pair.Key; - var iso_orig_pos = pair.Value; - iso_object.transform.position = iso_orig_pos + delta; - iso_object.FixIsoPosition(); - var pos_delta = iso_object.transform.position - iso_orig_pos; - return pos_delta.magnitude > AccIn.magnitude ? pos_delta : AccIn; - }); - } float ZMoveIsoObjects(float delta) { Undo.RecordObjects(_iso_zpositions.Keys.ToArray(), "Move"); @@ -50,6 +38,41 @@ namespace IsoTools { }); } + Vector3 XYMoveIsoObjects(Vector3 delta) { + Undo.RecordObjects(_positions.Keys.ToArray(), "Move"); + return _positions.Aggregate(Vector3.zero, (AccIn, pair) => { + var iso_object = pair.Key; + var iso_orig_p = pair.Value; + iso_object.transform.position = iso_orig_p + delta; + iso_object.FixIsoPosition(); + var pos_delta = iso_object.transform.position - iso_orig_p; + return pos_delta.magnitude > AccIn.magnitude ? pos_delta : AccIn; + }); + } + + void ZMoveSlider() { + var iso_world = GameObject.FindObjectOfType(); + if ( iso_world ) { + Handles.color = Handles.zAxisColor; + var delta = Handles.Slider(_viewCenter, IsoUtils.Vec3OneY) - _viewCenter; + if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) { + float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.TileSize); + _viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.TileSize); + } + } + } + + void XYMoveSlider(Color color, Vector3 dir) { + var iso_world = GameObject.FindObjectOfType(); + if ( iso_world ) { + Handles.color = color; + var delta = Handles.Slider(_viewCenter, iso_world.IsoToScreen(dir)) - _viewCenter; + if ( delta.magnitude > Mathf.Epsilon ) { + _viewCenter = _center + XYMoveIsoObjects(_viewCenter - _center + delta); + } + } + } + void XYMoveRectangle() { Handles.color = IsoUtils.ColorChangeA(Handles.zAxisColor, 0.3f); Handles.DotCap( @@ -75,20 +98,7 @@ namespace IsoTools { } } - void ZMoveSlider() { - var iso_world = GameObject.FindObjectOfType(); - if ( iso_world ) { - Handles.color = Handles.yAxisColor; - var delta = Handles.Slider(_viewCenter, IsoUtils.Vec3OneY) - _viewCenter; - if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) { - float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.TileSize); - _viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.TileSize); - } - } - } - void OnEnable() { - Tools.hidden = true; GrabPositions(); } @@ -97,8 +107,15 @@ namespace IsoTools { } void OnSceneGUI() { - ZMoveSlider(); - XYMoveRectangle(); + if ( Tools.current == Tool.Move ) { + Tools.hidden = true; + ZMoveSlider(); + XYMoveSlider(Handles.xAxisColor, IsoUtils.Vec3OneX); + XYMoveSlider(Handles.yAxisColor, IsoUtils.Vec3OneY); + XYMoveRectangle(); + } else { + Tools.hidden = false; + } } public override void OnInspectorGUI() { diff --git a/Assets/IsoTools/Examples/Scenes/Scene5.unity b/Assets/IsoTools/Examples/Scenes/Scene5.unity index 243ed60..195720d 100644 --- a/Assets/IsoTools/Examples/Scenes/Scene5.unity +++ b/Assets/IsoTools/Examples/Scenes/Scene5.unity @@ -87,6 +87,64 @@ NavMeshSettings: cellSize: .166666672 manualCellSize: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &274776129 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.y + value: 16 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.z + value: 14.2857141 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: _position.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 153404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_Name + value: Floor_3x4 + objectReference: {fileID: 0} + - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: _position.z + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + m_IsPrefabParent: 0 --- !u!1 &318480492 GameObject: m_ObjectHideFlags: 0 @@ -171,7 +229,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 7 --- !u!114 &318480498 MonoBehaviour: m_ObjectHideFlags: 0 @@ -183,7 +241,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3f01619d3802e814f86f9e6bb965349a, type: 3} m_Name: m_EditorClassIdentifier: - _tileType: 0 _tileSize: 16 _minDepth: 0 _maxDepth: 100 @@ -196,15 +253,15 @@ Prefab: m_Modifications: - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.x - value: -16 + value: -32 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.y - value: 24 + value: 16 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z - value: 20 + value: 57.1428566 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalRotation.x @@ -224,11 +281,11 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_RootOrder - value: 1 + value: 4 objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.x - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.y @@ -250,118 +307,6 @@ Prefab: m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} m_IsPrefabParent: 0 --- !u!1001 &409886624 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.y - value: 16 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_RootOrder - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _alignment - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_Name - value: Cube_1x1x4 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &940832437 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalPosition.z - value: 80 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: m_RootOrder - value: 4 - objectReference: {fileID: 0} - - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: _position.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - propertyPath: _position.y - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &1454547313 Prefab: m_ObjectHideFlags: 0 serializedVersion: 2 @@ -378,53 +323,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalPosition.z - value: 60 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_Name - value: Cube_1x1x2 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - m_IsPrefabParent: 0 ---- !u!1001 &1818595414 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.x - value: 16 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.y - value: 24 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.z - value: 40 + value: 71.4285736 objectReference: {fileID: 0} - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: m_LocalRotation.x @@ -452,8 +351,186 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _position.y + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _alignment value: 1 objectReference: {fileID: 0} + - target: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_Name + value: Cube_1x1x4 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1197576131 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.y + value: 16 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_Name + value: Cube_1x1x5 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.z + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1454547313 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.z + value: 28.5714283 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_RootOrder + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_Name + value: Cube_1x1x2 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_IsPrefabParent: 0 +--- !u!1001 &1818595414 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.x + value: 32 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.y + value: 16 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalPosition.z + value: 42.8571434 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} propertyPath: _alignment value: 1 @@ -465,3 +542,53 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} m_IsPrefabParent: 0 +--- !u!1001 &2146784705 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalPosition.z + value: 85.7142868 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: _position.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + propertyPath: _position.y + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} + m_IsPrefabParent: 0 diff --git a/Assets/IsoTools/Scripts/IsoWorld.cs b/Assets/IsoTools/Scripts/IsoWorld.cs index 02d6489..8f9492b 100644 --- a/Assets/IsoTools/Scripts/IsoWorld.cs +++ b/Assets/IsoTools/Scripts/IsoWorld.cs @@ -9,12 +9,6 @@ using UnityEditor; namespace IsoTools { [ExecuteInEditMode] public class IsoWorld : MonoBehaviour { - - /// World tile types. - public enum TileTypes { - Isometric, - UpDown - } class ObjectInfo { public int Index; @@ -54,22 +48,10 @@ namespace IsoTools { Vector3 _objsMaxNumPos = Vector3.zero; Vector3 _objsNumPosCount = Vector3.zero; - TileTypes _lastTileType = TileTypes.Isometric; float _lastTileSize = 0.0f; float _lastMinDepth = 0.0f; float _lastMaxDepth = 0.0f; - [SerializeField] - public TileTypes _tileType = TileTypes.Isometric; - /// World tile type. - public TileTypes TileType { - get { return _tileType; } - set { - _tileType = value; - ChangeSortingProperty(); - } - } - [SerializeField] public float _tileSize = 32.0f; /// Isometric tile size. @@ -136,18 +118,9 @@ namespace IsoTools { /// Isometric coordinates. // ------------------------------------------------------------------------ public Vector2 IsoToScreen(Vector3 pos) { - switch ( TileType ) { - case TileTypes.Isometric: - return new Vector2( - (pos.x - pos.y), - (pos.x + pos.y) * 0.5f + pos.z) * TileSize; - case TileTypes.UpDown: - return new Vector2( - pos.x, - pos.y + pos.z) * TileSize; - default: - throw new UnityException("IsoWorld. TileType is wrong!"); - } + return new Vector2( + (pos.x - pos.y), + (pos.x + pos.y) * 0.5f + pos.z) * TileSize; } // ------------------------------------------------------------------------ @@ -158,20 +131,10 @@ namespace IsoTools { /// Screen coordinates. // ------------------------------------------------------------------------ public Vector3 ScreenToIso(Vector2 pos) { - switch ( TileType ) { - case TileTypes.Isometric: - return new Vector3( - (pos.x * 0.5f + pos.y), - (pos.y - pos.x * 0.5f), - 0.0f) / TileSize; - case TileTypes.UpDown: - return new Vector3( - pos.x, - pos.y, - 0.0f) / TileSize; - default: - throw new UnityException("IsoWorld. TileType is wrong!"); - } + return new Vector3( + (pos.x * 0.5f + pos.y), + (pos.y - pos.x * 0.5f), + 0.0f) / TileSize; } // ------------------------------------------------------------------------ @@ -183,20 +146,9 @@ namespace IsoTools { /// Point isometric height. // ------------------------------------------------------------------------ public Vector3 ScreenToIso(Vector2 pos, float iso_z) { - switch ( TileType ) { - case TileTypes.Isometric: { - var iso_pos = ScreenToIso(new Vector2(pos.x, pos.y - iso_z * TileSize)); - iso_pos.z = iso_z; - return iso_pos; - } - case TileTypes.UpDown: { - var iso_pos = ScreenToIso(new Vector2(pos.x, pos.y - iso_z * TileSize)); - iso_pos.z = iso_z; - return iso_pos; - } - default: - throw new UnityException("IsoWorld. TileType is wrong!"); - } + var iso_pos = ScreenToIso(new Vector2(pos.x, pos.y - iso_z * TileSize)); + iso_pos.z = iso_z; + return iso_pos; } void MarkEditorWorldDirty() { @@ -221,7 +173,6 @@ namespace IsoTools { void ChangeSortingProperty() { MarkDirty(); FixAllTransforms(); - _lastTileType = TileType; _lastTileSize = TileSize; _lastMinDepth = MinDepth; _lastMaxDepth = MaxDepth; @@ -403,10 +354,9 @@ namespace IsoTools { void LateUpdate() { if ( Application.isEditor ) { - if ( _lastTileType != _tileType ) TileType = _tileType; - if ( !Mathf.Approximately(_lastTileSize, _tileSize ) ) TileSize = _tileSize; - if ( !Mathf.Approximately(_lastMinDepth, _minDepth ) ) MinDepth = _minDepth; - if ( !Mathf.Approximately(_lastMaxDepth, _maxDepth ) ) MaxDepth = _maxDepth; + if ( !Mathf.Approximately(_lastTileSize, _tileSize) ) TileSize = _tileSize; + if ( !Mathf.Approximately(_lastMinDepth, _minDepth) ) MinDepth = _minDepth; + if ( !Mathf.Approximately(_lastMaxDepth, _maxDepth) ) MaxDepth = _maxDepth; } StepSort(); } diff --git a/UnityIso-csharp.sln b/UnityIso-csharp.sln index 19e353f..4aad93e 100644 --- a/UnityIso-csharp.sln +++ b/UnityIso-csharp.sln @@ -23,7 +23,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution + GlobalSection(MonoDevelopProperties) = preSolution StartupItem = Assembly-CSharp.csproj Policies = $0 $0.TextStylePolicy = $1 diff --git a/UnityIso.sln b/UnityIso.sln index 6725127..109b609 100644 --- a/UnityIso.sln +++ b/UnityIso.sln @@ -23,7 +23,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution + GlobalSection(MonoDevelopProperties) = preSolution StartupItem = Assembly-CSharp.csproj Policies = $0 $0.TextStylePolicy = $1 diff --git a/UnityIso.userprefs b/UnityIso.userprefs index 687c3df..2d76864 100644 --- a/UnityIso.userprefs +++ b/UnityIso.userprefs @@ -1,11 +1,8 @@  - + - - - - +