Skip to content

Commit 8008bb1

Browse files
committed
PrefabData Setup
- Removed Start method from PrefabDataHolder, replaced with setup method which is only called once per unique prefab, rather than every new instance of PrefabDataHolder. (Increases prefab spawning by ~20%)
1 parent 7074ac5 commit 8008bb1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Assets/MapEditor/Managers/PrefabManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static GameObject Process(GameObject go, string filePath)
5555
}
5656
PrefabDataHolder prefabDataHolder = go.AddComponent<PrefabDataHolder>();
5757
prefabDataHolder.prefabData = new PrefabData() { id = AssetManager.ToID(filePath) };
58+
prefabDataHolder.Setup();
5859
return go;
5960
}
6061

Assets/MapEditor/WorldData/PrefabDataHolder.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55

66
[DisallowMultipleComponent]
77
[SelectionBase]
8-
[ExecuteAlways]
98
public class PrefabDataHolder : MonoBehaviour
109
{
1110
public WorldSerialization.PrefabData prefabData;
1211

13-
private void Start()
12+
public void Setup()
1413
{
1514
for (int i = 0; i < GetComponents<Component>().Length; i++)
16-
{
1715
ComponentUtility.MoveComponentUp(this);
18-
}
1916
}
17+
2018
public void UpdatePrefabData()
2119
{
2220
prefabData.position = gameObject.transform.position - (0.5f * land.terrainData.size);
2321
prefabData.rotation = transform.rotation;
2422
prefabData.scale = transform.localScale;
2523
}
24+
2625
public void SnapToGround()
2726
{
2827
Vector3 newPos = transform.position;

0 commit comments

Comments
 (0)