mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
+ IsoSnappingParent
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Assets\IsoTools\Scripts\Internal\Editor\IsoObjectEditor.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\Internal\Editor\IsoObjectEditor.cs" />
|
||||||
|
<Compile Include="Assets\IsoTools\Scripts\Internal\Editor\IsoSnappingParentEditor.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapAssetEditor.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapAssetEditor.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapAssetPostprocessor.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapAssetPostprocessor.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapEditor.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\Internal\Editor\TiledMapEditor.cs" />
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoRaycastHit.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoRaycastHit.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoRigidbody.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoRigidbody.cs" />
|
||||||
|
<Compile Include="Assets\IsoTools\Scripts\IsoSnappingParent.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoSphereCollider.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoSphereCollider.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoTriggerListener.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoTriggerListener.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Scripts\IsoWorld.cs" />
|
<Compile Include="Assets\IsoTools\Scripts\IsoWorld.cs" />
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ namespace IsoTools.Internal {
|
|||||||
Vector3 _center = Vector3.zero;
|
Vector3 _center = Vector3.zero;
|
||||||
Vector3 _viewCenter = Vector3.zero;
|
Vector3 _viewCenter = Vector3.zero;
|
||||||
|
|
||||||
static public readonly float SnappingDistance = 0.2f;
|
static public readonly float SnappingDistance = 0.2f;
|
||||||
static public readonly int FloatBeautifierDigits = 4;
|
|
||||||
|
|
||||||
static bool IsSnappingEnabled() {
|
static bool IsSnappingEnabled() {
|
||||||
return !Event.current.control;
|
return !Event.current.control;
|
||||||
@@ -34,12 +33,12 @@ namespace IsoTools.Internal {
|
|||||||
_center = _viewCenter = _positions.Aggregate(Vector3.zero, (AccIn, p) => {
|
_center = _viewCenter = _positions.Aggregate(Vector3.zero, (AccIn, p) => {
|
||||||
return AccIn + IsoUtils.Vec3FromVec2(iso_world.IsoToScreen(p.Key.position + p.Key.size * 0.5f));
|
return AccIn + IsoUtils.Vec3FromVec2(iso_world.IsoToScreen(p.Key.position + p.Key.size * 0.5f));
|
||||||
}) / _positions.Count;
|
}) / _positions.Count;
|
||||||
|
} else {
|
||||||
|
_positions.Clear();
|
||||||
|
_isoZPositions.Clear();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void GrabOtherIsoObjects() {
|
|
||||||
_otherObjects = FindObjectsOfType<IsoObject>()
|
_otherObjects = FindObjectsOfType<IsoObject>()
|
||||||
.Where(p => p.gameObject.activeInHierarchy && !targets.Contains(p))
|
.Where(p => p.gameObject.activeInHierarchy && !_positions.ContainsKey(p))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,17 +57,7 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float FloatBeautifier(float v) {
|
static bool SnappingProcess(ref float min_a, float size_a, float min_b, float size_b) {
|
||||||
return (float)System.Math.Round(v, FloatBeautifierDigits);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2Beautifier(Vector2 v) {
|
|
||||||
v.x = FloatBeautifier(v.x);
|
|
||||||
v.y = FloatBeautifier(v.y);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SnappingProcess(ref float min_a, float size_a, float min_b, float size_b) {
|
|
||||||
var max_a = min_a + size_a;
|
var max_a = min_a + size_a;
|
||||||
var max_b = min_b + size_b;
|
var max_b = min_b + size_b;
|
||||||
var result = false;
|
var result = false;
|
||||||
@@ -99,23 +88,30 @@ namespace IsoTools.Internal {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSnappingIntersect(float min_a, float size_a, float min_b, float size_b) {
|
static bool IsSnappingIntersect(float min_a, float size_a, float min_b, float size_b) {
|
||||||
return
|
return
|
||||||
min_a + size_a + SnappingDistance >= min_b &&
|
min_a + size_a + SnappingDistance >= min_b &&
|
||||||
min_a - SnappingDistance <= min_b + size_b;
|
min_a - SnappingDistance <= min_b + size_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ZMoveIsoObjects(float delta) {
|
public static float ZMoveIsoObjects(
|
||||||
Undo.RecordObjects(
|
bool move,
|
||||||
_isoZPositions.Keys.ToArray(),
|
float delta,
|
||||||
_isoZPositions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
IDictionary<IsoObject, float> iso_z_positions,
|
||||||
|
IList<IsoObject> other_objects)
|
||||||
|
{
|
||||||
|
if ( move ) {
|
||||||
|
Undo.RecordObjects(
|
||||||
|
iso_z_positions.Keys.ToArray(),
|
||||||
|
iso_z_positions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
||||||
|
}
|
||||||
if ( IsSnappingEnabled() ) {
|
if ( IsSnappingEnabled() ) {
|
||||||
var snapping_z = false;
|
var snapping_z = false;
|
||||||
foreach ( var pair in _isoZPositions ) {
|
foreach ( var pair in iso_z_positions ) {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_z = pair.Value;
|
var iso_orig_z = pair.Value;
|
||||||
var result_p_z = iso_orig_z + delta;
|
var result_p_z = iso_orig_z + delta;
|
||||||
foreach ( var other in _otherObjects ) {
|
foreach ( var other in other_objects ) {
|
||||||
if ( IsSnappingIntersect(iso_object.positionX, iso_object.sizeX, other.positionX, other.sizeX) &&
|
if ( IsSnappingIntersect(iso_object.positionX, iso_object.sizeX, other.positionX, other.sizeX) &&
|
||||||
IsSnappingIntersect(iso_object.positionY, iso_object.sizeY, other.positionY, other.sizeY) )
|
IsSnappingIntersect(iso_object.positionY, iso_object.sizeY, other.positionY, other.sizeY) )
|
||||||
{
|
{
|
||||||
@@ -133,7 +129,7 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !snapping_z ) {
|
if ( !snapping_z ) {
|
||||||
var pair = _isoZPositions.First();
|
var pair = iso_z_positions.First();
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_z = pair.Value;
|
var iso_orig_z = pair.Value;
|
||||||
var result_p_z = iso_orig_z + delta;
|
var result_p_z = iso_orig_z + delta;
|
||||||
@@ -144,29 +140,38 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _isoZPositions.Aggregate(0.0f, (AccIn, pair) => {
|
return iso_z_positions.Aggregate(0.0f, (AccIn, pair) => {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_z = pair.Value;
|
var iso_orig_z = pair.Value;
|
||||||
var result_p_z = iso_orig_z + delta;
|
var result_p_z = iso_orig_z + delta;
|
||||||
iso_object.positionZ = FloatBeautifier(result_p_z);
|
if ( move ) {
|
||||||
var z_delta = iso_object.position.z - iso_orig_z;
|
iso_object.positionZ = IsoUtils.FloatBeautifier(result_p_z);
|
||||||
|
}
|
||||||
|
var z_delta = result_p_z - iso_orig_z;
|
||||||
return Mathf.Abs(z_delta) > Mathf.Abs(AccIn) ? z_delta : AccIn;
|
return Mathf.Abs(z_delta) > Mathf.Abs(AccIn) ? z_delta : AccIn;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 XYMoveIsoObjects(Vector3 delta) {
|
public static Vector3 XYMoveIsoObjects(
|
||||||
Undo.RecordObjects(
|
bool move,
|
||||||
_positions.Keys.ToArray(),
|
Vector3 delta,
|
||||||
_positions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
IDictionary<IsoObject, Vector3> positions,
|
||||||
|
IList<IsoObject> other_objects)
|
||||||
|
{
|
||||||
|
if ( move ) {
|
||||||
|
Undo.RecordObjects(
|
||||||
|
positions.Keys.ToArray(),
|
||||||
|
positions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
||||||
|
}
|
||||||
if ( IsSnappingEnabled() ) {
|
if ( IsSnappingEnabled() ) {
|
||||||
var snapping_x = false;
|
var snapping_x = false;
|
||||||
var snapping_y = false;
|
var snapping_y = false;
|
||||||
foreach ( var pair in _positions ) {
|
foreach ( var pair in positions ) {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_p = pair.Value;
|
var iso_orig_p = pair.Value;
|
||||||
var result_pos = iso_orig_p + delta;
|
var result_pos = iso_orig_p + delta;
|
||||||
var result_pos_iso = IsoWorld.Instance.ScreenToIso(result_pos, iso_object.positionZ);
|
var result_pos_iso = IsoWorld.Instance.ScreenToIso(result_pos, iso_object.positionZ);
|
||||||
foreach ( var other in _otherObjects ) {
|
foreach ( var other in other_objects ) {
|
||||||
if ( IsSnappingIntersect(iso_object.positionZ, iso_object.sizeZ, other.positionZ, other.sizeZ) ) {
|
if ( IsSnappingIntersect(iso_object.positionZ, iso_object.sizeZ, other.positionZ, other.sizeZ) ) {
|
||||||
var new_snapping_x = !snapping_x && IsSnappingIntersect(result_pos_iso.y, iso_object.sizeY, other.positionY, other.sizeY)
|
var new_snapping_x = !snapping_x && IsSnappingIntersect(result_pos_iso.y, iso_object.sizeY, other.positionY, other.sizeY)
|
||||||
? SnappingProcess(ref result_pos_iso.x, iso_object.sizeX, other.positionX, other.sizeX)
|
? SnappingProcess(ref result_pos_iso.x, iso_object.sizeX, other.positionX, other.sizeX)
|
||||||
@@ -194,7 +199,7 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !snapping_x && !snapping_y ) {
|
if ( !snapping_x && !snapping_y ) {
|
||||||
var pair = _positions.First();
|
var pair = positions.First();
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_p = pair.Value;
|
var iso_orig_p = pair.Value;
|
||||||
var result_pos = iso_orig_p + delta;
|
var result_pos = iso_orig_p + delta;
|
||||||
@@ -216,14 +221,17 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _positions.Aggregate(Vector3.zero, (AccIn, pair) => {
|
return positions.Aggregate(Vector3.zero, (AccIn, pair) => {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
var iso_orig_p = pair.Value;
|
var iso_orig_p = pair.Value;
|
||||||
var result_pos = iso_orig_p + delta;
|
var result_pos = iso_orig_p + delta;
|
||||||
iso_object.transform.position = result_pos;
|
if ( move ) {
|
||||||
iso_object.FixIsoPosition();
|
var new_iso_pos = IsoWorld.Instance.ScreenToIso(
|
||||||
iso_object.positionXY = Vector2Beautifier(iso_object.positionXY);
|
result_pos,
|
||||||
var pos_delta = iso_object.transform.position - iso_orig_p;
|
iso_object.positionZ);
|
||||||
|
iso_object.position = IsoUtils.VectorBeautifier(new_iso_pos);
|
||||||
|
}
|
||||||
|
var pos_delta = result_pos - iso_orig_p;
|
||||||
return pos_delta.magnitude > AccIn.magnitude ? pos_delta : AccIn;
|
return pos_delta.magnitude > AccIn.magnitude ? pos_delta : AccIn;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -234,7 +242,11 @@ namespace IsoTools.Internal {
|
|||||||
Handles.color = Handles.zAxisColor;
|
Handles.color = Handles.zAxisColor;
|
||||||
var delta = Handles.Slider(_viewCenter, IsoUtils.vec3OneY) - _viewCenter;
|
var delta = Handles.Slider(_viewCenter, IsoUtils.vec3OneY) - _viewCenter;
|
||||||
if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) {
|
if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) {
|
||||||
float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.tileHeight);
|
float tmp_y = ZMoveIsoObjects(
|
||||||
|
true,
|
||||||
|
(_viewCenter.y - _center.y + delta.y) / iso_world.tileHeight,
|
||||||
|
_isoZPositions,
|
||||||
|
_otherObjects);
|
||||||
_viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.tileHeight);
|
_viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.tileHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +258,11 @@ namespace IsoTools.Internal {
|
|||||||
Handles.color = color;
|
Handles.color = color;
|
||||||
var delta = Handles.Slider(_viewCenter, iso_world.IsoToScreen(dir)) - _viewCenter;
|
var delta = Handles.Slider(_viewCenter, iso_world.IsoToScreen(dir)) - _viewCenter;
|
||||||
if ( delta.magnitude > Mathf.Epsilon ) {
|
if ( delta.magnitude > Mathf.Epsilon ) {
|
||||||
_viewCenter = _center + XYMoveIsoObjects(_viewCenter - _center + delta);
|
_viewCenter = _center + XYMoveIsoObjects(
|
||||||
|
true,
|
||||||
|
_viewCenter - _center + delta,
|
||||||
|
_positions,
|
||||||
|
_otherObjects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,13 +292,20 @@ namespace IsoTools.Internal {
|
|||||||
Vector3.zero,
|
Vector3.zero,
|
||||||
Handles.RectangleCap) - _viewCenter;
|
Handles.RectangleCap) - _viewCenter;
|
||||||
if ( delta.magnitude > Mathf.Epsilon ) {
|
if ( delta.magnitude > Mathf.Epsilon ) {
|
||||||
_viewCenter = _center + XYMoveIsoObjects(_viewCenter - _center + delta);
|
_viewCenter = _center + XYMoveIsoObjects(
|
||||||
|
true,
|
||||||
|
_viewCenter - _center + delta,
|
||||||
|
_positions,
|
||||||
|
_otherObjects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
GrabPositions();
|
GrabPositions();
|
||||||
GrabOtherIsoObjects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable() {
|
void OnDisable() {
|
||||||
@@ -307,8 +330,7 @@ namespace IsoTools.Internal {
|
|||||||
public override void OnInspectorGUI() {
|
public override void OnInspectorGUI() {
|
||||||
DrawDefaultInspector();
|
DrawDefaultInspector();
|
||||||
GrabPositions();
|
GrabPositions();
|
||||||
GrabOtherIsoObjects();
|
|
||||||
DirtyTargetPosition();
|
DirtyTargetPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace IsoTools.Internal {
|
||||||
|
[CustomEditor(typeof(IsoSnappingParent)), CanEditMultipleObjects]
|
||||||
|
public class IsoSnappingParentEditor : Editor {
|
||||||
|
|
||||||
|
IDictionary<IsoSnappingParent, Vector3> _parents = new Dictionary<IsoSnappingParent, Vector3>();
|
||||||
|
IDictionary<IsoObject, Vector3> _positions = new Dictionary<IsoObject, Vector3>();
|
||||||
|
IList<IsoObject> _otherObjects = new List<IsoObject>();
|
||||||
|
Vector3 _center = Vector3.zero;
|
||||||
|
Vector3 _viewCenter = Vector3.zero;
|
||||||
|
|
||||||
|
void GrabPositions() {
|
||||||
|
var iso_world = IsoWorld.Instance;
|
||||||
|
if ( iso_world ) {
|
||||||
|
_parents = targets
|
||||||
|
.Where(p => p is IsoSnappingParent)
|
||||||
|
.Select(p => p as IsoSnappingParent)
|
||||||
|
.ToDictionary(p => p, p => p.transform.position);
|
||||||
|
foreach ( var parent in _parents ) {
|
||||||
|
var iso_objects = parent.Key.GetComponentsInChildren<IsoObject>(true);
|
||||||
|
foreach ( var iso_object in iso_objects ) {
|
||||||
|
_positions[iso_object] = iso_object.transform.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_center = _viewCenter = _parents.Aggregate(Vector3.zero, (AccIn, p) => {
|
||||||
|
return AccIn + p.Key.transform.position;
|
||||||
|
}) / _parents.Count;
|
||||||
|
} else {
|
||||||
|
_parents.Clear();
|
||||||
|
_positions.Clear();
|
||||||
|
}
|
||||||
|
_otherObjects = FindObjectsOfType<IsoObject>()
|
||||||
|
.Where(p => p.gameObject.activeInHierarchy && !_positions.ContainsKey(p))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void XYMoveSlider(Color color, Vector3 dir) {
|
||||||
|
var iso_world = IsoWorld.Instance;
|
||||||
|
if ( iso_world ) {
|
||||||
|
Handles.color = color;
|
||||||
|
var delta = Handles.Slider(_viewCenter, iso_world.IsoToScreen(dir)) - _viewCenter;
|
||||||
|
if ( delta.magnitude > Mathf.Epsilon ) {
|
||||||
|
Undo.RecordObjects(
|
||||||
|
_parents.Select(p => p.Key.transform).ToArray(),
|
||||||
|
_parents.Count > 1 ? "Move IsoSnappingParents" : "Move IsoSnappingParent");
|
||||||
|
_viewCenter = _center + IsoObjectEditor.XYMoveIsoObjects(
|
||||||
|
false,
|
||||||
|
_viewCenter - _center + delta,
|
||||||
|
_positions,
|
||||||
|
_otherObjects);
|
||||||
|
foreach ( var parent in _parents ) {
|
||||||
|
parent.Key.transform.position = parent.Value + (_viewCenter - _center);
|
||||||
|
}
|
||||||
|
foreach ( var pos in _positions ) {
|
||||||
|
pos.Key.FixIsoPosition();
|
||||||
|
pos.Key.positionXY = IsoUtils.VectorBeautifier(pos.Key.positionXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XYMoveRectangle() {
|
||||||
|
Handles.color = new Color(
|
||||||
|
Handles.zAxisColor.r,
|
||||||
|
Handles.zAxisColor.g,
|
||||||
|
Handles.zAxisColor.b,
|
||||||
|
0.3f);
|
||||||
|
Handles.DotCap(
|
||||||
|
0,
|
||||||
|
_viewCenter,
|
||||||
|
Quaternion.identity,
|
||||||
|
HandleUtility.GetHandleSize(_viewCenter) * 0.15f);
|
||||||
|
Handles.color = Handles.zAxisColor;
|
||||||
|
Handles.ArrowCap(
|
||||||
|
0,
|
||||||
|
_viewCenter,
|
||||||
|
Quaternion.identity,
|
||||||
|
HandleUtility.GetHandleSize(_viewCenter));
|
||||||
|
Handles.color = Handles.zAxisColor;
|
||||||
|
var delta = Handles.FreeMoveHandle(
|
||||||
|
_viewCenter,
|
||||||
|
Quaternion.identity,
|
||||||
|
HandleUtility.GetHandleSize(_viewCenter) * 0.15f,
|
||||||
|
Vector3.zero,
|
||||||
|
Handles.RectangleCap) - _viewCenter;
|
||||||
|
if ( delta.magnitude > Mathf.Epsilon ) {
|
||||||
|
Undo.RecordObjects(
|
||||||
|
_parents.Select(p => p.Key.transform).ToArray(),
|
||||||
|
_parents.Count > 1 ? "Move IsoSnappingParents" : "Move IsoSnappingParent");
|
||||||
|
_viewCenter = _center + IsoObjectEditor.XYMoveIsoObjects(
|
||||||
|
false,
|
||||||
|
_viewCenter - _center + delta,
|
||||||
|
_positions,
|
||||||
|
_otherObjects);
|
||||||
|
foreach ( var parent in _parents ) {
|
||||||
|
parent.Key.transform.position = parent.Value + (_viewCenter - _center);
|
||||||
|
}
|
||||||
|
foreach ( var pos in _positions ) {
|
||||||
|
pos.Key.FixIsoPosition();
|
||||||
|
pos.Key.positionXY = IsoUtils.VectorBeautifier(pos.Key.positionXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
void OnEnable() {
|
||||||
|
GrabPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable() {
|
||||||
|
if ( Tools.hidden ) {
|
||||||
|
Tools.hidden = false;
|
||||||
|
Tools.current = Tool.Move;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnSceneGUI() {
|
||||||
|
if ( Tools.current == Tool.Move ) {
|
||||||
|
Tools.hidden = true;
|
||||||
|
XYMoveSlider(Handles.xAxisColor, IsoUtils.vec3OneX);
|
||||||
|
XYMoveSlider(Handles.yAxisColor, IsoUtils.vec3OneY);
|
||||||
|
XYMoveRectangle();
|
||||||
|
} else {
|
||||||
|
Tools.hidden = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI() {
|
||||||
|
DrawDefaultInspector();
|
||||||
|
GrabPositions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eded9573ac09b4e1492ac1553b9c1b60
|
||||||
|
timeCreated: 1471590629
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -24,6 +24,8 @@ namespace IsoTools.Internal {
|
|||||||
public static Vector3 vec3OneYZ { get { return new Vector3(0.0f, 1.0f, 1.0f); } }
|
public static Vector3 vec3OneYZ { get { return new Vector3(0.0f, 1.0f, 1.0f); } }
|
||||||
public static Vector3 vec3OneXZ { get { return new Vector3(1.0f, 0.0f, 1.0f); } }
|
public static Vector3 vec3OneXZ { get { return new Vector3(1.0f, 0.0f, 1.0f); } }
|
||||||
|
|
||||||
|
static public readonly int FloatBeautifierDigits = 4;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// MinMax
|
// MinMax
|
||||||
@@ -436,6 +438,29 @@ namespace IsoTools.Internal {
|
|||||||
return a == b;
|
return a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Beautifiers
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
public static float FloatBeautifier(float v) {
|
||||||
|
return (float)System.Math.Round(v, FloatBeautifierDigits);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2 VectorBeautifier(Vector2 v) {
|
||||||
|
return new Vector2{
|
||||||
|
x = FloatBeautifier(v.x),
|
||||||
|
y = FloatBeautifier(v.y)};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3 VectorBeautifier(Vector3 v) {
|
||||||
|
return new Vector3{
|
||||||
|
x = FloatBeautifier(v.x),
|
||||||
|
y = FloatBeautifier(v.y),
|
||||||
|
z = FloatBeautifier(v.z)};
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|||||||
8
Assets/IsoTools/Scripts/IsoSnappingParent.cs
Normal file
8
Assets/IsoTools/Scripts/IsoSnappingParent.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace IsoTools {
|
||||||
|
[SelectionBase]
|
||||||
|
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||||
|
public class IsoSnappingParent : MonoBehaviour {
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/IsoTools/Scripts/IsoSnappingParent.cs.meta
Normal file
12
Assets/IsoTools/Scripts/IsoSnappingParent.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f1e3b581728784cafa59b549fe35214b
|
||||||
|
timeCreated: 1471590321
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -117,6 +117,8 @@ PlayerSettings:
|
|||||||
m_Bits: 238
|
m_Bits: 238
|
||||||
iPhoneSdkVersion: 988
|
iPhoneSdkVersion: 988
|
||||||
iPhoneTargetOSVersion: 22
|
iPhoneTargetOSVersion: 22
|
||||||
|
tvOSSdkVersion: 0
|
||||||
|
tvOSTargetOSVersion: 900
|
||||||
uIPrerenderedIcon: 0
|
uIPrerenderedIcon: 0
|
||||||
uIRequiresPersistentWiFi: 0
|
uIRequiresPersistentWiFi: 0
|
||||||
uIRequiresFullScreen: 1
|
uIRequiresFullScreen: 1
|
||||||
@@ -196,6 +198,7 @@ PlayerSettings:
|
|||||||
wiiUSystemHeapSize: 128
|
wiiUSystemHeapSize: 128
|
||||||
wiiUTVStartupScreen: {fileID: 0}
|
wiiUTVStartupScreen: {fileID: 0}
|
||||||
wiiUGamePadStartupScreen: {fileID: 0}
|
wiiUGamePadStartupScreen: {fileID: 0}
|
||||||
|
wiiUDrcBufferDisabled: 0
|
||||||
wiiUProfilerLibPath:
|
wiiUProfilerLibPath:
|
||||||
actionOnDotNetUnhandledException: 1
|
actionOnDotNetUnhandledException: 1
|
||||||
enableInternalProfiler: 0
|
enableInternalProfiler: 0
|
||||||
@@ -263,6 +266,7 @@ PlayerSettings:
|
|||||||
ps4DownloadDataSize: 0
|
ps4DownloadDataSize: 0
|
||||||
ps4GarlicHeapSize: 2048
|
ps4GarlicHeapSize: 2048
|
||||||
ps4Passcode: KgSnOxla5PMvVHtMgwLFr7qLEJsRxHBI
|
ps4Passcode: KgSnOxla5PMvVHtMgwLFr7qLEJsRxHBI
|
||||||
|
ps4UseDebugIl2cppLibs: 0
|
||||||
ps4pnSessions: 1
|
ps4pnSessions: 1
|
||||||
ps4pnPresence: 1
|
ps4pnPresence: 1
|
||||||
ps4pnFriends: 1
|
ps4pnFriends: 1
|
||||||
@@ -328,6 +332,7 @@ PlayerSettings:
|
|||||||
psp2UseLibLocation: 0
|
psp2UseLibLocation: 0
|
||||||
psp2InfoBarOnStartup: 0
|
psp2InfoBarOnStartup: 0
|
||||||
psp2InfoBarColor: 0
|
psp2InfoBarColor: 0
|
||||||
|
psp2UseDebugIl2cppLibs: 0
|
||||||
psmSplashimage: {fileID: 0}
|
psmSplashimage: {fileID: 0}
|
||||||
spritePackerPolicy:
|
spritePackerPolicy:
|
||||||
scriptingDefineSymbols:
|
scriptingDefineSymbols:
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 5.3.4f1
|
m_EditorVersion: 5.3.5f1
|
||||||
m_StandardAssetsVersion: 0
|
m_StandardAssetsVersion: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user