Allow setting the parent of a detail

This commit is contained in:
Nick 2022-06-29 16:15:34 -04:00
parent 785f668e9d
commit ba243648d0
2 changed files with 22 additions and 3 deletions

View File

@ -30,9 +30,14 @@ namespace NewHorizons.Builder.Props
detailGO = MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
}
else detailGO = MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
else
{
detailGO = MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
}
if (detailGO != null && detail.removeChildren != null)
if (detailGO == null) return;
if (detail.removeChildren != null)
{
foreach (var childPath in detail.removeChildren)
{
@ -42,7 +47,7 @@ namespace NewHorizons.Builder.Props
}
}
if (detailGO != null && detail.removeComponents)
if (detail.removeComponents)
{
// Just swap all the children to a new game object
var newDetailGO = new GameObject(detailGO.name);
@ -67,6 +72,15 @@ namespace NewHorizons.Builder.Props
detailGO.name = detail.rename;
}
if (!string.IsNullOrEmpty(detail.parentPath))
{
var newParent = go.transform.Find(detail.parentPath);
if (newParent != null)
{
detailGO.transform.parent = newParent.transform;
}
}
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
}

View File

@ -169,6 +169,11 @@ namespace NewHorizons.External.Modules
/// If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is
/// </summary>
public string quantumGroupID;
/// <summary>
/// The path (not including the root planet object) of the parent of this game object. Optional (will default to the root sector).
/// </summary>
public string parentPath;
}
[JsonObject]