diff --git a/Assembly-CSharp-Editor-vs.csproj b/Assembly-CSharp-Editor-vs.csproj
index 635ce51..47b0939 100644
--- a/Assembly-CSharp-Editor-vs.csproj
+++ b/Assembly-CSharp-Editor-vs.csproj
@@ -46,6 +46,7 @@
+
/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll
diff --git a/Assembly-CSharp-Editor.csproj b/Assembly-CSharp-Editor.csproj
index 91a83c4..fff4965 100644
--- a/Assembly-CSharp-Editor.csproj
+++ b/Assembly-CSharp-Editor.csproj
@@ -46,6 +46,7 @@
+
/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll
diff --git a/Assets/IsoTools/Editor/IsoAlignmentWindow.cs b/Assets/IsoTools/Editor/IsoAlignmentWindow.cs
new file mode 100644
index 0000000..94bd6ac
--- /dev/null
+++ b/Assets/IsoTools/Editor/IsoAlignmentWindow.cs
@@ -0,0 +1,39 @@
+using UnityEngine;
+using UnityEditor;
+using System.Linq;
+
+namespace IsoTools {
+ public class IsoAlignmentWindow : EditorWindow {
+
+ public static bool Alignment { get; private set; }
+
+ void AlignmentSelection() {
+ var iso_objects = Selection.gameObjects
+ .Where(p => p.GetComponent())
+ .Select(p => p.GetComponent());
+ foreach ( var iso_object in iso_objects ) {
+ iso_object.Position = iso_object.TilePosition;
+ iso_object.FixTransform();
+ }
+ }
+
+ [MenuItem("IsoTools/Alignment")]
+ static void Init() {
+ var window = EditorWindow.GetWindow();
+ window.title = "IsoAlignment";
+ window.Show();
+ }
+
+ static IsoAlignmentWindow() {
+ Alignment = true;
+ }
+
+ void OnGUI() {
+ GUILayout.Space(5);
+ Alignment = EditorGUILayout.Toggle("Auto alignment", Alignment);
+ if ( GUILayout.Button("Alignment selection objects") || Alignment ) {
+ AlignmentSelection();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/IsoTools/Editor/IsoAlignmentWindow.cs.meta b/Assets/IsoTools/Editor/IsoAlignmentWindow.cs.meta
new file mode 100644
index 0000000..8cbd103
--- /dev/null
+++ b/Assets/IsoTools/Editor/IsoAlignmentWindow.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: bc6645583f19a4c99b26459ef98d0d9c
+timeCreated: 1431871954
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/IsoTools/Editor/IsoObjectEditor.cs b/Assets/IsoTools/Editor/IsoObjectEditor.cs
index f19d440..6788aba 100644
--- a/Assets/IsoTools/Editor/IsoObjectEditor.cs
+++ b/Assets/IsoTools/Editor/IsoObjectEditor.cs
@@ -26,6 +26,13 @@ namespace IsoTools {
}) / _positions.Count;
}
+ void AlignmentIsoObject(IsoObject iso_object) {
+ if ( IsoAlignmentWindow.Alignment ) {
+ iso_object.Position = iso_object.TilePosition;
+ iso_object.FixTransform();
+ }
+ }
+
float ZMoveIsoObjects(float delta) {
Undo.RecordObjects(_iso_zpositions.Keys.ToArray(), "Move");
return _iso_zpositions.Aggregate(0.0f, (AccIn, pair) => {
@@ -33,6 +40,7 @@ namespace IsoTools {
var iso_orig_z = pair.Value;
iso_object.PositionZ = iso_orig_z + delta;
iso_object.FixTransform();
+ AlignmentIsoObject(iso_object);
var z_delta = iso_object.Position.z - iso_orig_z;
return Mathf.Abs(z_delta) > Mathf.Abs(AccIn) ? z_delta : AccIn;
});
@@ -45,6 +53,7 @@ namespace IsoTools {
var iso_orig_p = pair.Value;
iso_object.transform.position = iso_orig_p + delta;
iso_object.FixIsoPosition();
+ AlignmentIsoObject(iso_object);
var pos_delta = iso_object.transform.position - iso_orig_p;
return pos_delta.magnitude > AccIn.magnitude ? pos_delta : AccIn;
});
diff --git a/Assets/IsoTools/Scripts/IsoObject.cs b/Assets/IsoTools/Scripts/IsoObject.cs
index 4997960..340f369 100644
--- a/Assets/IsoTools/Scripts/IsoObject.cs
+++ b/Assets/IsoTools/Scripts/IsoObject.cs
@@ -12,8 +12,6 @@ namespace IsoTools {
Vector2 _lastTransform = Vector2.zero;
Vector3 _lastPosition = Vector3.zero;
Vector3 _lastSize = Vector3.zero;
- bool _lastSorting = false;
- bool _lastAlignment = false;
#endif
[SerializeField]
@@ -76,28 +74,6 @@ namespace IsoTools {
}
}
- [SerializeField]
- bool _sorting = true;
- /// Auto sorting tile.
- public bool Sorting {
- get { return _sorting; }
- set {
- _sorting = value;
- FixTransform();
- }
- }
-
- [SerializeField]
- bool _alignment = true;
- /// Auto alignment position by isometric tile size.
- public bool Alignment {
- get { return _alignment; }
- set {
- _alignment = value;
- FixTransform();
- }
- }
-
[SerializeField]
/// Isometric object tile position.
public Vector3 TilePosition {
@@ -128,9 +104,6 @@ namespace IsoTools {
}
public void FixTransform() {
- if ( Application.isEditor && Alignment ) {
- _position = TilePosition;
- }
Vector3 trans = IsoWorld.IsoToScreen(Position);
trans.z = transform.position.z;
transform.position = trans;
@@ -149,8 +122,6 @@ namespace IsoTools {
_lastTransform = transform.position;
_lastPosition = Position;
_lastSize = Size;
- _lastSorting = Sorting;
- _lastAlignment = Alignment;
#endif
}
@@ -187,10 +158,8 @@ namespace IsoTools {
{
FixIsoPosition();
}
- if ( _lastPosition != _position ) Position = _position;
- if ( _lastSize != _size ) Size = _size;
- if ( _lastSorting != _sorting ) Sorting = _sorting;
- if ( _lastAlignment != _alignment ) Alignment = _alignment;
+ if ( _lastPosition != _position ) Position = _position;
+ if ( _lastSize != _size ) Size = _size;
}
}
#endif
diff --git a/Assets/IsoTools/Scripts/IsoWorld.cs b/Assets/IsoTools/Scripts/IsoWorld.cs
index 8f9492b..954353a 100644
--- a/Assets/IsoTools/Scripts/IsoWorld.cs
+++ b/Assets/IsoTools/Scripts/IsoWorld.cs
@@ -102,7 +102,7 @@ namespace IsoTools {
/// Isometric object for resorting.
// ------------------------------------------------------------------------
public void MarkDirty(IsoObject obj) {
- if ( obj && obj.Sorting ) {
+ if ( obj ) {
var renderer = obj.GetComponent();
if ( renderer && renderer.isVisible ) {
MarkDirty();
diff --git a/UnityIso-csharp.sln b/UnityIso-csharp.sln
index 4aad93e..9049961 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 109b609..d158333 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 2d76864..c63945d 100644
--- a/UnityIso.userprefs
+++ b/UnityIso.userprefs
@@ -1,8 +1,8 @@
-
-
+
+
-
+