Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void AddSuperCustomProperties(GameObject go, XElement xProperties, SuperT
component.m_Properties = properties.OrderBy(p => p.m_Name).ToList();

AssignUnityTag(component);
AssignUnityLayer(component);
AssignUnityLayer(component, defaultInheritFromParent: true);
}

public void AssignTilemapSorting(TilemapRenderer renderer)
Expand Down Expand Up @@ -146,7 +146,7 @@ protected void AssignUnityTag(SuperCustomProperties properties)
}
}

protected void AssignUnityLayer(SuperCustomProperties properties)
protected void AssignUnityLayer(SuperCustomProperties properties, bool defaultInheritFromParent)
{
// Do we have a 'unity:layer' property?
CustomProperty prop;
Expand All @@ -163,7 +163,7 @@ protected void AssignUnityLayer(SuperCustomProperties properties)
properties.gameObject.layer = LayerMask.NameToLayer(layer);
}
}
else
else if (defaultInheritFromParent)
{
// Inherit the layer of our parent
var parent = properties.gameObject.transform.parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ private void DoPrefabReplacements()
// Keep the name from Tiled.
instance.name = so.gameObject.name;

// Transfer and reapply custom property magic on the instantiated prefab.
var soComponent = so.gameObject.GetComponent<SuperCustomProperties>();
if (soComponent != null && !soComponent.m_Properties.IsEmpty())
{
var component = instance.AddComponent<SuperCustomProperties>();
component.m_Properties = new List<CustomProperty>();
component.m_Properties.CombineFromSource(soComponent.m_Properties);
AssignUnityTag(component);
AssignUnityLayer(component, defaultInheritFromParent: false);
}

// Update bookkeeping for later custom property replacement.
goToDestroy.Add(so.gameObject);
objectsById[so.m_Id] = instance;
Expand Down