Show grid checkbox. Show properties in inspector.

This commit is contained in:
2016-02-06 02:13:38 +06:00
parent ba482724d3
commit 244b672b23
10 changed files with 91 additions and 264898 deletions

View File

@@ -416,7 +416,7 @@ namespace IsoTools {
bool IsIsoObjectDepends(IsoObject a, IsoObject b) {
return
a.Internal.ScreenRect.Overlaps(b.Internal.ScreenRect) &&
a.Internal.ScreenRect.Overlaps(b.Internal.ScreenRect, false) &&
IsIsoObjectDepends(a.position, a.size, b.position, b.size);
}

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 221bc03dca62748f284639c0b399875b
timeCreated: 1454394623
timeCreated: 1454699157
licenseType: Free
TextureImporter:
fileIDToRecycleName:

File diff suppressed because it is too large Load Diff

View File

@@ -22,8 +22,6 @@ namespace IsoTools.Tiled.Internal {
iso_object.mode = IsoObject.Mode.Mode3d;
iso_object.position = Vector3.zero;
iso_object.size = IsoUtils.Vec3FromXY(_asset.Data.Height, _asset.Data.Width);
iso_object.isAlignment = true;
iso_object.isShowBounds = true;
var tiled_map = map_go.AddComponent<TiledMap>();
tiled_map.Asset = _asset;

View File

@@ -27,8 +27,7 @@ namespace IsoTools.Tiled.Internal {
public override void OnInspectorGUI() {
DrawDefaultInspector();
if ( _map && _map.Properties != null ) {
GUILayout.Label(string.Format(
"Property count: {0}", _map.Properties.Count));
_map.Properties.OnInspectorGUI("Map properties");
}
}
}

View File

@@ -27,8 +27,7 @@ namespace IsoTools.Tiled.Internal {
public override void OnInspectorGUI() {
DrawDefaultInspector();
if ( _layer && _layer.Properties != null ) {
GUILayout.Label(string.Format(
"Property count: {0}", _layer.Properties.Count));
_layer.Properties.OnInspectorGUI("Layer properties");
}
}
}

View File

@@ -1,5 +1,6 @@
using UnityEngine;
using NUnit.Framework;
using System;
using System.Collections.Generic;
namespace IsoTools.Tiled.Internal {
@@ -51,6 +52,31 @@ namespace IsoTools.Tiled.Internal {
[Test]
public void Test03() {
var props = new TiledMapProperties(null);
Assert.Throws<IndexOutOfRangeException>(() => {
props.GetKeyByIndex(0); });
Assert.Throws<IndexOutOfRangeException>(() => {
props.GetValueByIndex(0); });
var prop_list = new List<string>{
"prop1", "val1",
"prop2", "val2",
"prop3", "val3",
"prop4", "",
"fakep"
};
props = new TiledMapProperties(prop_list);
Assert.AreEqual(props.GetKeyByIndex (0), "prop1");
Assert.AreEqual(props.GetKeyByIndex (1), "prop2");
Assert.AreEqual(props.GetValueByIndex(0), "val1");
Assert.AreEqual(props.GetValueByIndex(1), "val2");
Assert.Throws<IndexOutOfRangeException>(() => {
props.GetKeyByIndex(-1); });
Assert.Throws<IndexOutOfRangeException>(() => {
props.GetValueByIndex(4); });
}
[Test]
public void Test04() {
var props = new TiledMapProperties(null);
bool v0;
short v1;
@@ -69,7 +95,7 @@ namespace IsoTools.Tiled.Internal {
}
[Test]
public void Test04() {
public void Test05() {
var prop_list = new List<string>{
"bool" , "true",
"short" , "64",

View File

@@ -27,8 +27,7 @@ namespace IsoTools.Tiled.Internal {
public override void OnInspectorGUI() {
DrawDefaultInspector();
if ( _tile && _tile.Properties != null ) {
GUILayout.Label(string.Format(
"Property count: {0}", _tile.Properties.Count));
_tile.Properties.OnInspectorGUI("Tileset properties");
}
}
}

View File

@@ -14,6 +14,21 @@ namespace IsoTools.Tiled {
public TiledMapAsset Asset = null;
public TiledMapProperties Properties = null;
// ---------------------------------------------------------------------
//
// For editor
//
// ---------------------------------------------------------------------
#if UNITY_EDITOR
[SerializeField] bool _isShowGrid = false;
public bool isShowGrid {
get { return _isShowGrid; }
set { _isShowGrid = value; }
}
#endif
// ---------------------------------------------------------------------
//
// Functions
@@ -45,7 +60,7 @@ namespace IsoTools.Tiled {
void OnDrawGizmos() {
var iso_object = GetComponent<IsoObject>();
if ( iso_object.isShowBounds && iso_object.isoWorld ) {
if ( isShowGrid && iso_object && iso_object.isoWorld ) {
IsoUtils.DrawGrid(
iso_object.isoWorld,
iso_object.position, iso_object.size,

View File

@@ -1,7 +1,12 @@
using UnityEngine;
using System;
using System.Globalization;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace IsoTools.Tiled {
public class TiledMapProperties {
List<string> _properties = null;
@@ -22,6 +27,20 @@ namespace IsoTools.Tiled {
}
}
public string GetKeyByIndex(int index) {
if ( (uint)index >= (uint)Count ) {
throw new IndexOutOfRangeException();
}
return _properties[index * 2];
}
public string GetValueByIndex(int index) {
if ( (uint)index >= (uint)Count ) {
throw new IndexOutOfRangeException();
}
return _properties[index * 2 + 1];
}
public bool Has(string property_name) {
if ( _properties != null ) {
for ( int i = 0, e = _properties.Count / 2; i < e; ++i ) {
@@ -175,5 +194,23 @@ namespace IsoTools.Tiled {
value = string.Empty;
return false;
}
// -----------------------------
// For editor
// -----------------------------
#if UNITY_EDITOR
bool _showProperties = true;
public void OnInspectorGUI(string label) {
if ( Count > 0 ) {
_showProperties = EditorGUILayout.Foldout(_showProperties, label);
if ( _showProperties ) {
for ( int i = 0, e = Count; i < e; ++i ) {
EditorGUILayout.LabelField(GetKeyByIndex(i), GetValueByIndex(i));
}
}
}
}
#endif
}
}