mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +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 {
|
||||
@@ -47,6 +49,7 @@ public class IsoObject : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
bool _alignment = true;
|
||||
/// <summary>Auto alignment position by isometric tile size.</summary>
|
||||
public bool Alignment {
|
||||
get { return _alignment; }
|
||||
set {
|
||||
|
||||
@@ -5,8 +5,11 @@ 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 {
|
||||
@@ -29,16 +32,35 @@ public class IsoWorld : MonoBehaviour {
|
||||
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),
|
||||
@@ -46,6 +68,14 @@ public class IsoWorld : MonoBehaviour {
|
||||
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;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\IsoTools\Examples\Scripts\IsoController.cs">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\IsoTools\Scripts\IsoObject.cs">
|
||||
<Files>
|
||||
<File FileName="Assets\IsoTools\Examples\Scripts\IsoController.cs" Line="30" Column="35" />
|
||||
<File FileName="Assets\IsoTools\Scripts\IsoObject.cs" Line="18" Column="22" />
|
||||
<File FileName="Assets\IsoTools\Scripts\IsoWorld.cs" Line="14" Column="28" />
|
||||
<File FileName="Assets\IsoTools\Examples\Scripts\IsoAutoController.cs" Line="4" Column="1" />
|
||||
<File FileName="Assets\IsoTools\Scripts\IsoObject.cs" Line="137" Column="14" />
|
||||
<File FileName="Assets\IsoTools\Scripts\IsoWorld.cs" Line="67" Column="57" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
||||
Reference in New Issue
Block a user