alignment flag dynamic change fix.

alignment work in editor only.
mini code refactoring.
This commit is contained in:
2015-02-15 22:12:21 +06:00
parent 14327737b6
commit bb7eaca49f
15 changed files with 1764 additions and 382 deletions

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_4_6_0;UNITY_4_6;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
@@ -51,7 +51,7 @@
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
<Compile Include="Assets\IsoTools\Scripts\IsoWorld.cs" />
<Reference Include="UnityEngine.UI">
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/4.6.0/UnityEngine.UI.dll</HintPath>
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_4_6_0;UNITY_4_6;UNITY_STANDALONE_OSX;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_GAMECENTER;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
@@ -51,7 +51,7 @@
<Compile Include="Assets\IsoTools\Scripts\IsoObject.cs" />
<Compile Include="Assets\IsoTools\Scripts\IsoWorld.cs" />
<Reference Include="UnityEngine.UI">
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/4.6.0/UnityEngine.UI.dll</HintPath>
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -1,5 +0,0 @@
fileFormatVersion: 2
guid: b0264992f90e27e48beeee54b801c8f2
folderAsset: yes
DefaultImporter:
userData:

View File

@@ -1,5 +0,0 @@
fileFormatVersion: 2
guid: 47c3c77b488bde14eac761a5144660ed
folderAsset: yes
DefaultImporter:
userData:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 11ea09039680944f5a209ed6ed266880
timeCreated: 1424000856
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,161 +5,155 @@ using UnityEditor;
#endif
namespace IsoTools {
[ExecuteInEditMode]
public class IsoObject : MonoBehaviour {
Transform _transform = null;
Vector3 _lastPosition = Vector3.zero;
Vector3 _lastTransform = Vector3.zero;
[ExecuteInEditMode]
public class IsoObject : MonoBehaviour {
Transform _transform = null;
Vector3 _lastTransform = Vector3.zero;
Vector3 _lastPosition = Vector3.zero;
Vector3 _lastSize = Vector3.zero;
bool _lastSorting = false;
bool _lastAlignment = false;
[SerializeField]
Vector3 _position = Vector3.zero;
/// <summary>Isometric object position.</summary>
public Vector3 Position {
get { return _position; }
set {
_position = value;
if ( Alignment ) {
FixAlignment();
} else {
[SerializeField]
Vector3 _position = Vector3.zero;
/// <summary>Isometric object position.</summary>
public Vector3 Position {
get { return _position; }
set {
_position = value;
FixTransform();
}
}
[SerializeField]
Vector3 _size = Vector3.one;
/// <summary>Isometric object size.</summary>
public Vector3 Size {
get { return _size; }
set {
_size = value;
FixTransform();
}
}
[SerializeField]
bool _sorting = true;
/// <summary>Auto sorting tile.</summary>
public bool Sorting {
get { return _sorting; }
set {
_sorting = value;
FixTransform();
}
}
[SerializeField]
bool _alignment = true;
/// <summary>Auto alignment position by isometric tile size.</summary>
public bool Alignment {
get { return _alignment; }
set {
_alignment = value;
FixTransform();
}
}
[SerializeField]
/// <summary>Isometric object tile position.</summary>
public Vector3 TilePosition {
get {
return new Vector3(
Mathf.Round(Position.x),
Mathf.Round(Position.y),
Mathf.Round(Position.z));
}
set {
Position = value;
}
}
IsoWorld _iso_world = null;
public IsoWorld GetIsoWorld() {
if ( !_iso_world ) {
_iso_world = GameObject.FindObjectOfType<IsoWorld>();
}
if ( !_iso_world ) {
throw new UnityException("IsoObject. IsoWorld not found!");
}
return _iso_world;
}
public void ResetIsoWorld() {
_iso_world = null;
}
public void FixTransform() {
if ( Application.isEditor && Alignment ) {
_position = TilePosition;
}
var iso_world = GetIsoWorld();
if ( iso_world && _transform ) {
Vector3 trans = iso_world.IsoToScreen(Position);
trans.z = _transform.position.z;
_transform.position = trans;
FixLastProperties(trans);
}
MartDirtyIsoWorld();
MarkEditorObjectDirty();
}
}
[SerializeField]
Vector3 _size = Vector3.one;
/// <summary>Isometric object size.</summary>
public Vector3 Size {
get { return _size; }
set {
_size = value;
if ( Alignment ) {
FixAlignment();
} else {
FixTransform();
public void FixIsoPosition() {
var iso_world = GetIsoWorld();
if ( iso_world && _transform ) {
Vector2 trans = _transform.position;
Position = iso_world.ScreenToIso(trans, Position.z);
}
MartDirtyIsoWorld();
MarkEditorObjectDirty();
}
}
[SerializeField]
bool _alignment = true;
/// <summary>Auto alignment position by isometric tile size.</summary>
public bool Alignment {
get { return _alignment; }
set {
_alignment = value;
if ( Alignment ) {
FixAlignment();
} else {
FixTransform();
}
MartDirtyIsoWorld();
MarkEditorObjectDirty();
}
}
[SerializeField]
bool _sorting = true;
/// <summary>Auto sorting tile.</summary>
public bool Sorting {
get { return _sorting; }
set {
_sorting = value;
MartDirtyIsoWorld();
MarkEditorObjectDirty();
}
}
public Vector3 TilePosition {
get {
return new Vector3(
Mathf.Round(Position.x),
Mathf.Round(Position.y),
Mathf.Round(Position.z));
}
}
IsoWorld _iso_world = null;
public IsoWorld GetIsoWorld() {
if ( !_iso_world ) {
_iso_world = GameObject.FindObjectOfType<IsoWorld>();
}
if ( !_iso_world ) {
throw new UnityException("IsoObject. IsoWorld not found!");
}
return _iso_world;
}
public void ResetIsoWorld() {
_iso_world = null;
}
public void FixAlignment() {
_position = TilePosition;
FixTransform();
MartDirtyIsoWorld();
MarkEditorObjectDirty();
}
public void FixTransform() {
var iso_world = GetIsoWorld();
if ( iso_world && _transform ) {
Vector3 trans = iso_world.IsoToScreen(Position);
trans.z = _transform.position.z;
_transform.position = trans;
_lastPosition = Position;
void FixLastProperties(Vector3 trans) {
_lastTransform = trans;
_lastPosition = Position;
_lastSize = Size;
_lastSorting = Sorting;
_lastAlignment = Alignment;
}
}
public void FixIsoPosition() {
var iso_world = GetIsoWorld();
if ( iso_world && _transform ) {
Vector2 trans = _transform.position;
Position = iso_world.ScreenToIso(trans, Position.z);
FixTransform();
void MartDirtyIsoWorld() {
var iso_world = GetIsoWorld();
if ( iso_world && Sorting ) {
iso_world.MarkDirty();
}
}
}
void MartDirtyIsoWorld() {
var iso_world = GetIsoWorld();
if ( iso_world && Sorting ) {
iso_world.MarkDirty();
}
}
void MarkEditorObjectDirty() {
void MarkEditorObjectDirty() {
#if UNITY_EDITOR
if ( Application.isEditor ) {
EditorUtility.SetDirty(this);
}
if ( Application.isEditor ) {
EditorUtility.SetDirty(this);
}
#endif
}
void Awake() {
_transform = gameObject.transform;
_lastPosition = Position;
_lastTransform = _transform.position;
FixIsoPosition();
MartDirtyIsoWorld();
}
void Update() {
if ( _lastPosition != _position ) {
Position = _position;
}
if ( _lastTransform != _transform.position ) {
void Awake() {
_transform = gameObject.transform;
FixLastProperties(_transform.position);
FixIsoPosition();
}
}
void Update() {
if ( _lastTransform != _transform.position ) {
FixIsoPosition();
}
if ( Application.isEditor ) {
if ( _lastPosition != _position ) Position = _position;
if ( _lastSize != _size ) Size = _size;
if ( _lastSorting != _sorting ) Sorting = _sorting;
if ( _lastAlignment != _alignment ) Alignment = _alignment;
}
}
void OnEnable() {
MartDirtyIsoWorld();
void OnEnable() {
MartDirtyIsoWorld();
}
}
}
} // namespace IsoTools

View File

@@ -2,234 +2,234 @@
using System.Collections.Generic;
namespace IsoTools {
[ExecuteInEditMode]
public class IsoWorld : MonoBehaviour {
/// <summary>World tile types.</summary>
public enum TileTypes {
Isometric,
UpDown
}
/// <summary>World tile type.</summary>
public TileTypes TileType = TileTypes.Isometric;
/// <summary>Isometric tile size.</summary>
public float TileSize = 32.0f;
/// <summary>Start sorting depth value.</summary>
public float StartDepth = 0.0f;
/// <summary>Step sorting depth value.</summary>
public float StepDepth = 0.1f;
[ExecuteInEditMode]
public class IsoWorld : MonoBehaviour {
/// <summary>World tile types.</summary>
public enum TileTypes {
Isometric,
UpDown
}
/// <summary>World tile type.</summary>
public TileTypes TileType = TileTypes.Isometric;
/// <summary>Isometric tile size.</summary>
public float TileSize = 32.0f;
/// <summary>Start sorting depth value.</summary>
public float StartDepth = 0.0f;
/// <summary>Step sorting depth value.</summary>
public float StepDepth = 0.1f;
class ObjectInfo {
public IsoObject IsoObject;
public bool Visited;
public int BeginDepend;
public int EndDepend;
public ObjectInfo(IsoObject obj) {
IsoObject = obj;
}
public void Reset(int first_depend) {
Visited = false;
BeginDepend = first_depend;
EndDepend = first_depend;
}
}
bool _dirty = true;
float _lastTileSize = 0.0f;
TileTypes _lastTileType = TileTypes.Isometric;
// ------------------------------------------------------------------------
/// <summary>
/// Marks world for resorting.
/// </summary>
// ------------------------------------------------------------------------
public void MarkDirty() {
_dirty = true;
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert isometric coordinates to screen coordinates
/// </summary>
/// <returns>Screen coordinates</returns>
/// <param name="pos">Isometric coordinates.</param>
// ------------------------------------------------------------------------
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. Type is wrong!");
}
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert screen coordinates to isometric coordinates
/// </summary>
/// <returns>Isometric coordinates</returns>
/// <param name="pos">Screen coordinates.</param>
// ------------------------------------------------------------------------
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. Type is wrong!");
}
}
// ------------------------------------------------------------------------
/// <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) {
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;
class ObjectInfo {
public IsoObject IsoObject;
public bool Visited;
public int BeginDepend;
public int EndDepend;
public ObjectInfo(IsoObject obj) {
IsoObject = obj;
}
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. Type is wrong!");
}
}
void _fixAllTransforms() {
var objects = _scanObjects(false);
foreach ( var obj in objects ) {
obj.IsoObject.FixTransform();
}
}
void _fixTileSize() {
_fixAllTransforms();
_lastTileSize = TileSize;
}
void _fixTileType() {
_fixAllTransforms();
_lastTileType = TileType;
}
void _fixDirty() {
_manualSort();
_dirty = false;
}
void _fixDisable() {
var objects = _scanObjects(false);
foreach ( var obj in objects ) {
obj.IsoObject.ResetIsoWorld();
}
}
IList<ObjectInfo> _scanObjects(bool onlySorting) {
IsoObject[] iso_objects = GameObject.FindObjectsOfType<IsoObject>();
var objects = new List<ObjectInfo>(iso_objects.Length);
foreach ( var iso_object in iso_objects ) {
if ( !onlySorting || iso_object.Sorting ) {
var info = new ObjectInfo(iso_object);
objects.Add(info);
public void Reset(int first_depend) {
Visited = false;
BeginDepend = first_depend;
EndDepend = first_depend;
}
}
return objects;
}
IList<int> _scanDepends(IList<ObjectInfo> objects) {
var depends = new List<int>(objects.Count);
foreach ( var obj_a in objects ) {
obj_a.Reset(depends.Count);
var obj_ao = obj_a.IsoObject;
var max_ax = obj_ao.Position.x + obj_ao.Size.x;
var max_ay = obj_ao.Position.y + obj_ao.Size.y;
for ( int i = 0; i < objects.Count; ++i ) {
var obj_bo = objects[i].IsoObject;
if ( obj_ao != obj_bo ) {
if ( obj_bo.Position.x < max_ax && obj_bo.Position.y < max_ay ) {
var max_bz = obj_bo.Position.z + obj_bo.Size.z;
if ( obj_ao.Position.z < max_bz ) {
depends.Add(i);
++obj_a.EndDepend;
bool _dirty = true;
float _lastTileSize = 0.0f;
TileTypes _lastTileType = TileTypes.Isometric;
// ------------------------------------------------------------------------
/// <summary>
/// Marks world for resorting.
/// </summary>
// ------------------------------------------------------------------------
public void MarkDirty() {
_dirty = true;
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert isometric coordinates to screen coordinates
/// </summary>
/// <returns>Screen coordinates</returns>
/// <param name="pos">Isometric coordinates.</param>
// ------------------------------------------------------------------------
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. Type is wrong!");
}
}
// ------------------------------------------------------------------------
/// <summary>
/// Convert screen coordinates to isometric coordinates
/// </summary>
/// <returns>Isometric coordinates</returns>
/// <param name="pos">Screen coordinates.</param>
// ------------------------------------------------------------------------
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. Type is wrong!");
}
}
// ------------------------------------------------------------------------
/// <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) {
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. Type is wrong!");
}
}
void _fixAllTransforms() {
var objects = _scanObjects(false);
foreach ( var obj in objects ) {
obj.IsoObject.FixTransform();
}
}
void _fixTileSize() {
_fixAllTransforms();
_lastTileSize = TileSize;
}
void _fixTileType() {
_fixAllTransforms();
_lastTileType = TileType;
}
void _fixDirty() {
_manualSort();
_dirty = false;
}
void _fixDisable() {
var objects = _scanObjects(false);
foreach ( var obj in objects ) {
obj.IsoObject.ResetIsoWorld();
}
}
IList<ObjectInfo> _scanObjects(bool onlySorting) {
var iso_objects = GameObject.FindObjectsOfType<IsoObject>();
var objects = new List<ObjectInfo>(iso_objects.Length);
foreach ( var iso_object in iso_objects ) {
if ( !onlySorting || iso_object.Sorting ) {
var info = new ObjectInfo(iso_object);
objects.Add(info);
}
}
return objects;
}
IList<int> _scanDepends(IList<ObjectInfo> objects) {
var depends = new List<int>(objects.Count);
foreach ( var obj_a in objects ) {
obj_a.Reset(depends.Count);
var obj_ao = obj_a.IsoObject;
var max_ax = obj_ao.Position.x + obj_ao.Size.x;
var max_ay = obj_ao.Position.y + obj_ao.Size.y;
for ( int i = 0; i < objects.Count; ++i ) {
var obj_bo = objects[i].IsoObject;
if ( obj_ao != obj_bo ) {
if ( obj_bo.Position.x < max_ax && obj_bo.Position.y < max_ay ) {
var max_bz = obj_bo.Position.z + obj_bo.Size.z;
if ( obj_ao.Position.z < max_bz ) {
depends.Add(i);
++obj_a.EndDepend;
}
}
}
}
}
return depends;
}
return depends;
}
void _manualSort() {
var objects = _scanObjects(true);
var depends = _scanDepends(objects);
var depth = StartDepth;
foreach ( var info in objects ) {
_placeObject(info, objects, depends, ref depth);
}
}
void _placeObject(IsoObject obj, float depth) {
var pos = obj.gameObject.transform.position;
obj.gameObject.transform.position = new Vector3(pos.x, pos.y, depth);
}
void _placeObject(ObjectInfo info, IList<ObjectInfo> objects, IList<int> depends, ref float depth) {
if ( !info.Visited ) {
info.Visited = true;
for ( int i = info.BeginDepend; i < info.EndDepend && i < depends.Count; ++i ) {
var object_index = depends[i];
var obj = objects[object_index];
_placeObject(obj, objects, depends, ref depth);
void _manualSort() {
var objects = _scanObjects(true);
var depends = _scanDepends(objects);
var depth = StartDepth;
foreach ( var info in objects ) {
_placeObject(info, objects, depends, ref depth);
}
_placeObject(info.IsoObject, depth);
depth += StepDepth;
}
}
void Start() {
_fixTileSize();
_fixTileType();
_fixDirty();
}
void _placeObject(IsoObject obj, float depth) {
var pos = obj.gameObject.transform.position;
obj.gameObject.transform.position = new Vector3(pos.x, pos.y, depth);
}
void LateUpdate() {
if ( _lastTileSize != TileSize ) {
void _placeObject(ObjectInfo info, IList<ObjectInfo> objects, IList<int> depends, ref float depth) {
if ( !info.Visited ) {
info.Visited = true;
for ( int i = info.BeginDepend; i < info.EndDepend && i < depends.Count; ++i ) {
var object_index = depends[i];
var obj = objects[object_index];
_placeObject(obj, objects, depends, ref depth);
}
_placeObject(info.IsoObject, depth);
depth += StepDepth;
}
}
void Start() {
_fixTileSize();
}
if ( _lastTileType != TileType ) {
_fixTileType();
}
if ( _dirty ) {
_fixDirty();
}
}
void OnDisable() {
_fixDisable();
void LateUpdate() {
if ( _lastTileSize != TileSize ) {
_fixTileSize();
}
if ( _lastTileType != TileType ) {
_fixTileType();
}
if ( _dirty ) {
_fixDirty();
}
}
void OnDisable() {
_fixDisable();
}
}
}
} // namespace IsoTools

View File

@@ -3,8 +3,27 @@
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
serializedVersion: 3
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
m_LegacyDeferred:
m_Mode: 1
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
m_AlwaysIncludedShaders:
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_LightmapStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDirSeparate: 1
m_LightmapKeepDynamic: 1
m_FogStripping: 0
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1

View File

@@ -0,0 +1,133 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!126 &1
NavMeshLayers:
m_ObjectHideFlags: 0
Built-in Layer 0:
name: Default
cost: 1
editType: 2
Built-in Layer 1:
name: Not Walkable
cost: 1
editType: 0
Built-in Layer 2:
name: Jump
cost: 2
editType: 2
User Layer 0:
name:
cost: 1
editType: 3
User Layer 1:
name:
cost: 1
editType: 3
User Layer 2:
name:
cost: 1
editType: 3
User Layer 3:
name:
cost: 1
editType: 3
User Layer 4:
name:
cost: 1
editType: 3
User Layer 5:
name:
cost: 1
editType: 3
User Layer 6:
name:
cost: 1
editType: 3
User Layer 7:
name:
cost: 1
editType: 3
User Layer 8:
name:
cost: 1
editType: 3
User Layer 9:
name:
cost: 1
editType: 3
User Layer 10:
name:
cost: 1
editType: 3
User Layer 11:
name:
cost: 1
editType: 3
User Layer 12:
name:
cost: 1
editType: 3
User Layer 13:
name:
cost: 1
editType: 3
User Layer 14:
name:
cost: 1
editType: 3
User Layer 15:
name:
cost: 1
editType: 3
User Layer 16:
name:
cost: 1
editType: 3
User Layer 17:
name:
cost: 1
editType: 3
User Layer 18:
name:
cost: 1
editType: 3
User Layer 19:
name:
cost: 1
editType: 3
User Layer 20:
name:
cost: 1
editType: 3
User Layer 21:
name:
cost: 1
editType: 3
User Layer 22:
name:
cost: 1
editType: 3
User Layer 23:
name:
cost: 1
editType: 3
User Layer 24:
name:
cost: 1
editType: 3
User Layer 25:
name:
cost: 1
editType: 3
User Layer 26:
name:
cost: 1
editType: 3
User Layer 27:
name:
cost: 1
editType: 3
User Layer 28:
name:
cost: 1
editType: 3

View File

@@ -3,15 +3,17 @@
--- !u!129 &1
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 3
serializedVersion: 6
AndroidProfiler: 0
defaultScreenOrientation: 4
targetDevice: 2
targetGlesGraphics: 1
targetIOSGraphics: -1
targetResolution: 0
accelerometerFrequency: 60
companyName: DefaultCompany
productName: UnityIso
cloudProjectId:
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
defaultScreenWidth: 1024
@@ -27,6 +29,7 @@ PlayerSettings:
m_Stereoscopic3D: 0
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1
iosAppInBackgroundBehavior: 0
displayResolutionDialog: 1
allowedAutorotateToPortrait: 1
allowedAutorotateToPortraitUpsideDown: 1
@@ -34,16 +37,16 @@ PlayerSettings:
allowedAutorotateToLandscapeLeft: 1
useOSAutorotation: 1
use32BitDisplayBuffer: 1
use24BitDepthBuffer: 1
disableDepthAndStencilBuffers: 0
defaultIsFullScreen: 1
defaultIsNativeResolution: 1
runInBackground: 0
captureSingleScreen: 0
Override IPod Music: 0
Prepare IOS For Recording: 0
enableHWStatistics: 1
submitAnalytics: 1
usePlayerLog: 1
stripPhysics: 0
bakeCollisionMeshes: 0
forceSingleInstance: 0
resizableWindow: 0
useMacAppStoreValidation: 0
@@ -56,22 +59,28 @@ PlayerSettings:
visibleInBackground: 0
macFullscreenMode: 2
d3d9FullscreenMode: 1
d3d11ForceExclusiveMode: 0
d3d11FullscreenMode: 1
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0
xboxEnableGuest: 0
xboxOneResolution: 0
ps3SplashScreen: {fileID: 0}
videoMemoryForVertexBuffers: 0
psp2PowerMode: 0
psp2AcquireBGM: 1
m_SupportedAspectRatios:
4:3: 1
5:4: 1
16:10: 1
16:9: 1
Others: 1
iPhoneBundleIdentifier: com.Company.ProductName
bundleIdentifier: com.Company.ProductName
bundleVersion: 1.0
preloadedAssets: []
metroEnableIndependentInputSource: 0
metroEnableLowLatencyPresentationAPI: 0
xboxOneDisableKinectGpuReservation: 0
productGUID: 0ae4d8e5611a65d45bd97550aa4471af
iPhoneBundleVersion: 1.0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 9
AndroidPreferredInstallLocation: 1
@@ -83,9 +92,10 @@ PlayerSettings:
ForceSDCardPermission: 0
CreateWallpaper: 0
APKExpansionFiles: 0
preloadShaders: 0
StripUnusedMeshComponents: 0
iPhoneSdkVersion: 988
iPhoneTargetOSVersion: 16
iPhoneTargetOSVersion: 22
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIStatusBarHidden: 1
@@ -101,15 +111,34 @@ PlayerSettings:
iPadHighResPortraitSplashScreen: {fileID: 0}
iPadLandscapeSplashScreen: {fileID: 0}
iPadHighResLandscapeSplashScreen: {fileID: 0}
iOSCustomLaunchScreenType: 0
iOSLaunchScreenPortrait: {fileID: 0}
iOSLaunchScreenLandscape: {fileID: 0}
iOSLaunchScreenBackgroundColor:
serializedVersion: 2
rgba: 0
iOSLaunchScreenFillPct: 1
iOSLaunchScreenCustomXibPath:
AndroidTargetDevice: 0
AndroidSplashScreenScale: 0
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidTVCompatibility: 1
AndroidIsGame: 1
androidEnableBanner: 1
m_AndroidBanners:
- width: 320
height: 180
banner: {fileID: 0}
resolutionDialogBanner: {fileID: 0}
m_BuildTargetIcons: []
m_BuildTargetBatching: []
webPlayerTemplate: APPLICATION:Default
m_TemplateCustomTags: {}
actionOnDotNetUnhandledException: 1
enableInternalProfiler: 0
logObjCUncaughtExceptions: 1
enableCrashReportAPI: 0
locationUsageDescription:
XboxTitleId:
XboxImageXexPath:
@@ -126,6 +155,7 @@ PlayerSettings:
ps3ThumbnailPath:
ps3BackgroundPath:
ps3SoundPath:
ps3NPAgeRating: 12
ps3TrophyCommId:
ps3NpCommunicationPassphrase:
ps3TrophyPackagePath:
@@ -133,15 +163,65 @@ PlayerSettings:
ps3TrophyCommSig:
ps3SaveGameSlots: 1
ps3TrialMode: 0
ps3VideoMemoryForAudio: 0
ps3EnableVerboseMemoryStats: 0
ps3UseSPUForUmbra: 0
ps3EnableMoveSupport: 1
ps3DisableDolbyEncoding: 0
ps4NPAgeRating: 12
ps4NPTitleSecret:
ps4NPTrophyPackPath:
ps4ParentalLevel: 1
ps4ContentID: ED1633-NPXX51362_00-0000000000000000
ps4Category: 0
ps4MasterVersion: 01.00
ps4AppVersion: 01.00
ps4AppType: 0
ps4ParamSfxPath:
ps4VideoOutPixelFormat: 0
ps4VideoOutResolution: 4
ps4PronunciationXMLPath:
ps4PronunciationSIGPath:
ps4BackgroundImagePath:
ps4StartupImagePath:
ps4SaveDataImagePath:
ps4BGMPath:
ps4ShareFilePath:
ps4NPtitleDatPath:
ps4RemotePlayKeyAssignment: -1
ps4EnterButtonAssignment: 1
ps4ApplicationParam1: 0
ps4ApplicationParam2: 0
ps4ApplicationParam3: 0
ps4ApplicationParam4: 0
ps4Passcode: pRt5wtCRyeac8JJA3aoWdPQ0NhGppEkN
ps4pnSessions: 1
ps4pnPresence: 1
ps4pnFriends: 1
ps4pnGameCustomData: 1
playerPrefsSupport: 0
monoEnv:
psp2Splashimage: {fileID: 0}
psp2LiveAreaGate: {fileID: 0}
psp2LiveAreaBackround: {fileID: 0}
psp2NPTrophyPackPath:
psp2NPSupportGBMorGJP: 0
psp2NPAgeRating: 12
psp2NPCommsID:
psp2NPCommunicationsID:
psp2NPCommsPassphrase:
psp2NPCommsSig:
psp2ParamSfxPath:
psp2ManualPath:
psp2LiveAreaGatePath:
psp2LiveAreaBackroundPath:
psp2LiveAreaPath:
psp2LiveAreaTrialPath:
psp2PatchChangeInfoPath:
psp2PatchOriginalPackage:
psp2PackagePassword:
psp2KeystoneFile:
psp2DRMType: 0
psp2StorageType: 0
psp2MediaCapacity: 0
psp2DLCConfigPath:
psp2ThumbnailPath:
psp2BackgroundPath:
@@ -149,7 +229,23 @@ PlayerSettings:
psp2TrophyCommId:
psp2TrophyPackagePath:
psp2PackagedResourcesPath:
flashStrippingLevel: 2
psp2SaveDataQuota: 10240
psp2ParentalLevel: 1
psp2ShortTitle: Not Set
psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF
psp2Category: 0
psp2MasterVersion: 01.00
psp2AppVersion: 01.00
psp2TVBootMode: 0
psp2EnterButtonAssignment: 2
psp2TVDisableEmu: 0
psp2AllowTwitterDialog: 1
psp2Upgradable: 0
psp2HealthWarning: 0
psp2UseLibLocation: 0
psp2InfoBarOnStartup: 0
psp2InfoBarColor: 0
psmSplashimage: {fileID: 0}
spritePackerPolicy:
scriptingDefineSymbols: {}
metroPackageName: UnityIso
@@ -213,8 +309,10 @@ PlayerSettings:
metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1}
metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1}
metroSplashScreenUseBackgroundColor: 0
metroCapabilities: {}
metroUnprocessedPlugins: []
platformCapabilities: {}
metroFTAName:
metroFTAFileTypes: []
metroProtocolName:
metroCompilationOverrides: 1
blackberryDeviceAddress:
blackberryDevicePassword:
@@ -222,10 +320,8 @@ PlayerSettings:
blackberryTokenExires:
blackberryTokenAuthor:
blackberryTokenAuthorId:
blackberryAuthorId:
blackberryCskPassword:
blackberrySaveLogPath:
blackberryAuthorIdOveride: 0
blackberrySharedPermissions: 0
blackberryCameraPermissions: 0
blackberryGPSPermissions: 0
@@ -243,7 +339,47 @@ PlayerSettings:
tizenGPSPermissions: 0
tizenMicrophonePermissions: 0
stvDeviceAddress:
stvProductDescription:
stvProductAuthor:
stvProductAuthorEmail:
stvProductLink:
stvProductCategory: 0
XboxOneProductId:
XboxOneUpdateKey:
XboxOneSandboxId:
XboxOneContentId:
XboxOneTitleId:
XboxOneSCId:
XboxOneGameOsOverridePath:
XboxOnePackagingOverridePath:
XboxOneAppManifestOverridePath:
XboxOnePackageEncryption: 0
XboxOneDescription:
XboxOneIsContentPackage: 0
XboxOneEnableGPUVariability: 0
XboxOneSockets: {}
XboxOneSplashScreen: {fileID: 0}
XboxOneAllowedProductIds: []
XboxOnePersistentLocalStorageSize: 0
intPropertyNames:
- WebGL::ScriptingBackend
- WebGL::audioCompressionFormat
- WebGL::exceptionSupport
- WebGL::memorySize
- iOS::Architecture
- iOS::ScriptingBackend
WebGL::ScriptingBackend: 1
WebGL::audioCompressionFormat: 4
WebGL::exceptionSupport: 0
WebGL::memorySize: 256
iOS::Architecture: 2
iOS::ScriptingBackend: 0
boolPropertyNames:
- WebGL::dataCaching
WebGL::dataCaching: 0
stringPropertyNames:
- WebGL::emscriptenArgs
- WebGL::template
WebGL::emscriptenArgs:
WebGL::template: APPLICATION:Default
firstStreamedLevelWithResources: 0
unityRebuildLibraryVersion: 9
unityForwardCompatibleVersion: 39
unityStandardAssetsVersion: 0

View File

@@ -0,0 +1,2 @@
m_EditorVersion: 5.0.0f1
m_StandardAssetsVersion: 0

View File

@@ -17,7 +17,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

@@ -17,7 +17,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,9 +1,9 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/IsoTools/Scripts/IsoWorld.cs">
<Files>
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="142" Column="23" />
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="190" Column="36" />
<File FileName="Assets/IsoTools/Scripts/IsoObject.cs" Line="27" Column="4" />
<File FileName="Assets/IsoTools/Scripts/IsoWorld.cs" Line="186" Column="23" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>