remove dev stuff
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
* Isometric 2.5D Toolset
|
||||
** Планы
|
||||
**** Общее
|
||||
***** Документация с гифками по каждой фиче в блоге
|
||||
***** Что-то придумать с иконкой
|
||||
***** Подумать над Hexagonal grid!
|
||||
***** Подумать на тему лестниц и IsoMeshCollider
|
||||
***** Подумать на тему IsoHeightmap
|
||||
**** Код
|
||||
***** Система чанков
|
||||
***** Структура карты с поиском путей в ней
|
||||
Возможно некий GridMap с настройками, который будет парентом изо-объектов
|
||||
***** Декали на тайлах (тени и прочее)
|
||||
***** Главная плашка тулзы с ссылками на форумы, сайт, доку и просилку рейтинга там же
|
||||
***** Добавить parent-children возможность в изометрические координаты
|
||||
***** Нужно что-то придумать с аллокациями на события IsoCollision и прочие физические преобразования
|
||||
***** Поддержка коллайдеров как чаилдов
|
||||
***** Добавить поддержку каких-нить твиннов?
|
||||
**** Баги
|
||||
***** Есть проблема с порядком тайлов в Tiled карте при нескольких таилсетах
|
||||
***** Реимпорт Tiled карты ломает эти тайловые карты на сцене
|
||||
***** Debug mode в инспекторе ломает сортировку и изометрический редактор
|
||||
** Версия X.X.X
|
||||
*** Код
|
||||
**** Сэмпл полурогалика
|
||||
**** Подумать на тему статических объектов
|
||||
**** Рисовать баунды разными цветами, дабы было понятно где верх, где низ
|
||||
*** Баги
|
||||
**** При перемещении камеры тайлы по краям дергаются в сортировке
|
||||
**** В ретино-версии юнити сломались гизмы
|
||||
**** Когда IsoObject двигается в сцене сам, то при выделении редактором всё глючит
|
||||
**** Тормозит редактирование кучи объектов или парентов
|
||||
** TODO Версия 3.1.0
|
||||
*** Код
|
||||
**** TODO Поддержка TiledMap
|
||||
**** TODO Возможность вывода баунда только для текущего объекта
|
||||
**** TODO Подсвечивать проникающие друг-в-друга объекты в редакторе
|
||||
**** TODO Возможность невидимых изометрических объектов без сортировки
|
||||
**** TODO Добавить ворнинг на использование IsoObject в качестве парента
|
||||
**** TODO Добавить возможность брать объект по позиции мыши без райкаста
|
||||
**** TODO Добавить скрипт камеры для слежения за изометрическим объектом
|
||||
**** TODO Возможность задавать плоскость проекции изометрических координат
|
||||
**** TODO Было бы удобно иметь кнопку по округлению индексов позиции тайлов
|
||||
**** TODO Повороты коллайдеров (Nick Temple)
|
||||
** DONE Версия 3.0.4
|
||||
*** Баги
|
||||
**** DONE После Undo в редакторе исчезают объекты на сцене
|
||||
проблема была в неверном bounds из ParticleSystemRenderer
|
||||
** DONE Версия 3.0.3
|
||||
*** Код
|
||||
**** DONE Не рисовать gizmos вне камеры
|
||||
**** DONE Пофиксить новые ворнинги до 2017.3
|
||||
**** DONE Не снаппить по изо чаелдам
|
||||
** DONE Версия 3.0.2
|
||||
*** Код
|
||||
**** DONE Вынести настройки физики в IsoWorld
|
||||
** DONE Версия 3.0.1
|
||||
*** Баги
|
||||
**** DONE Проблемы с сериализацией дженерик классов
|
||||
** DONE Версия 3.0.0
|
||||
*** Общее
|
||||
**** DONE Сделать страничку на сайте в новом стиле
|
||||
*** Код
|
||||
**** DONE Возможность нескольких миров на одной сцене
|
||||
**** DONE Причесать папки и их структуру
|
||||
**** DONE Сделать не изометрический пример
|
||||
http://www.dragosha.com/free/adventure-tileset.html
|
||||
**** DONE Переделать определение видимости для объектов на QuadTree
|
||||
**** DONE Размер SnapDistance вынести в настройки IsoWorld
|
||||
*** Баги
|
||||
**** DONE Unity 5.4 (useLightProbes property is deprecated. Use lightProbeUsage instead)
|
||||
**** DONE Удаление на ходу закешенего рендерера приводит к ошибке
|
||||
**** DONE Первый кадр на тяжелой сцене невероятно медленный, надо разобраться
|
||||
**** DONE При изменении трансформа IsoObject, нужно выдавать ошибку, что так делать не стоит
|
||||
**** DONE При случайном удалении камеры вместе с IsoWorld - происходят невнятные ошибки
|
||||
**** DONE При изменении позиции Transform из инспектора почему-то нет Undo
|
||||
Нельзя менять трансформ, он возвращается назад
|
||||
** DONE Версия 2.4.2
|
||||
*** Код
|
||||
**** DONE Добавить IsoSnappingParent со снаппингом при перемещении
|
||||
*** Баги
|
||||
**** DONE Не разделяются разные слои в Tiled карте по Z
|
||||
** DONE Версия 2.4.1
|
||||
*** Баги
|
||||
**** DONE Ошибка с оффсетом тайлов в Tiled.
|
||||
http://forum.unity3d.com/threads/v2-4-isometric-2-5d-toolset.291418/page-4#post-2694244
|
||||
** DONE Версия 2.4
|
||||
*** Общее
|
||||
**** DONE Написать в доке про Capsule Collider
|
||||
**** DONE Написать в доке про райкаст
|
||||
**** DONE README.txt
|
||||
**** DONE CHANGELOG.txt
|
||||
*** Код
|
||||
**** DONE Physics raycast
|
||||
**** DONE Прилипание к краям соседних объектов (snapping)
|
||||
**** DONE Коллайлер в виде цилиндра
|
||||
**** DONE Добавить возможность подвижных парентов
|
||||
*** Баги
|
||||
**** DONE Объекты с парентами и выравниванием глючат при таскании в редакторе
|
||||
**** DONE Первый кадр игры в редакторе почему-то не сортированный
|
||||
Только в редакторе судя по всему
|
||||
** DONE Версия 2.3.2
|
||||
*** Общее
|
||||
**** DONE Написать в описании, что все исходники в комплекте
|
||||
**** DONE Написать в описании что бы рейтили
|
||||
P.S. Leave your rating for this Asset. It is very important for me and the development of the project :) Thank you!
|
||||
**** DONE Обновить доку по событиям физики
|
||||
*** Баги
|
||||
**** DONE Не сохраняются префабы тайловой карты из-за материалов
|
||||
**** DONE DontDestroyOnLoad не работает с изометрической физикой
|
||||
**** DONE Layer Collision Matrix не работает
|
||||
**** DONE Почему-то в ивентах о коллизиях пустой gameObject когда нет rigidbody
|
||||
**** DONE Не удаляется FakeObject, когда он уже не нужен
|
||||
*** Код
|
||||
**** DONE Оптимизировать "IsIsoObjectVisible", ибо очень медленно на ios
|
||||
Теперь есть новый флажок 'cacheRenderers'
|
||||
**** DONE Сделать IsoWorld синглтоном
|
||||
**** DONE Оптимизировать отправку сообщений о коллизиях и тригерах
|
||||
***** DONE Попрофайлить события физики
|
||||
***** DONE Возможность выключать события для скорости
|
||||
IsoTriggerListener && IsoCollisionListener
|
||||
** DONE Версия 2.3.1
|
||||
*** Баги
|
||||
**** DONE OOM зафиксить для секторов
|
||||
** DONE Версия 2.3
|
||||
*** Код
|
||||
**** DONE Поддержка Tiled
|
||||
*** Баги
|
||||
**** DONE При выделении префаба с IsoObject объекты начинают пересортировываться
|
||||
** DONE Версия 2.2
|
||||
*** Общее
|
||||
**** DONE Дописать в доку инфу о событиях триггеров и коллизий
|
||||
**** DONE Доку поправить на новый код (фингер айди)
|
||||
**** DONE В Release Notes написать нормальную историю версий
|
||||
**** DONE Теги проставить для ассета
|
||||
*** Баги
|
||||
**** DONE Поправить код под VS 2013
|
||||
http://www.gamedev.ru/messages/?rec=60563
|
||||
**** DONE Сектора идут всегда с нуля, неважно на сколько удалён от центра координат объект
|
||||
*** Код
|
||||
**** DONE Интеграция с Playmaker
|
||||
**** DONE Внутренние классы и функции засунуть подальше в Internal
|
||||
**** DONE Тач индексы на фингер айди переделать
|
||||
** DONE Версия 2.1
|
||||
*** Код
|
||||
**** DONE Доступ к объектам, которые перекрывают заданный
|
||||
**** DONE Полезные функции для работы с мышкой
|
||||
**** DONE Добавить возможность тайлов не в прямой изометрии
|
||||
**** DONE Сделать флажок выключения сортировки
|
||||
Enable/Disable
|
||||
**** DONE Провернуть идею того, что не нужно каждый раз пересчитывать депенсы для объектов
|
||||
**** DONE 2d тайлы с 3d персонажами (микс 2д и 3д)
|
||||
*** Баги
|
||||
**** DONE Во вкладке Game несортированные объекты попадают, которые не в камере редактора
|
||||
**** DONE Префабы почему-то постоянно меняются объектов
|
||||
**** DONE При смене камеры (Game/Editor) нужно пересортировывать
|
||||
** DONE Версия 2.0
|
||||
*** Общее
|
||||
**** DONE Вставить вменяемые спрайты для сэмплов и скриншотов
|
||||
**** DONE Web-demo сделать
|
||||
*** Код
|
||||
**** DONE Добавить физику
|
||||
*** Редактор
|
||||
**** DONE Кастомные стрелки gizmos
|
||||
http://docs.unity3d.com/ScriptReference/Handles.Slider.html
|
||||
**** DONE Сделать общее выравнивание, а не пообъектное
|
||||
**** DONE Рисовать дебажную информацию в редакторе
|
||||
***** DONE BB для физики и размеров
|
||||
*** Баги
|
||||
**** DONE Не пересортировывается мир, когда в редакторе двигаешь объекты, так как думает, что они не видимые в главную камеру
|
||||
** DONE Начальная версия
|
||||
*** Игра
|
||||
**** DONE Топологическая сортировка одноклеточной изометрии
|
||||
**** DONE Сортировка многоклеточной изометрии
|
||||
**** DONE Корректная сортировка с учетом высоты и этажности
|
||||
**** DONE Зарешать проблемы с тайлами пола (размер по Z = 0)
|
||||
**** DONE Разные виды изометрии
|
||||
*** Редактор
|
||||
**** DONE Расставление предметов в редакторе по клеточкам
|
||||
**** DONE Корректная сортировка в редакторе
|
||||
**** DONE Визуальное отображение в редакторе клеток изометрии, центров и т.д
|
||||
*** Оптимизации
|
||||
**** DONE Сортировать только когда что-то изменилось, либо только тех, кого это касается
|
||||
**** DONE Придумать как можно не сортировать то, что за экраном
|
||||
**** DONE Придумать как применить какой-нить куад-трии
|
||||
*** Баги
|
||||
**** DONE Автоматически не выравнивается объект, когда ставится галочка выравнивания
|
||||
*** Прочее
|
||||
**** DONE Найти арт для демо
|
||||
**** DONE Написать описание для ассет-стора
|
||||
**** DONE Снять видео использования
|
||||
**** DONE Всякие неймспейсы, финальные названия функций, комменты
|
||||
**** DONE Описание плагина составить
|
||||
**** DONE Доку написать на функции
|
||||
**** DONE Составить описание меня, как паблишера
|
||||
*** Мелочи
|
||||
**** DONE FindObjectsOfType медленный
|
||||
**** DONE Проверить многоклеточные вертикальные объекты
|
||||
**** DONE Проверить вложенные префабы
|
||||
**** DONE Разобраться с подменой IsoWorld
|
||||
**** DONE Координаты перепутаны
|
||||
**** DONE По флагу выравнивания, выравнивать только в редакторе
|
||||
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 305 KiB |
|
Before Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 386 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 496 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 52 KiB |
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cba32081dae94248987da65f874c467
|
||||
folderAsset: yes
|
||||
timeCreated: 1477130201
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4af79c76da8fe4ee1b2a0cd711fb04a4
|
||||
folderAsset: yes
|
||||
timeCreated: 1453217672
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e14fd592ac9a4690a5b6a34edb31898
|
||||
folderAsset: yes
|
||||
timeCreated: 1453182090
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,127 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEditor;
|
||||
using IsoTools.Internal;
|
||||
using System;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
[CustomEditor(typeof(TiledMapAsset))]
|
||||
class TiledMapAssetEditor : Editor {
|
||||
TiledMapAsset _asset = null;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Functions
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void CreateTiledMapOnScene() {
|
||||
var map_go = new GameObject(_asset.Name);
|
||||
try {
|
||||
CreateTiledMap(map_go);
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat("Create tiled map error: {0}", e.Message);
|
||||
DestroyImmediate(map_go, true);
|
||||
}
|
||||
Undo.RegisterCreatedObjectUndo(map_go, "Create Tiled Map");
|
||||
}
|
||||
|
||||
void CreateTiledMap(GameObject map_go) {
|
||||
var map_data = _asset.Data;
|
||||
|
||||
var iso_object = map_go.AddComponent<IsoObject>();
|
||||
iso_object.renderersMode = IsoObject.RenderersMode.Mode3d;
|
||||
iso_object.position = Vector3.zero;
|
||||
iso_object.size = IsoUtils.Vec3FromXY(map_data.Height, map_data.Width);
|
||||
|
||||
var tiled_map = map_go.AddComponent<TiledMap>();
|
||||
tiled_map.Asset = _asset;
|
||||
tiled_map.Properties = new TiledMapProperties(map_data.Properties);
|
||||
for ( int i = map_data.Layers.Count - 1; i >= 0; --i ) {
|
||||
CreateTiledLayer(tiled_map, i);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateTiledLayer(TiledMap map, int layer_index) {
|
||||
var layer_data = _asset.Data.Layers[layer_index];
|
||||
|
||||
var layer_go = new GameObject(layer_data.Name);
|
||||
layer_go.transform.SetParent(map.transform, false);
|
||||
layer_go.transform.localPosition = IsoUtils.Vec3FromXY(
|
||||
layer_data.OffsetX / _asset.PixelsPerUnit,
|
||||
-layer_data.OffsetY / _asset.PixelsPerUnit);
|
||||
layer_go.transform.localPosition = IsoUtils.Vec3ChangeZ(
|
||||
layer_go.transform.localPosition, - layer_index * _asset.LayersDepthStep);
|
||||
layer_go.SetActive(layer_data.Visible);
|
||||
|
||||
var tiled_layer = layer_go.AddComponent<TiledMapLayer>();
|
||||
tiled_layer.Asset = _asset;
|
||||
tiled_layer.Properties = new TiledMapProperties(layer_data.Properties);
|
||||
for ( int i = 0, e = _asset.Data.Tilesets.Count; i < e; ++i ) {
|
||||
CreateTiledTileset(tiled_layer, layer_index, i);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateTiledTileset(TiledMapLayer layer, int layer_index, int tileset_index) {
|
||||
var tileset_data = _asset.Data.Tilesets[tileset_index];
|
||||
|
||||
var tileset_go = new GameObject(tileset_data.Name);
|
||||
tileset_go.transform.SetParent(layer.transform, false);
|
||||
|
||||
var tiled_tileset = tileset_go.AddComponent<TiledMapTileset>();
|
||||
tiled_tileset.Asset = _asset;
|
||||
tiled_tileset.Properties = new TiledMapProperties(tileset_data.Properties);
|
||||
CreateTiledTilesetMesh(tiled_tileset, tileset_index, layer_index);
|
||||
}
|
||||
|
||||
void CreateTiledTilesetMesh(TiledMapTileset tileset, int tileset_index, int layer_index) {
|
||||
var mesh_filter = tileset.gameObject.AddComponent<MeshFilter>();
|
||||
mesh_filter.mesh = GetTilesetMesh(tileset_index, layer_index);
|
||||
var mesh_renderer = tileset.gameObject.AddComponent<MeshRenderer>();
|
||||
mesh_renderer.sharedMaterial = GetTilesetMaterial(tileset_index);
|
||||
}
|
||||
|
||||
Mesh GetTilesetMesh(int tileset_index, int layer_index) {
|
||||
var mesh_name = string.Format("mesh_{0}_{1}", tileset_index, layer_index);
|
||||
var subassets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_asset));
|
||||
foreach ( var subasset in subassets ) {
|
||||
if ( subasset.name == mesh_name && subasset is Mesh ) {
|
||||
return subasset as Mesh;
|
||||
}
|
||||
}
|
||||
throw new UnityException(string.Format(
|
||||
"not found tileset mesh ({0})",
|
||||
mesh_name));
|
||||
}
|
||||
|
||||
Material GetTilesetMaterial(int tileset_index) {
|
||||
var material_name = string.Format("material_{0}", tileset_index);
|
||||
var subassets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_asset));
|
||||
foreach ( var subasset in subassets ) {
|
||||
if ( subasset.name == material_name && subasset is Material ) {
|
||||
return subasset as Material;
|
||||
}
|
||||
}
|
||||
throw new UnityException(string.Format(
|
||||
"not found tileset material ({0})",
|
||||
material_name));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void OnEnable() {
|
||||
_asset = target as TiledMapAsset;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( GUILayout.Button("Create tiled map on scene") ) {
|
||||
CreateTiledMapOnScene();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1612079295b4947b58adc4bb6585b7dd
|
||||
timeCreated: 1453182090
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,184 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using IsoTools.Internal;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
public class TiledMapAssetPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets, string[] deleted_assets,
|
||||
string[] moved_assets, string[] moved_from_asset_paths)
|
||||
{
|
||||
var asset_paths = imported_assets
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
|
||||
foreach ( var asset_path in asset_paths ) {
|
||||
var asset = AssetDatabase.LoadAssetAtPath<TiledMapAsset>(asset_path);
|
||||
if ( asset ) {
|
||||
TiledMapAssetProcess(asset_path, asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TiledMapAssetProcess(string asset_path, TiledMapAsset asset) {
|
||||
try {
|
||||
GenerateLayerMeshes(asset);
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat(
|
||||
"Postprocess tiled map asset error: {0}",
|
||||
e.Message);
|
||||
AssetDatabase.DeleteAsset(asset_path);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateLayerMeshes(TiledMapAsset asset) {
|
||||
var dirty = false;
|
||||
for ( int i = 0; i < asset.Data.Layers.Count; ++i ) {
|
||||
for ( int j = 0; j < asset.Data.Tilesets.Count; ++j ) {
|
||||
var mesh_name = string.Format("mesh_{0}_{1}", j, i);
|
||||
if ( !HasSubAsset(asset, mesh_name) ) {
|
||||
var mesh = GenerateTilesetMesh(asset, j, i);
|
||||
mesh.name = mesh_name;
|
||||
AssetDatabase.AddObjectToAsset(mesh, asset);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( int j = 0; j < asset.Data.Tilesets.Count; ++j ) {
|
||||
var material_name = string.Format("material_{0}", j);
|
||||
if ( !HasSubAsset(asset, material_name) ) {
|
||||
var material = GenerateTilesetMaterial(asset, j);
|
||||
material.name = material_name;
|
||||
AssetDatabase.AddObjectToAsset(material, asset);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
if ( dirty ) {
|
||||
EditorUtility.SetDirty(asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
static bool HasSubAsset(TiledMapAsset asset, string subasset_name) {
|
||||
var subassets = AssetDatabase.LoadAllAssetsAtPath(
|
||||
AssetDatabase.GetAssetPath(asset));
|
||||
return subassets.Any(p => p.name == subasset_name);
|
||||
}
|
||||
|
||||
static Mesh GenerateTilesetMesh(TiledMapAsset asset, int tileset_index, int layer_index) {
|
||||
var vertices = new List<Vector3>();
|
||||
var triangles = new List<int>();
|
||||
var uvs = new List<Vector2>();
|
||||
for ( var tile_y = 0; tile_y < asset.Data.Height; ++tile_y ) {
|
||||
for ( var tile_x = 0; tile_x < asset.Data.Width; ++tile_x ) {
|
||||
var tile_gid = asset.Data
|
||||
.Layers[layer_index]
|
||||
.Tiles[tile_y * asset.Data.Width + tile_x];
|
||||
if ( tile_gid > 0 && CheckTileGidByTileset(asset, tile_gid, tileset_index) ) {
|
||||
var tile_iso_pos = new Vector2(
|
||||
-tile_y + asset.Data.Height - 1,
|
||||
-tile_x + asset.Data.Width - 1);
|
||||
|
||||
var tile_screen_pos = TiledIsoToScreen(asset, tile_iso_pos);
|
||||
var tile_sprite = GetTileSprite(asset, tile_gid, tileset_index);
|
||||
var tile_width = tile_sprite.rect.width / asset.PixelsPerUnit;
|
||||
var tile_height = tile_sprite.rect.height / asset.PixelsPerUnit;
|
||||
var tileset_data = asset.Data.Tilesets[tileset_index];
|
||||
var tileset_offset_x = tileset_data.TileOffsetX / asset.PixelsPerUnit;
|
||||
var tileset_offset_y = (tileset_data.TileHeight * 0.5f - tileset_data.TileOffsetY) / asset.PixelsPerUnit;
|
||||
|
||||
var vertex_pos =
|
||||
IsoUtils.Vec3FromVec2(tile_screen_pos) -
|
||||
IsoUtils.Vec3FromXY(tile_width, tile_height) * 0.5f +
|
||||
IsoUtils.Vec3FromXY(tileset_offset_x, tileset_offset_y);
|
||||
|
||||
vertices.Add(vertex_pos);
|
||||
vertices.Add(vertex_pos + IsoUtils.Vec3FromX (tile_width));
|
||||
vertices.Add(vertex_pos + IsoUtils.Vec3FromXY(tile_width, tile_height));
|
||||
vertices.Add(vertex_pos + IsoUtils.Vec3FromY (tile_height));
|
||||
|
||||
triangles.Add(vertices.Count - 4 + 2);
|
||||
triangles.Add(vertices.Count - 4 + 1);
|
||||
triangles.Add(vertices.Count - 4 + 0);
|
||||
triangles.Add(vertices.Count - 4 + 0);
|
||||
triangles.Add(vertices.Count - 4 + 3);
|
||||
triangles.Add(vertices.Count - 4 + 2);
|
||||
|
||||
var tex_size = new Vector2(tile_sprite.texture.width, tile_sprite.texture.height);
|
||||
uvs.Add(new Vector2(tile_sprite.rect.xMin / tex_size.x, tile_sprite.rect.yMin / tex_size.y));
|
||||
uvs.Add(new Vector2(tile_sprite.rect.xMax / tex_size.x, tile_sprite.rect.yMin / tex_size.y));
|
||||
uvs.Add(new Vector2(tile_sprite.rect.xMax / tex_size.x, tile_sprite.rect.yMax / tex_size.y));
|
||||
uvs.Add(new Vector2(tile_sprite.rect.xMin / tex_size.x, tile_sprite.rect.yMax / tex_size.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
var mesh = new Mesh();
|
||||
mesh.vertices = vertices.ToArray();
|
||||
mesh.triangles = triangles.ToArray();
|
||||
mesh.uv = uvs.ToArray();
|
||||
mesh.RecalculateNormals();
|
||||
return mesh;
|
||||
}
|
||||
|
||||
static Material GenerateTilesetMaterial(TiledMapAsset asset, int tileset_index) {
|
||||
var shader = Shader.Find("Sprites/Default");
|
||||
if ( !shader ) {
|
||||
throw new UnityException("'Sprites/Default' shader not found");
|
||||
}
|
||||
var material = new Material(shader);
|
||||
material.SetTexture("_MainTex", GetTilesetTexture(asset, tileset_index));
|
||||
return material;
|
||||
}
|
||||
|
||||
static Vector2 TiledIsoToScreen(TiledMapAsset asset, Vector2 iso_pnt) {
|
||||
return new Vector2(
|
||||
(iso_pnt.x - iso_pnt.y) * asset.Data.TileWidth * 0.5f / asset.PixelsPerUnit,
|
||||
(iso_pnt.x + iso_pnt.y) * asset.Data.TileHeight * 0.5f / asset.PixelsPerUnit);
|
||||
}
|
||||
|
||||
static bool CheckTileGidByTileset(TiledMapAsset asset, int tile_gid, int tileset_index) {
|
||||
var tileset_data = asset.Data.Tilesets[tileset_index];
|
||||
return
|
||||
tile_gid >= tileset_data.FirstGid &&
|
||||
tile_gid < tileset_data.FirstGid + tileset_data.TileCount;
|
||||
}
|
||||
|
||||
static Sprite GetTileSprite(TiledMapAsset asset, int tile_gid, int tileset_index) {
|
||||
var tileset_data = asset.Data.Tilesets[tileset_index];
|
||||
var tile_sprite_name = string.Format(
|
||||
"{0}_{1}",
|
||||
Path.GetFileNameWithoutExtension(tileset_data.ImageSource),
|
||||
tile_gid);
|
||||
var tileset_assets = AssetDatabase.LoadAllAssetsAtPath(Path.Combine(
|
||||
Path.GetDirectoryName(AssetDatabase.GetAssetPath(asset)),
|
||||
tileset_data.ImageSource));
|
||||
var tile_sprite = tileset_assets
|
||||
.Where(p => p is Sprite && p.name == tile_sprite_name)
|
||||
.Select(p => p as Sprite)
|
||||
.FirstOrDefault();
|
||||
if ( !tile_sprite ) {
|
||||
throw new UnityException(string.Format(
|
||||
"sprite ({0}) for tile ({1}) not found",
|
||||
tile_sprite_name, tile_gid));
|
||||
}
|
||||
return tile_sprite;
|
||||
}
|
||||
|
||||
static Texture2D GetTilesetTexture(TiledMapAsset asset, int tileset_index) {
|
||||
var tileset_data = asset.Data.Tilesets[tileset_index];
|
||||
var tileset_texture_path = Path.Combine(
|
||||
Path.GetDirectoryName(AssetDatabase.GetAssetPath(asset)),
|
||||
tileset_data.ImageSource);
|
||||
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(tileset_texture_path);
|
||||
if ( !texture ) {
|
||||
throw new UnityException(string.Format(
|
||||
"texture ({0}) for tileset ({1}) not found",
|
||||
tileset_texture_path, tileset_index));
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0efb791828e36460381a0cb252b3fca5
|
||||
timeCreated: 1461077920
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
[CustomEditor(typeof(TiledMap)), CanEditMultipleObjects]
|
||||
class TiledMapMapEditor : Editor {
|
||||
TiledMap _map = null;
|
||||
|
||||
void OnEnable() {
|
||||
_map = target as TiledMap;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( _map && _map.Properties != null ) {
|
||||
_map.Properties.OnInspectorGUI("Map properties");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4fe69d04227f4d48adc05234d7a49f3
|
||||
timeCreated: 1454357848
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
[CustomEditor(typeof(TiledMapLayer)), CanEditMultipleObjects]
|
||||
class TiledMapLayerEditor : Editor {
|
||||
TiledMapLayer _layer = null;
|
||||
|
||||
void OnEnable() {
|
||||
_layer = target as TiledMapLayer;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( _layer && _layer.Properties != null ) {
|
||||
_layer.Properties.OnInspectorGUI("Layer properties");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae52a145971b34ce58548f7d0a1be41b
|
||||
timeCreated: 1454357699
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,223 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
class TiledMapPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets, string[] deleted_assets,
|
||||
string[] moved_assets, string[] moved_from_asset_paths)
|
||||
{
|
||||
var tmx_assets = imported_assets
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".tmx"));
|
||||
foreach ( var tmx_asset in tmx_assets ) {
|
||||
TmxAssetProcess(tmx_asset);
|
||||
}
|
||||
}
|
||||
|
||||
static void TmxAssetProcess(string tmx_asset) {
|
||||
var tile_map_data = LoadTiledMapFromTmxFile(tmx_asset);
|
||||
if ( tile_map_data != null ) {
|
||||
var new_asset_path = Path.ChangeExtension(tmx_asset, ".asset");
|
||||
var new_asset = AssetDatabase.LoadAssetAtPath<TiledMapAsset>(new_asset_path);
|
||||
if ( !new_asset ) {
|
||||
new_asset = ScriptableObject.CreateInstance<TiledMapAsset>();
|
||||
AssetDatabase.CreateAsset(new_asset, new_asset_path);
|
||||
}
|
||||
new_asset.Data = tile_map_data;
|
||||
new_asset.Name = Path.GetFileNameWithoutExtension(new_asset_path);
|
||||
RemoveAllSubAsset(new_asset_path);
|
||||
EditorUtility.SetDirty(new_asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
static TiledMapData LoadTiledMapFromTmxFile(string tmx_path) {
|
||||
try {
|
||||
var tmx_root_elem = XDocument.Load(tmx_path).Document.Root;
|
||||
var tiled_map_data = new TiledMapData();
|
||||
LoadTiledMapOptsFromTmxRootElem(tmx_root_elem, tiled_map_data);
|
||||
LoadTiledMapLayersFromTmxRootElem(tmx_root_elem, tiled_map_data);
|
||||
LoadTiledMapTilesetsFromTmxRootElem(tmx_root_elem, tiled_map_data);
|
||||
LoadTiledMapTilesetsTextures(tmx_path, tiled_map_data);
|
||||
return tiled_map_data;
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat("Parsing TMX file error: {0}", e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadTiledMapOptsFromTmxRootElem(XElement root_elem, TiledMapData data) {
|
||||
data.Width = SafeLoadIntFromElemAttr(root_elem, "width" , data.Width);
|
||||
data.Height = SafeLoadIntFromElemAttr(root_elem, "height" , data.Height);
|
||||
data.TileWidth = SafeLoadIntFromElemAttr(root_elem, "tilewidth" , data.TileWidth);
|
||||
data.TileHeight = SafeLoadIntFromElemAttr(root_elem, "tileheight", data.TileHeight);
|
||||
var orientation_str = root_elem.Attribute("orientation").Value;
|
||||
switch ( orientation_str ) {
|
||||
case "isometric":
|
||||
data.Orientation = TiledMapOrientation.Isometric;
|
||||
break;
|
||||
default:
|
||||
throw new UnityException(string.Format(
|
||||
"unsupported orientation ({0})",
|
||||
orientation_str));
|
||||
}
|
||||
SafeLoadPropertiesFromOwnerElem(root_elem, data.Properties);
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Layers
|
||||
// -----------------------------
|
||||
|
||||
static void LoadTiledMapLayersFromTmxRootElem(XElement root_elem, TiledMapData data) {
|
||||
foreach ( var layer_elem in root_elem.Elements("layer") ) {
|
||||
var layer = new TiledMapLayerData();
|
||||
LoadTiledMapLayerFromTmxLayerElem(layer_elem, layer);
|
||||
data.Layers.Add(layer);
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadTiledMapLayerFromTmxLayerElem(XElement layer_elem, TiledMapLayerData layer) {
|
||||
layer.Name = SafeLoadStrFromElemAttr (layer_elem, "name" , layer.Name);
|
||||
layer.OffsetX = SafeLoadIntFromElemAttr (layer_elem, "offsetx", layer.OffsetX);
|
||||
layer.OffsetY = SafeLoadIntFromElemAttr (layer_elem, "offsety", layer.OffsetY);
|
||||
layer.Visible = SafeLoadBoolFromElemAttr(layer_elem, "visible", layer.Visible);
|
||||
LoadTiledMapLayerTilesFromTmxLayerElem(layer_elem, layer);
|
||||
SafeLoadPropertiesFromOwnerElem(layer_elem, layer.Properties);
|
||||
}
|
||||
|
||||
static void LoadTiledMapLayerTilesFromTmxLayerElem(XElement layer_elem, TiledMapLayerData layer) {
|
||||
foreach ( var elem in layer_elem.Element("data").Elements("tile") ) {
|
||||
layer.Tiles.Add(SafeLoadIntFromElemAttr(elem, "gid", 0));
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Tilesets
|
||||
// -----------------------------
|
||||
|
||||
static void LoadTiledMapTilesetsFromTmxRootElem(XElement root_elem, TiledMapData data) {
|
||||
foreach ( var tileset_elem in root_elem.Elements("tileset") ) {
|
||||
var tileset = new TiledMapTilesetData();
|
||||
LoadTiledMapTilesetFromTmxTilesetElem(tileset_elem, tileset);
|
||||
data.Tilesets.Add(tileset);
|
||||
}
|
||||
}
|
||||
|
||||
static void LoadTiledMapTilesetFromTmxTilesetElem(XElement tileset_elem, TiledMapTilesetData tileset) {
|
||||
tileset.FirstGid = SafeLoadIntFromElemAttr(tileset_elem, "firstgid" , tileset.FirstGid);
|
||||
tileset.Name = SafeLoadStrFromElemAttr(tileset_elem, "name" , tileset.Name);
|
||||
tileset.Margin = SafeLoadIntFromElemAttr(tileset_elem, "margin" , tileset.Margin);
|
||||
tileset.Spacing = SafeLoadIntFromElemAttr(tileset_elem, "spacing" , tileset.Spacing);
|
||||
tileset.TileWidth = SafeLoadIntFromElemAttr(tileset_elem, "tilewidth" , tileset.TileWidth);
|
||||
tileset.TileHeight = SafeLoadIntFromElemAttr(tileset_elem, "tileheight", tileset.TileHeight);
|
||||
tileset.TileCount = SafeLoadIntFromElemAttr(tileset_elem, "tilecount" , tileset.TileCount);
|
||||
tileset.TileOffsetX = SafeLoadIntFromElemAttr(tileset_elem.Element("tileoffset"), "x" , tileset.TileOffsetX);
|
||||
tileset.TileOffsetY = SafeLoadIntFromElemAttr(tileset_elem.Element("tileoffset"), "y" , tileset.TileOffsetY);
|
||||
tileset.ImageSource = SafeLoadStrFromElemAttr(tileset_elem.Element("image" ), "source", tileset.ImageSource);
|
||||
SafeLoadPropertiesFromOwnerElem(tileset_elem, tileset.Properties);
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Textures
|
||||
// -----------------------------
|
||||
|
||||
static void LoadTiledMapTilesetsTextures(string tmx_path, TiledMapData data) {
|
||||
foreach ( var tileset in data.Tilesets ) {
|
||||
if ( !string.IsNullOrEmpty(tileset.ImageSource) ) {
|
||||
var base_path = Path.GetDirectoryName(tmx_path);
|
||||
var image_path = Path.Combine(base_path, tileset.ImageSource);
|
||||
|
||||
var importer = AssetImporter.GetAtPath(image_path) as TextureImporter;
|
||||
if ( !importer ) {
|
||||
throw new UnityException(string.Format(
|
||||
"tileset ({0}) image importer not found ({1})",
|
||||
tileset.Name, image_path));
|
||||
}
|
||||
|
||||
var meta_data = new List<SpriteMetaData>();
|
||||
var image_size = GetSizeFromTextureImporter(importer);
|
||||
for ( var i = image_size.y - tileset.TileHeight - tileset.Margin; i >= tileset.Margin; i -= tileset.TileHeight + tileset.Spacing ) {
|
||||
for ( var j = tileset.Margin; j <= image_size.x - tileset.Margin - tileset.TileWidth; j += tileset.TileWidth + tileset.Spacing ) {
|
||||
var meta_elem = new SpriteMetaData();
|
||||
meta_elem.name = string.Format(
|
||||
"{0}_{1}",
|
||||
Path.GetFileNameWithoutExtension(image_path),
|
||||
meta_data.Count + tileset.FirstGid);
|
||||
meta_elem.rect = new Rect(j, i, tileset.TileWidth, tileset.TileHeight);
|
||||
meta_data.Add(meta_elem);
|
||||
}
|
||||
}
|
||||
|
||||
importer.spritesheet = meta_data.ToArray();
|
||||
importer.textureType = TextureImporterType.Sprite;
|
||||
importer.spriteImportMode = SpriteImportMode.Multiple;
|
||||
AssetDatabase.ImportAsset(image_path, ImportAssetOptions.ForceUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Common
|
||||
// -----------------------------
|
||||
|
||||
static string SafeLoadStrFromElemAttr(XElement elem, string attr_name, string def_value) {
|
||||
if ( elem != null && elem.Attribute(attr_name) != null ) {
|
||||
return elem.Attribute(attr_name).Value;
|
||||
}
|
||||
return def_value;
|
||||
}
|
||||
|
||||
static int SafeLoadIntFromElemAttr(XElement elem, string attr_name, int def_value) {
|
||||
int value;
|
||||
if ( elem != null && int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
return value;
|
||||
}
|
||||
return def_value;
|
||||
}
|
||||
|
||||
static bool SafeLoadBoolFromElemAttr(XElement elem, string attr_name, bool def_value) {
|
||||
int value;
|
||||
if ( elem != null && int.TryParse(SafeLoadStrFromElemAttr(elem, attr_name, ""), out value) ) {
|
||||
return value != 0;
|
||||
}
|
||||
return def_value;
|
||||
}
|
||||
|
||||
static void SafeLoadPropertiesFromOwnerElem(XElement owner_elem, List<string> props) {
|
||||
var props_elem = owner_elem != null ? owner_elem.Element("properties") : null;
|
||||
if ( props_elem != null ) {
|
||||
foreach ( var prop_elem in props_elem.Elements("property") ) {
|
||||
var prop_name = SafeLoadStrFromElemAttr(prop_elem, "name" , null);
|
||||
var prop_value = SafeLoadStrFromElemAttr(prop_elem, "value", null);
|
||||
if ( !string.IsNullOrEmpty(prop_name) && prop_value != null ) {
|
||||
props.Add(prop_name);
|
||||
props.Add(prop_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RemoveAllSubAsset(string main_asset_path) {
|
||||
var subassets = AssetDatabase.LoadAllAssetsAtPath(main_asset_path);
|
||||
foreach ( var asset in subassets ) {
|
||||
if ( !AssetDatabase.IsMainAsset(asset) ) {
|
||||
GameObject.DestroyImmediate(asset, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Vector2 GetSizeFromTextureImporter(TextureImporter importer) {
|
||||
var method_args = new object[2]{0,0};
|
||||
typeof(TextureImporter)
|
||||
.GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
.Invoke(importer, method_args);
|
||||
return new Vector2((int)method_args[0], (int)method_args[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac5896bd1f00843dba1aa5a571380e1b
|
||||
timeCreated: 1453182091
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace IsoTools.Tiled.Internal {
|
||||
[CustomEditor(typeof(TiledMapTileset)), CanEditMultipleObjects]
|
||||
class TiledMapTileEditor : Editor {
|
||||
TiledMapTileset _tileset = null;
|
||||
|
||||
void OnEnable() {
|
||||
_tileset = target as TiledMapTileset;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( _tileset && _tileset.Properties != null ) {
|
||||
_tileset.Properties.OnInspectorGUI("Tileset properties");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b2831b8e398544239645b6e85f259eb
|
||||
timeCreated: 1454357710
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,50 +0,0 @@
|
||||
using UnityEngine;
|
||||
using IsoTools.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace IsoTools.Tiled {
|
||||
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(IsoObject))]
|
||||
public class TiledMap : MonoBehaviour {
|
||||
|
||||
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
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void OnDrawGizmos() {
|
||||
var iso_object = GetComponent<IsoObject>();
|
||||
if ( isShowGrid && iso_object && iso_object.isoWorld ) {
|
||||
IsoUtils.DrawIsoGrid(
|
||||
iso_object.isoWorld,
|
||||
iso_object.position, iso_object.size,
|
||||
IsoUtils.ColorChangeA(Color.green, 0.5f));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65223c9354c874240a67280485a6b300
|
||||
timeCreated: 1453567172
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IsoTools.Tiled {
|
||||
public enum TiledMapOrientation {
|
||||
Isometric
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class TiledMapLayerData {
|
||||
public string Name = "";
|
||||
public int OffsetX = 0;
|
||||
public int OffsetY = 0;
|
||||
public bool Visible = true;
|
||||
public List<int> Tiles = new List<int>();
|
||||
public List<string> Properties = new List<string>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class TiledMapTilesetData {
|
||||
public int FirstGid = 0;
|
||||
public string Name = "";
|
||||
public int Margin = 0;
|
||||
public int Spacing = 0;
|
||||
public int TileWidth = 0;
|
||||
public int TileHeight = 0;
|
||||
public int TileCount = 0;
|
||||
public int TileOffsetX = 0;
|
||||
public int TileOffsetY = 0;
|
||||
public string ImageSource = "";
|
||||
public List<string> Properties = new List<string>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class TiledMapData {
|
||||
public int Width = 0;
|
||||
public int Height = 0;
|
||||
public int TileWidth = 0;
|
||||
public int TileHeight = 0;
|
||||
public TiledMapOrientation Orientation = TiledMapOrientation.Isometric;
|
||||
public List<string> Properties = new List<string>();
|
||||
public List<TiledMapLayerData> Layers = new List<TiledMapLayerData>();
|
||||
public List<TiledMapTilesetData> Tilesets = new List<TiledMapTilesetData>();
|
||||
}
|
||||
|
||||
public class TiledMapAsset : ScriptableObject {
|
||||
//[HideInInspector]
|
||||
public TiledMapData Data = new TiledMapData();
|
||||
public string Name = string.Empty;
|
||||
public float PixelsPerUnit = 100.0f;
|
||||
public float LayersDepthStep = IsoWorld.DefStepDepth;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88b6d219eb032493cacdfdd698dc960b
|
||||
timeCreated: 1453182084
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
using UnityEngine;
|
||||
using IsoTools.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace IsoTools.Tiled {
|
||||
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||
public class TiledMapLayer : MonoBehaviour {
|
||||
|
||||
public TiledMapAsset Asset = null;
|
||||
public TiledMapProperties Properties = null;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2683a35aa9e5c4d7786be4a908523bbb
|
||||
timeCreated: 1454267808
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,216 +0,0 @@
|
||||
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;
|
||||
|
||||
// -----------------------------
|
||||
// Functions
|
||||
// -----------------------------
|
||||
|
||||
public TiledMapProperties(List<string> properties) {
|
||||
_properties = properties;
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return _properties != null
|
||||
? _properties.Count / 2
|
||||
: 0;
|
||||
}
|
||||
}
|
||||
|
||||
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 ) {
|
||||
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 ( int i = 0, e = _properties.Count / 2; i < e; ++i ) {
|
||||
if ( _properties[i * 2] == property_name ) {
|
||||
value = _properties[i * 2 + 1];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa7b674b7f7ae4c11a2df9172b4020ba
|
||||
timeCreated: 1454346480
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
using UnityEngine;
|
||||
using IsoTools.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace IsoTools.Tiled {
|
||||
[ExecuteInEditMode, DisallowMultipleComponent]
|
||||
public class TiledMapTileset : MonoBehaviour {
|
||||
|
||||
public TiledMapAsset Asset = null;
|
||||
public TiledMapProperties Properties = null;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 771457a2414954117b1fbe3a1178f023
|
||||
timeCreated: 1454774218
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 305 KiB |
|
Before Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 386 KiB |
|
Before Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 903 KiB |
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 824 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 415 KiB |