From 8c795496d5a0bf0c10a16cd30f00c134aa66c972 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 19 Sep 2014 17:01:08 +0100 Subject: [PATCH] Instantiate prefabs correctly (maintaining link) --- Assets/Fungus/Camera/Editor/CameraMenuItems.cs | 2 +- Assets/Fungus/Dialog/Editor/DialogMenuItems.cs | 2 +- Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs index 51f7c15d..4249f4c3 100644 --- a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs +++ b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs @@ -18,7 +18,7 @@ namespace Fungus GameObject prefab = Resources.LoadAssetAtPath("Assets/Fungus/Camera/Prefabs/" + prefabName + ".prefab", typeof(GameObject)) as GameObject; if (prefab != null) { - GameObject go = GameObject.Instantiate(prefab) as GameObject; + GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; go.name = prefabName; } } diff --git a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs index 1db612fe..d6a66003 100644 --- a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs +++ b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs @@ -43,7 +43,7 @@ namespace Fungus GameObject prefab = Resources.LoadAssetAtPath("Assets/Fungus/Dialog/Prefabs/" + prefabName + ".prefab", typeof(GameObject)) as GameObject; if (prefab != null) { - GameObject go = GameObject.Instantiate(prefab) as GameObject; + GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; go.name = prefabName; } } diff --git a/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs b/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs index 66a2710b..348a08e7 100644 --- a/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs +++ b/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs @@ -19,7 +19,7 @@ namespace Fungus GameObject prefab = Resources.LoadAssetAtPath("Assets/Fungus/Sprite/Prefabs/" + prefabName + ".prefab", typeof(GameObject)) as GameObject; if (prefab != null) { - GameObject go = GameObject.Instantiate(prefab) as GameObject; + GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; go.name = prefabName; } }