mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-16 14:09:00 +07:00
add function comments
This commit is contained in:
@@ -11,6 +11,7 @@ public class IsoObject : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
Vector3 _position = Vector3.zero;
|
||||
/// <summary>Isometric object position.</summary>
|
||||
public Vector3 Position {
|
||||
get { return _position; }
|
||||
set {
|
||||
@@ -29,6 +30,7 @@ public class IsoObject : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
Vector3 _size = Vector3.one;
|
||||
/// <summary>Isometric object size.</summary>
|
||||
public Vector3 Size {
|
||||
get { return _size; }
|
||||
set {
|
||||
@@ -46,7 +48,8 @@ public class IsoObject : MonoBehaviour {
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
bool _alignment = true;
|
||||
bool _alignment = true;
|
||||
/// <summary>Auto alignment position by isometric tile size.</summary>
|
||||
public bool Alignment {
|
||||
get { return _alignment; }
|
||||
set {
|
||||
|
||||
@@ -4,9 +4,12 @@ using System.Collections.Generic;
|
||||
namespace IsoTools {
|
||||
[ExecuteInEditMode]
|
||||
public class IsoWorld : MonoBehaviour {
|
||||
|
||||
|
||||
/// <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 {
|
||||
@@ -28,24 +31,51 @@ public class IsoWorld : MonoBehaviour {
|
||||
List<int> _depends = new List<int>();
|
||||
List<ObjectInfo> _objects = new List<ObjectInfo>();
|
||||
float _lastTileSize = 0.0f;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/// <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) {
|
||||
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),
|
||||
(pos.y - pos.x * 0.5f),
|
||||
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) {
|
||||
var iso_pos = ScreenToIso(new Vector2(pos.x, pos.y - iso_z * TileSize));
|
||||
iso_pos.z = iso_z;
|
||||
|
||||
Reference in New Issue
Block a user