style again

This commit is contained in:
2015-07-11 18:52:36 +06:00
parent 3437fa40ce
commit ff77d077e2
16 changed files with 103 additions and 141 deletions

View File

@@ -29,7 +29,7 @@ namespace IsoTools {
}
}
bool IsAnyAlignment {
bool isAnyAlignment {
get { return _positions.Keys.Any(p => p.isAlignment); }
}
@@ -47,7 +47,7 @@ namespace IsoTools {
float ZMoveIsoObjects(float delta) {
Undo.RecordObjects(_iso_zpositions.Keys.ToArray(), "Move");
var is_any_alignment = IsAnyAlignment;
var is_any_alignment = isAnyAlignment;
return _iso_zpositions.Aggregate(0.0f, (AccIn, pair) => {
var iso_object = pair.Key;
var iso_orig_z = pair.Value;
@@ -63,7 +63,7 @@ namespace IsoTools {
Vector3 XYMoveIsoObjects(Vector3 delta) {
Undo.RecordObjects(_positions.Keys.ToArray(), "Move");
var is_any_alignment = IsAnyAlignment;
var is_any_alignment = isAnyAlignment;
return _positions.Aggregate(Vector3.zero, (AccIn, pair) => {
var iso_object = pair.Key;
var iso_orig_p = pair.Value;

View File

@@ -42,8 +42,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: 1}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21217528
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -42,8 +42,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: 3}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21263702
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -42,8 +42,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 3, z: 1}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21253620
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -42,8 +42,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 3, y: 1, z: 1}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21262204
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -42,8 +42,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 3, y: 3, z: 0}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21253404
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 114888}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 32, y: 16, z: 22.2222233}
m_LocalPosition: {x: 1.29999995, y: .649999976, z: 22.2222233}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 483872}
@@ -70,8 +70,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: .529999971}
_position: {x: 2, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21221408
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155780}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -64, y: 0, z: 0}
m_LocalPosition: {x: -2.5999999, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 457334}
@@ -70,8 +70,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: .529999971}
_position: {x: -2, y: 2, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21228980
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 112436}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 32, y: -16, z: 0}
m_LocalPosition: {x: 1.29999995, y: -.649999976, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 400788}
@@ -70,8 +70,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: .529999971}
_position: {x: 0, y: -2, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21298190
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -70,8 +70,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
_size: {x: 1, y: 1, z: .529999971}
_position: {x: 0, y: 0, z: 0}
_alignment: 1
_showBounds: 0
_isAlignment: 1
_isShowBounds: 0
--- !u!212 &21238442
SpriteRenderer:
m_ObjectHideFlags: 1

View File

@@ -184,6 +184,10 @@ Prefab:
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 114888, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: m_Name
value: Road0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
m_IsPrefabParent: 0
@@ -394,7 +398,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 114888, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: m_Name
value: Road 4
value: Road9
objectReference: {fileID: 0}
- target: {fileID: 11480044, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: _showBounds
@@ -456,7 +460,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 114888, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: m_Name
value: Road 2
value: Road8
objectReference: {fileID: 0}
- target: {fileID: 11480044, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: _showBounds
@@ -516,6 +520,10 @@ Prefab:
propertyPath: _position.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 166186, guid: 30a269be2fc864c9ea00c7a65636d543, type: 2}
propertyPath: m_Name
value: CityTile_066
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 30a269be2fc864c9ea00c7a65636d543, type: 2}
m_IsPrefabParent: 0
@@ -916,6 +924,10 @@ Prefab:
propertyPath: _position.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11438418, guid: 30a269be2fc864c9ea00c7a65636d543, type: 2}
propertyPath: _position.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 30a269be2fc864c9ea00c7a65636d543, type: 2}
m_IsPrefabParent: 0
@@ -1088,7 +1100,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 114888, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: m_Name
value: Road 5
value: Road10
objectReference: {fileID: 0}
- target: {fileID: 11480044, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: _showBounds
@@ -1498,7 +1510,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 114888, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: m_Name
value: Road 1
value: Road7
objectReference: {fileID: 0}
- target: {fileID: 11480044, guid: 04fdbaa6703674aa59a45e7b9fa9fff6, type: 2}
propertyPath: _showBounds
@@ -2106,7 +2118,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1768303655}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0, y: 1.99000001, z: -10}
m_LocalPosition: {x: -0, y: 2, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

View File

@@ -5,8 +5,7 @@ using UnityEditor;
#endif
namespace IsoTools {
[ExecuteInEditMode]
[DisallowMultipleComponent]
[ExecuteInEditMode, DisallowMultipleComponent]
public class IsoObject : MonoBehaviour {
// ------------------------------------------------------------------------
@@ -18,7 +17,6 @@ namespace IsoTools {
[SerializeField]
Vector3 _size = Vector3.one;
/// <summary>Isometric object size.</summary>
public Vector3 size {
get { return _size; }
set {
@@ -27,35 +25,29 @@ namespace IsoTools {
}
}
/// <summary>Isometric object size X.</summary>
public float sizeX {
get { return size.x; }
set { size = IsoUtils.Vec3ChangeX(size, value); }
}
/// <summary>Isometric object size Y.</summary>
public float sizeY {
get { return size.y; }
set { size = IsoUtils.Vec3ChangeY(size, value); }
}
/// <summary>Isometric object size Z.</summary>
public float sizeZ {
get { return size.z; }
set { size = IsoUtils.Vec3ChangeZ(size, value); }
}
/// <summary>Isometric object size XY.</summary>
public Vector2 sizeXY {
get { return new Vector2(sizeX, sizeY); }
}
/// <summary>Isometric object size YZ.</summary>
public Vector2 sizeYZ {
get { return new Vector2(sizeY, sizeZ); }
}
/// <summary>Isometric object size XZ.</summary>
public Vector2 sizeXZ {
get { return new Vector2(sizeX, sizeZ); }
}
@@ -69,7 +61,6 @@ namespace IsoTools {
[SerializeField]
Vector3 _position = Vector3.zero;
/// <summary>Isometric object position.</summary>
public Vector3 position {
get { return _position; }
set {
@@ -78,35 +69,29 @@ namespace IsoTools {
}
}
/// <summary>Isometric object position X.</summary>
public float positionX {
get { return position.x; }
set { position = IsoUtils.Vec3ChangeX(position, value); }
}
/// <summary>Isometric object position Y.</summary>
public float positionY {
get { return position.y; }
set { position = IsoUtils.Vec3ChangeY(position, value); }
}
/// <summary>Isometric object position Z.</summary>
public float positionZ {
get { return position.z; }
set { position = IsoUtils.Vec3ChangeZ(position, value); }
}
/// <summary>Isometric object position XY.</summary>
public Vector2 positionXY {
get { return new Vector2(positionX, positionY); }
}
/// <summary>Isometric object position YZ.</summary>
public Vector2 positionYZ {
get { return new Vector2(positionY, positionZ); }
}
/// <summary>Isometric object position XZ.</summary>
public Vector2 positionXZ {
get { return new Vector2(positionX, positionZ); }
}
@@ -117,41 +102,34 @@ namespace IsoTools {
//
// ------------------------------------------------------------------------
/// <summary>Isometric object tile position.</summary>
public Vector3 tilePosition {
get { return IsoUtils.Vec3Round(position); }
set { position = value; }
}
/// <summary>Isometric object tile position X.</summary>
public float tilePositionX {
get { return tilePosition.x; }
set { tilePosition = IsoUtils.Vec3ChangeX(tilePosition, value); }
}
/// <summary>Isometric object tile position Y.</summary>
public float tilePositionY {
get { return tilePosition.y; }
set { tilePosition = IsoUtils.Vec3ChangeY(tilePosition, value); }
}
/// <summary>Isometric object tile position Z.</summary>
public float tilePositionZ {
get { return tilePosition.z; }
set { tilePosition = IsoUtils.Vec3ChangeZ(tilePosition, value); }
}
/// <summary>Isometric object tile position XY.</summary>
public Vector2 tilePositionXY {
get { return new Vector2(tilePositionX, tilePositionY); }
}
/// <summary>Isometric object tile position YZ.</summary>
public Vector2 tilePositionYZ {
get { return new Vector2(tilePositionY, tilePositionZ); }
}
/// <summary>Isometric object tile position XZ.</summary>
public Vector2 tilePositionXZ {
get { return new Vector2(tilePositionX, tilePositionZ); }
}
@@ -163,9 +141,9 @@ namespace IsoTools {
// ------------------------------------------------------------------------
#if UNITY_EDITOR
Vector3 _lastSize = Vector3.zero;
Vector3 _lastPosition = Vector3.zero;
Vector2 _lastTransform = Vector2.zero;
Vector3 _lastSize = Vector3.zero;
Vector3 _lastPosition = Vector3.zero;
Vector2 _lastTransPos = Vector2.zero;
[SerializeField] bool _isAlignment = true;
[SerializeField] bool _isShowBounds = false;
@@ -204,7 +182,7 @@ namespace IsoTools {
public void FixTransform() {
#if UNITY_EDITOR
if ( Application.isEditor && !Application.isPlaying && isAlignment ) {
if ( !Application.isPlaying && isAlignment ) {
_position = tilePosition;
}
#endif
@@ -224,9 +202,9 @@ namespace IsoTools {
void FixLastProperties() {
#if UNITY_EDITOR
_lastSize = size;
_lastPosition = position;
_lastTransform = transform.position;
_lastSize = size;
_lastPosition = position;
_lastTransPos = transform.position;
#endif
}
@@ -236,12 +214,16 @@ namespace IsoTools {
void MarkEditorObjectDirty() {
#if UNITY_EDITOR
if ( Application.isEditor ) {
EditorUtility.SetDirty(this);
}
EditorUtility.SetDirty(this);
#endif
}
// ------------------------------------------------------------------------
//
// Messages
//
// ------------------------------------------------------------------------
void Awake() {
FixLastProperties();
FixIsoPosition();
@@ -263,22 +245,20 @@ namespace IsoTools {
}
void OnDrawGizmos() {
if ( isShowBounds && isoWorld ) {
if ( isShowBounds ) {
IsoUtils.DrawCube(isoWorld, position + size * 0.5f, size, Color.red);
}
}
void Update() {
if ( Application.isEditor ) {
if ( !IsoUtils.Vec3Approximately(_lastSize, _size) ) {
size = _size;
}
if ( !IsoUtils.Vec3Approximately(_lastPosition, _position) ) {
position = _position;
}
if ( !IsoUtils.Vec2Approximately(_lastTransform, transform.position) ) {
FixIsoPosition();
}
if ( !IsoUtils.Vec3Approximately(_lastSize, _size) ) {
size = _size;
}
if ( !IsoUtils.Vec3Approximately(_lastPosition, _position) ) {
position = _position;
}
if ( !IsoUtils.Vec2Approximately(_lastTransPos, transform.position) ) {
FixIsoPosition();
}
}
#endif

View File

@@ -1,5 +1,4 @@
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
#if UNITY_EDITOR
@@ -7,8 +6,7 @@ using UnityEditor;
#endif
namespace IsoTools {
[ExecuteInEditMode]
[DisallowMultipleComponent]
[ExecuteInEditMode, DisallowMultipleComponent]
public class IsoWorld : MonoBehaviour {
class ObjectInfo {
@@ -49,9 +47,14 @@ namespace IsoTools {
Vector3 _objsMaxNumPos = Vector3.zero;
Vector3 _objsNumPosCount = Vector3.zero;
// ------------------------------------------------------------------------
//
// Public
//
// ------------------------------------------------------------------------
[SerializeField]
public float _tileSize = 32.0f;
/// <summary>Isometric tile size.</summary>
public float tileSize {
get { return _tileSize; }
set {
@@ -62,7 +65,6 @@ namespace IsoTools {
[SerializeField]
public float _minDepth = 0.0f;
/// <summary>Min sorting depth value.</summary>
public float minDepth {
get { return _minDepth; }
set {
@@ -73,7 +75,6 @@ namespace IsoTools {
[SerializeField]
public float _maxDepth = 100.0f;
/// <summary>Max sorting depth value.</summary>
public float maxDepth {
get { return _maxDepth; }
set {
@@ -82,48 +83,23 @@ namespace IsoTools {
}
}
// ------------------------------------------------------------------------
/// <summary>
/// Marks world for resorting.
/// </summary>
// ------------------------------------------------------------------------
public void MarkDirty() {
_dirty = true;
MarkEditorWorldDirty();
}
// ------------------------------------------------------------------------
/// <summary>
/// Marks world for resorting.
/// </summary>
/// <param name="iso_object">Isometric object for resorting.</param>
// ------------------------------------------------------------------------
public void MarkDirty(IsoObject iso_object) {
if ( !_dirty && iso_object && _visibles.Contains(iso_object) ) {
MarkDirty();
}
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert isometric coordinates to screen coordinates
/// </summary>
/// <returns>Screen coordinates</returns>
/// <param name="pos">Isometric coordinates.</param>
// ------------------------------------------------------------------------
public Vector2 IsoToScreen(Vector3 pos) {
return new Vector2(
(pos.x - pos.y),
(pos.x + pos.y) * 0.5f + pos.z) * tileSize;
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert screen coordinates to isometric coordinates
/// </summary>
/// <returns>Isometric coordinates</returns>
/// <param name="pos">Screen coordinates.</param>
// ------------------------------------------------------------------------
public Vector3 ScreenToIso(Vector2 pos) {
return new Vector3(
(pos.x * 0.5f + pos.y),
@@ -131,14 +107,6 @@ namespace IsoTools {
0.0f) / tileSize;
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert screen coordinates to isometric coordinates with specified isometric height
/// </summary>
/// <returns>Isometric coordinates</returns>
/// <param name="pos">Screen coordinates.</param>
/// <param name="iso_z">Point isometric height.</param>
// ------------------------------------------------------------------------
public Vector3 ScreenToIso(Vector2 pos, float iso_z) {
return IsoUtils.Vec3ChangeZ(
ScreenToIso(new Vector2(pos.x, pos.y - iso_z * tileSize)),
@@ -172,9 +140,7 @@ namespace IsoTools {
void MarkEditorWorldDirty() {
#if UNITY_EDITOR
if ( Application.isEditor ) {
EditorUtility.SetDirty(this);
}
EditorUtility.SetDirty(this);
#endif
}
@@ -388,6 +354,12 @@ namespace IsoTools {
}
}
// ------------------------------------------------------------------------
//
// Messages
//
// ------------------------------------------------------------------------
void Start() {
ChangeSortingProperty();
StepSort();

View File

@@ -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

View File

@@ -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

View File

@@ -1,11 +1,9 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoObject.cs">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs">
<Files>
<File FileName="Assets/IsoTools/Scripts/IsoFakeObject.cs" Line="1" Column="1" />
<File FileName="Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs" Line="1" Column="1" />
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="1" Column="1" />
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="175" Column="4" />
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="234" Column="4" />
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="244" Column="35" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>