diff --git a/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/Importers/TmxAssetImporter.cs b/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/Importers/TmxAssetImporter.cs index 0abc240f..ff8d8523 100644 --- a/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/Importers/TmxAssetImporter.cs +++ b/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/Importers/TmxAssetImporter.cs @@ -430,6 +430,15 @@ private void DoPrefabReplacements() { objectsById[so.m_Id].BroadcastProperty(p, objectsById); } + + if (so.gameObject.GetSuperPropertyValueBool(StringConstants.Unity_PrefabKeepObject, false)) + { + var superObjectCopy = objectsById[so.m_Id].AddComponent(); + EditorUtility.CopySerialized(so, superObjectCopy); + + var superPropsCopy = objectsById[so.m_Id].AddComponent(); + EditorUtility.CopySerialized(props, superPropsCopy); + } } } diff --git a/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/StringConstants.cs b/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/StringConstants.cs index 390602e3..732df12d 100644 --- a/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/StringConstants.cs +++ b/SuperTiled2Unity/Assets/SuperTiled2Unity/Scripts/Editor/StringConstants.cs @@ -6,6 +6,7 @@ public static class StringConstants public const string Unity_Ignore = Unity_Prefix + "ignore"; public const string Unity_IsTrigger = Unity_Prefix + "IsTrigger"; public const string Unity_Layer = Unity_Prefix + "layer"; + public const string Unity_PrefabKeepObject = Unity_Prefix + "prefabKeepObject"; public const string Unity_SortingLayer = Unity_Prefix + "SortingLayer"; public const string Unity_SortingLayerName = Unity_Prefix + "SortingLayerName"; public const string Unity_SortingOrder = Unity_Prefix + "SortingOrder"; diff --git a/docs/manual/custom-properties-importing.rst b/docs/manual/custom-properties-importing.rst index 7ed170c8..f30669c8 100644 --- a/docs/manual/custom-properties-importing.rst +++ b/docs/manual/custom-properties-importing.rst @@ -19,6 +19,7 @@ These custom properties always have a :code:`unity:` prefix so that they do not * **Collision**: The colliders are not imported for the layer." ":code:`unity:IsTrigger`", ":code:`bool`", "Layers, Tileset, Tile, Collider, Collider Group", "Controls the :code:`isTrigger` setting of the :code:`Collider2D` object generated in the prefab. Add as a layer custom property to override all colliders for a given layer." ":code:`unity:layer`", ":code:`string`", "Layers, Tileset, Tile, Collider, Collider Group", "Controls which Unity phyisics layer our generated colliders are assigned. The layer name must exist in your project's Tag Manager." + ":code:`unity:prefabKeepObject`", ":code:`bool`", "Objects", "When set on a prefab replacement object, will retain the SuperObject and SuperCustomProperties." ":code:`unity:SortingLayer`", ":code:`string`", "Layers, Tile Objects", "Controls which sorting layer is assigned to the Unity :code:`Renderer` component created for your tilemaps and sprites. The sorting layer name must exist in your project's Tag Manager." ":code:`unity:SortingOrder`", ":code:`int`", "Layers, Tile Objects", "Controls which sorting order is applied to the Unity :code:`Renderer` component created for your tilemaps and sprites." ":code:`unity:Tag`", ":code:`string`", "Layers, Objects", "Controls which tag is applied to the :code:`GameObject` created for your layers and objects. The tag must exist in your project's Tag Manager."