mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-15 01:12:05 +07:00
undo-redo for create tiled map and property holder
This commit is contained in:
@@ -68,6 +68,7 @@
|
|||||||
<Compile Include="Assets\IsoTools\Tiled\TiledMap.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\TiledMap.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\TiledMapAsset.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\TiledMapAsset.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\TiledMapLayer.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\TiledMapLayer.cs" />
|
||||||
|
<Compile Include="Assets\IsoTools\Tiled\TiledMapProperties.cs" />
|
||||||
<Compile Include="Assets\IsoTools\Tiled\TiledMapTile.cs" />
|
<Compile Include="Assets\IsoTools\Tiled\TiledMapTile.cs" />
|
||||||
<Reference Include="UnityEngine.UI">
|
<Reference Include="UnityEngine.UI">
|
||||||
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
|
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float ZMoveIsoObjects(float delta) {
|
float ZMoveIsoObjects(float delta) {
|
||||||
Undo.RecordObjects(_iso_zpositions.Keys.ToArray(), "Move");
|
Undo.RecordObjects(
|
||||||
|
_iso_zpositions.Keys.ToArray(),
|
||||||
|
_iso_zpositions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
||||||
var is_any_alignment = isAnyAlignment;
|
var is_any_alignment = isAnyAlignment;
|
||||||
return _iso_zpositions.Aggregate(0.0f, (AccIn, pair) => {
|
return _iso_zpositions.Aggregate(0.0f, (AccIn, pair) => {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
@@ -77,7 +79,9 @@ namespace IsoTools.Internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 XYMoveIsoObjects(Vector3 delta) {
|
Vector3 XYMoveIsoObjects(Vector3 delta) {
|
||||||
Undo.RecordObjects(_positions.Keys.ToArray(), "Move");
|
Undo.RecordObjects(
|
||||||
|
_positions.Keys.ToArray(),
|
||||||
|
_positions.Count > 1 ? "Move IsoObjects" : "Move IsoObject");
|
||||||
var is_any_alignment = isAnyAlignment;
|
var is_any_alignment = isAnyAlignment;
|
||||||
return _positions.Aggregate(Vector3.zero, (AccIn, pair) => {
|
return _positions.Aggregate(Vector3.zero, (AccIn, pair) => {
|
||||||
var iso_object = pair.Key;
|
var iso_object = pair.Key;
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ namespace IsoTools {
|
|||||||
[ExecuteInEditMode, DisallowMultipleComponent]
|
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||||
public class IsoObject : MonoBehaviour {
|
public class IsoObject : MonoBehaviour {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Mode
|
// Mode
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public enum Mode {
|
public enum Mode {
|
||||||
Mode2d,
|
Mode2d,
|
||||||
@@ -32,11 +32,11 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Size
|
// Size
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
Vector3 _size = Vector3.one;
|
Vector3 _size = Vector3.one;
|
||||||
@@ -76,11 +76,11 @@ namespace IsoTools {
|
|||||||
get { return new Vector2(sizeX, sizeZ); }
|
get { return new Vector2(sizeX, sizeZ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Position
|
// Position
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
Vector3 _position = Vector3.zero;
|
Vector3 _position = Vector3.zero;
|
||||||
@@ -120,11 +120,11 @@ namespace IsoTools {
|
|||||||
get { return new Vector2(positionX, positionZ); }
|
get { return new Vector2(positionX, positionZ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// TilePosition
|
// TilePosition
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector3 tilePosition {
|
public Vector3 tilePosition {
|
||||||
get { return IsoUtils.Vec3Round(position); }
|
get { return IsoUtils.Vec3Round(position); }
|
||||||
@@ -158,11 +158,11 @@ namespace IsoTools {
|
|||||||
get { return new Vector2(tilePositionX, tilePositionZ); }
|
get { return new Vector2(tilePositionX, tilePositionZ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Internal
|
// Internal
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public class InternalState {
|
public class InternalState {
|
||||||
public bool Dirty = false;
|
public bool Dirty = false;
|
||||||
@@ -178,11 +178,11 @@ namespace IsoTools {
|
|||||||
|
|
||||||
public InternalState Internal = new InternalState();
|
public InternalState Internal = new InternalState();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// For editor
|
// For editor
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
Vector3 _lastSize = Vector3.zero;
|
Vector3 _lastSize = Vector3.zero;
|
||||||
@@ -203,11 +203,11 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
IsoWorld _isoWorld = null;
|
IsoWorld _isoWorld = null;
|
||||||
public IsoWorld isoWorld {
|
public IsoWorld isoWorld {
|
||||||
@@ -270,11 +270,11 @@ namespace IsoTools {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
Internal.SelfDepends = new HashSet<IsoObject>(new IsoObject[47]);
|
Internal.SelfDepends = new HashSet<IsoObject>(new IsoObject[47]);
|
||||||
@@ -328,4 +328,4 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace IsoTools
|
} // namespace IsoTools
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ namespace IsoTools {
|
|||||||
Vector2 _sectorsMaxNumPos = Vector2.zero;
|
Vector2 _sectorsMaxNumPos = Vector2.zero;
|
||||||
Vector2 _sectorsNumPosCount = Vector2.zero;
|
Vector2 _sectorsNumPosCount = Vector2.zero;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Constants
|
// Constants
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public static readonly float DefTileSize = 32.0f;
|
public static readonly float DefTileSize = 32.0f;
|
||||||
public static readonly float MinTileSize = Mathf.Epsilon;
|
public static readonly float MinTileSize = Mathf.Epsilon;
|
||||||
@@ -63,11 +63,11 @@ namespace IsoTools {
|
|||||||
public static readonly float MinStartDepth = float.MinValue;
|
public static readonly float MinStartDepth = float.MinValue;
|
||||||
public static readonly float MaxStartDepth = float.MaxValue;
|
public static readonly float MaxStartDepth = float.MaxValue;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Sorting properties
|
// Sorting properties
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public float _tileSize = DefTileSize;
|
public float _tileSize = DefTileSize;
|
||||||
@@ -129,11 +129,11 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// IsoToScreen/ScreenToIso
|
// IsoToScreen/ScreenToIso
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector2 IsoToScreen(Vector3 iso_pnt) {
|
public Vector2 IsoToScreen(Vector3 iso_pnt) {
|
||||||
if ( _dirtyMat ) {
|
if ( _dirtyMat ) {
|
||||||
@@ -160,11 +160,11 @@ namespace IsoTools {
|
|||||||
iso_z);
|
iso_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// TouchIsoPosition
|
// TouchIsoPosition
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector3 TouchIsoPosition(int finger_id) {
|
public Vector3 TouchIsoPosition(int finger_id) {
|
||||||
return TouchIsoPosition(finger_id, 0.0f);
|
return TouchIsoPosition(finger_id, 0.0f);
|
||||||
@@ -199,11 +199,11 @@ namespace IsoTools {
|
|||||||
return Vector3.zero;
|
return Vector3.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// TouchIsoTilePosition
|
// TouchIsoTilePosition
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector3 TouchIsoTilePosition(int finger_id) {
|
public Vector3 TouchIsoTilePosition(int finger_id) {
|
||||||
return IsoUtils.Vec3Floor(TouchIsoPosition(finger_id));
|
return IsoUtils.Vec3Floor(TouchIsoPosition(finger_id));
|
||||||
@@ -221,11 +221,11 @@ namespace IsoTools {
|
|||||||
return IsoUtils.Vec3Floor(TouchIsoPosition(finger_id, camera, iso_z));
|
return IsoUtils.Vec3Floor(TouchIsoPosition(finger_id, camera, iso_z));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// MouseIsoPosition
|
// MouseIsoPosition
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector3 MouseIsoPosition() {
|
public Vector3 MouseIsoPosition() {
|
||||||
return MouseIsoPosition(0.0f);
|
return MouseIsoPosition(0.0f);
|
||||||
@@ -253,11 +253,11 @@ namespace IsoTools {
|
|||||||
iso_z);
|
iso_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// MouseIsoTilePosition
|
// MouseIsoTilePosition
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public Vector3 MouseIsoTilePosition() {
|
public Vector3 MouseIsoTilePosition() {
|
||||||
return IsoUtils.Vec3Floor(MouseIsoPosition());
|
return IsoUtils.Vec3Floor(MouseIsoPosition());
|
||||||
@@ -275,11 +275,11 @@ namespace IsoTools {
|
|||||||
return IsoUtils.Vec3Floor(MouseIsoPosition(camera, iso_z));
|
return IsoUtils.Vec3Floor(MouseIsoPosition(camera, iso_z));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Internal
|
// Internal
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
public void MarkDirty() {
|
public void MarkDirty() {
|
||||||
if ( !_dirty ) {
|
if ( !_dirty ) {
|
||||||
@@ -308,11 +308,11 @@ namespace IsoTools {
|
|||||||
_oldVisibles.Remove(iso_object);
|
_oldVisibles.Remove(iso_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Private
|
// Private
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
void MarkDirtyIsoMatrix() {
|
void MarkDirtyIsoMatrix() {
|
||||||
_dirtyMat = true;
|
_dirtyMat = true;
|
||||||
@@ -634,11 +634,11 @@ namespace IsoTools {
|
|||||||
trans.position = IsoUtils.Vec3ChangeZ(trans.position, depth);
|
trans.position = IsoUtils.Vec3ChangeZ(trans.position, depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
ChangeSortingProperty();
|
ChangeSortingProperty();
|
||||||
@@ -689,4 +689,4 @@ namespace IsoTools {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace IsoTools
|
} // namespace IsoTools
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ Camera:
|
|||||||
far clip plane: 1000
|
far clip plane: 1000
|
||||||
field of view: 60
|
field of view: 60
|
||||||
orthographic: 1
|
orthographic: 1
|
||||||
orthographic size: 3
|
orthographic size: 6
|
||||||
m_Depth: -1
|
m_Depth: -1
|
||||||
m_CullingMask:
|
m_CullingMask:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ namespace IsoTools.Tiled.Internal {
|
|||||||
Debug.LogErrorFormat("Create tiled map error: {0}", e.Message);
|
Debug.LogErrorFormat("Create tiled map error: {0}", e.Message);
|
||||||
DestroyImmediate(map_go, true);
|
DestroyImmediate(map_go, true);
|
||||||
}
|
}
|
||||||
|
Undo.RegisterCreatedObjectUndo(map_go, "Create TiledMap");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,17 +13,18 @@ namespace IsoTools.Tiled {
|
|||||||
|
|
||||||
public TiledMapAsset Asset = null;
|
public TiledMapAsset Asset = null;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Messages
|
// Messages
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
}
|
}
|
||||||
@@ -55,4 +56,4 @@ namespace IsoTools.Tiled {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace IsoTools.Tiled
|
} // namespace IsoTools.Tiled
|
||||||
|
|||||||
171
Assets/IsoTools/Tiled/TiledMapProperties.cs
Normal file
171
Assets/IsoTools/Tiled/TiledMapProperties.cs
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace IsoTools.Tiled {
|
||||||
|
public class TiledMapProperties {
|
||||||
|
List<string> _properties = null;
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// Functions
|
||||||
|
// -----------------------------
|
||||||
|
|
||||||
|
public TiledMapProperties(List<string> properties) {
|
||||||
|
_properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Has(string property_name) {
|
||||||
|
if ( _properties != null ) {
|
||||||
|
for ( var i = 0; i < _properties.Count / 2; ++i ) {
|
||||||
|
if ( _properties[i * 2] == property_name ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// GetAsX
|
||||||
|
// -----------------------------
|
||||||
|
|
||||||
|
public bool GetAsBool(string property_name) {
|
||||||
|
bool value;
|
||||||
|
if ( TryGetAsBool(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public short GetAsShort(string property_name) {
|
||||||
|
short value;
|
||||||
|
if ( TryGetAsShort(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetAsInt(string property_name) {
|
||||||
|
int value;
|
||||||
|
if ( TryGetAsInt(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public long GetAsLong(string property_name) {
|
||||||
|
long value;
|
||||||
|
if ( TryGetAsLong(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetAsFloat(string property_name) {
|
||||||
|
float value;
|
||||||
|
if ( TryGetAsFloat(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetAsDouble(string property_name) {
|
||||||
|
double value;
|
||||||
|
if ( TryGetAsDouble(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetAsString(string property_name) {
|
||||||
|
string value;
|
||||||
|
if ( TryGetAsString(property_name, out value) ) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
throw new UnityException("find or parse parameter error");
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
// TryGetAsX
|
||||||
|
// -----------------------------
|
||||||
|
|
||||||
|
public bool TryGetAsBool(string property_name, out bool value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( bool.TryParse(property_value, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsShort(string property_name, out short value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( short.TryParse(property_value, NumberStyles.Any, CultureInfo.InvariantCulture, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsInt(string property_name, out int value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( int.TryParse(property_value, NumberStyles.Any, CultureInfo.InvariantCulture, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsLong(string property_name, out long value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( long.TryParse(property_value, NumberStyles.Any, CultureInfo.InvariantCulture, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsFloat(string property_name, out float value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( float.TryParse(property_value, NumberStyles.Any, CultureInfo.InvariantCulture, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsDouble(string property_name, out double value) {
|
||||||
|
string property_value;
|
||||||
|
if ( TryGetAsString(property_name, out property_value) ) {
|
||||||
|
if ( double.TryParse(property_value, NumberStyles.Any, CultureInfo.InvariantCulture, out value) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetAsString(string property_name, out string value) {
|
||||||
|
if ( _properties != null ) {
|
||||||
|
for ( var i = 0; i < _properties.Count / 2; ++i ) {
|
||||||
|
if ( _properties[i * 2] == property_name ) {
|
||||||
|
value = _properties[i * 2 + 1];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = string.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace IsoTools.Tiled
|
||||||
12
Assets/IsoTools/Tiled/TiledMapProperties.cs.meta
Normal file
12
Assets/IsoTools/Tiled/TiledMapProperties.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fa7b674b7f7ae4c11a2df9172b4020ba
|
||||||
|
timeCreated: 1454346480
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user