Unity2D使用Tiled2Unity读取TiledMap中的自定义属性

继承Editor Scripts下的ICustomTiledImporter,实现HandleCustomproperties接口


例:

Unity2D使用Tiled2Unity读取TiledMap中的自定义属性_第1张图片

[Tiled2Unity.CustomTiledImporter]
class CustomImporterAddComponent : Tiled2Unity.ICustomTiledImporter
{
    public void HandleCustomProperties(UnityEngine.GameObject gameObject,
        IDictionary props)
    {
        // Simply add a component to our GameObject
        if (props.ContainsKey("AddComp"))
        {
            gameObject.AddComponent(props["AddComp"]);
        }
    }
    public void CustomizePrefab(GameObject prefab)
    {
        // Do nothing
    }
}



你可能感兴趣的:(unity3D)