From f2786e7255677b5fd407b04dce1a3e07b9541949 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 27 Mar 2015 15:21:43 +0000 Subject: [PATCH] Unified Fungus object spawning method Moved Prefabs to Resources folders so they can be easily loaded using Resources.Load --- .../Fungus/Camera/Editor/CameraMenuItems.cs | 4 +- Assets/Fungus/Camera/Prefabs.meta | 5 --- Assets/Fungus/Camera/Resources.meta | 9 +++++ .../Camera/{Prefabs => Resources}/View.prefab | 0 .../{Prefabs => Resources}/View.prefab.meta | 0 .../Fungus/Dialog/Editor/DialogMenuItems.cs | 39 ++++--------------- ...{FungusAudioTag.prefab => AudioTag.prefab} | 0 ...ioTag.prefab.meta => AudioTag.prefab.meta} | 0 ...ungusCharacter.prefab => Character.prefab} | 0 ...cter.prefab.meta => Character.prefab.meta} | 0 ...sEventSystem.prefab => EventSystem.prefab} | 0 ...em.prefab.meta => EventSystem.prefab.meta} | 0 ...gusMenuDialog.prefab => MenuDialog.prefab} | 0 ...log.prefab.meta => MenuDialog.prefab.meta} | 0 ...ungusSayDialog.prefab => SayDialog.prefab} | 0 ...alog.prefab.meta => SayDialog.prefab.meta} | 0 .../{FungusTag.prefab => Tag.prefab} | 0 ...{FungusTag.prefab.meta => Tag.prefab.meta} | 0 .../Editor/FungusScriptMenuItems.cs | 12 ++---- Assets/Fungus/Portrait/Prefabs.meta | 5 --- .../{Prefabs => Resources}/Stage.prefab | 7 ++-- .../{Prefabs => Resources}/Stage.prefab.meta | 0 .../StagePosition.prefab | 3 +- .../StagePosition.prefab.meta | 0 .../Fungus/Sprite/Editor/SpriteMenuItems.cs | 8 ++-- .../Sprite/{Prefabs.meta => Resources.meta} | 0 .../ClickableSprite.prefab | 0 .../ClickableSprite.prefab.meta | 0 .../DragTargetSprite.prefab | 0 .../DragTargetSprite.prefab.meta | 0 .../DraggableSprite.prefab | 0 .../DraggableSprite.prefab.meta | 0 .../ParallaxSprite.prefab | 0 .../ParallaxSprite.prefab.meta | 0 34 files changed, 30 insertions(+), 62 deletions(-) delete mode 100644 Assets/Fungus/Camera/Prefabs.meta create mode 100644 Assets/Fungus/Camera/Resources.meta rename Assets/Fungus/Camera/{Prefabs => Resources}/View.prefab (100%) rename Assets/Fungus/Camera/{Prefabs => Resources}/View.prefab.meta (100%) rename Assets/Fungus/Dialog/Resources/{FungusAudioTag.prefab => AudioTag.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusAudioTag.prefab.meta => AudioTag.prefab.meta} (100%) rename Assets/Fungus/Dialog/Resources/{FungusCharacter.prefab => Character.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusCharacter.prefab.meta => Character.prefab.meta} (100%) rename Assets/Fungus/Dialog/Resources/{FungusEventSystem.prefab => EventSystem.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusEventSystem.prefab.meta => EventSystem.prefab.meta} (100%) rename Assets/Fungus/Dialog/Resources/{FungusMenuDialog.prefab => MenuDialog.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusMenuDialog.prefab.meta => MenuDialog.prefab.meta} (100%) rename Assets/Fungus/Dialog/Resources/{FungusSayDialog.prefab => SayDialog.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusSayDialog.prefab.meta => SayDialog.prefab.meta} (100%) rename Assets/Fungus/Dialog/Resources/{FungusTag.prefab => Tag.prefab} (100%) rename Assets/Fungus/Dialog/Resources/{FungusTag.prefab.meta => Tag.prefab.meta} (100%) delete mode 100644 Assets/Fungus/Portrait/Prefabs.meta rename Assets/Fungus/Portrait/{Prefabs => Resources}/Stage.prefab (99%) rename Assets/Fungus/Portrait/{Prefabs => Resources}/Stage.prefab.meta (100%) rename Assets/Fungus/Portrait/{Prefabs => Resources}/StagePosition.prefab (97%) rename Assets/Fungus/Portrait/{Prefabs => Resources}/StagePosition.prefab.meta (100%) rename Assets/Fungus/Sprite/{Prefabs.meta => Resources.meta} (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/ClickableSprite.prefab (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/ClickableSprite.prefab.meta (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/DragTargetSprite.prefab (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/DragTargetSprite.prefab.meta (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/DraggableSprite.prefab (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/DraggableSprite.prefab.meta (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/ParallaxSprite.prefab (100%) rename Assets/Fungus/Sprite/{Prefabs => Resources}/ParallaxSprite.prefab.meta (100%) diff --git a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs index a203440f..a28f3d7e 100644 --- a/Assets/Fungus/Camera/Editor/CameraMenuItems.cs +++ b/Assets/Fungus/Camera/Editor/CameraMenuItems.cs @@ -8,9 +8,9 @@ namespace Fungus public class CameraMenuItems { [MenuItem("GameObject/Fungus/Camera/View")] - static void CreateBackground() + static void CreateView() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Camera/Prefabs/View.prefab"); + FungusScriptMenuItems.SpawnPrefab("View"); } } diff --git a/Assets/Fungus/Camera/Prefabs.meta b/Assets/Fungus/Camera/Prefabs.meta deleted file mode 100644 index 603b1f70..00000000 --- a/Assets/Fungus/Camera/Prefabs.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: 10dcdae42763d4e44af47c20af580910 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Assets/Fungus/Camera/Resources.meta b/Assets/Fungus/Camera/Resources.meta new file mode 100644 index 00000000..3b02aab2 --- /dev/null +++ b/Assets/Fungus/Camera/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6cc28e50d85784bb3bb7aa82a3091385 +folderAsset: yes +timeCreated: 1427468269 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/Camera/Prefabs/View.prefab b/Assets/Fungus/Camera/Resources/View.prefab similarity index 100% rename from Assets/Fungus/Camera/Prefabs/View.prefab rename to Assets/Fungus/Camera/Resources/View.prefab diff --git a/Assets/Fungus/Camera/Prefabs/View.prefab.meta b/Assets/Fungus/Camera/Resources/View.prefab.meta similarity index 100% rename from Assets/Fungus/Camera/Prefabs/View.prefab.meta rename to Assets/Fungus/Camera/Resources/View.prefab.meta diff --git a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs index e75759c3..ffd19d79 100644 --- a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs +++ b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs @@ -12,68 +12,43 @@ namespace Fungus [MenuItem("GameObject/Fungus/Dialog/Character")] static void CreateCharacter() { - GameObject go = Resources.Load("FungusCharacter"); - if (go != null) - { - GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject; - spawnedGO.name = "Character"; - } + FungusScriptMenuItems.SpawnPrefab("Character"); } [MenuItem("GameObject/Fungus/Dialog/SayDialog")] static void CreateSayDialog() { - GameObject go = Resources.Load("FungusSayDialog"); - if (go != null) - { - GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject; - spawnedGO.name = "SayDialog"; - } + FungusScriptMenuItems.SpawnPrefab("SayDialog"); } [MenuItem("GameObject/Fungus/Dialog/MenuDialog")] static void CreateMenuDialog() { - GameObject go = Resources.Load("FungusMenuDialog"); - if (go != null) - { - GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject; - spawnedGO.name = "MenuDialog"; - } + FungusScriptMenuItems.SpawnPrefab("MenuDialog"); } [MenuItem("GameObject/Fungus/Dialog/Tag")] static void CreateTag() { - GameObject go = Resources.Load("FungusTag"); - if (go != null) - { - GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject; - spawnedGO.name = "Tag"; - } + FungusScriptMenuItems.SpawnPrefab("Tag"); } [MenuItem("GameObject/Fungus/Dialog/AudioTag")] static void CreateAudioTag() { - GameObject go = Resources.Load("FungusAudioTag"); - if (go != null) - { - GameObject spawnedGO = PrefabUtility.InstantiatePrefab(go) as GameObject; - spawnedGO.name = "AudioTag"; - } + FungusScriptMenuItems.SpawnPrefab("AudioTag"); } [MenuItem("GameObject/Fungus/Portrait/Stage")] static void CreateStage() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/Stage.prefab"); + FungusScriptMenuItems.SpawnPrefab("Stage"); } [MenuItem("GameObject/Fungus/Portrait/StagePosition")] static void CreateStagePosition() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Portrait/Prefabs/StagePosition.prefab"); + FungusScriptMenuItems.SpawnPrefab("StagePosition"); } } diff --git a/Assets/Fungus/Dialog/Resources/FungusAudioTag.prefab b/Assets/Fungus/Dialog/Resources/AudioTag.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusAudioTag.prefab rename to Assets/Fungus/Dialog/Resources/AudioTag.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusAudioTag.prefab.meta b/Assets/Fungus/Dialog/Resources/AudioTag.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusAudioTag.prefab.meta rename to Assets/Fungus/Dialog/Resources/AudioTag.prefab.meta diff --git a/Assets/Fungus/Dialog/Resources/FungusCharacter.prefab b/Assets/Fungus/Dialog/Resources/Character.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusCharacter.prefab rename to Assets/Fungus/Dialog/Resources/Character.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusCharacter.prefab.meta b/Assets/Fungus/Dialog/Resources/Character.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusCharacter.prefab.meta rename to Assets/Fungus/Dialog/Resources/Character.prefab.meta diff --git a/Assets/Fungus/Dialog/Resources/FungusEventSystem.prefab b/Assets/Fungus/Dialog/Resources/EventSystem.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusEventSystem.prefab rename to Assets/Fungus/Dialog/Resources/EventSystem.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusEventSystem.prefab.meta b/Assets/Fungus/Dialog/Resources/EventSystem.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusEventSystem.prefab.meta rename to Assets/Fungus/Dialog/Resources/EventSystem.prefab.meta diff --git a/Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab b/Assets/Fungus/Dialog/Resources/MenuDialog.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab rename to Assets/Fungus/Dialog/Resources/MenuDialog.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab.meta b/Assets/Fungus/Dialog/Resources/MenuDialog.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusMenuDialog.prefab.meta rename to Assets/Fungus/Dialog/Resources/MenuDialog.prefab.meta diff --git a/Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab b/Assets/Fungus/Dialog/Resources/SayDialog.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab rename to Assets/Fungus/Dialog/Resources/SayDialog.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab.meta b/Assets/Fungus/Dialog/Resources/SayDialog.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusSayDialog.prefab.meta rename to Assets/Fungus/Dialog/Resources/SayDialog.prefab.meta diff --git a/Assets/Fungus/Dialog/Resources/FungusTag.prefab b/Assets/Fungus/Dialog/Resources/Tag.prefab similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusTag.prefab rename to Assets/Fungus/Dialog/Resources/Tag.prefab diff --git a/Assets/Fungus/Dialog/Resources/FungusTag.prefab.meta b/Assets/Fungus/Dialog/Resources/Tag.prefab.meta similarity index 100% rename from Assets/Fungus/Dialog/Resources/FungusTag.prefab.meta rename to Assets/Fungus/Dialog/Resources/Tag.prefab.meta diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs index 36215689..6f893b36 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs @@ -11,23 +11,19 @@ namespace Fungus [MenuItem("GameObject/Fungus/Fungus Script")] static void CreateFungusScript() { - SpawnPrefab("Assets/Fungus/FungusScript/Resources/FungusScript.prefab"); + SpawnPrefab("FungusScript"); } - public static GameObject SpawnPrefab(string prefabFile) + public static GameObject SpawnPrefab(string prefabName) { - string prefabName = Path.GetFileNameWithoutExtension(prefabFile); - - // This will only succeed if Fungus is located in the root folder of the project - GameObject prefab = Resources.LoadAssetAtPath(prefabFile, typeof(GameObject)) as GameObject; + GameObject prefab = Resources.Load(prefabName); if (prefab == null) { return null; } GameObject go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; - go.name = prefabName; - + Camera sceneCam = SceneView.currentDrawingSceneView.camera; Vector3 pos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 10f)); diff --git a/Assets/Fungus/Portrait/Prefabs.meta b/Assets/Fungus/Portrait/Prefabs.meta deleted file mode 100644 index 149c6519..00000000 --- a/Assets/Fungus/Portrait/Prefabs.meta +++ /dev/null @@ -1,5 +0,0 @@ -fileFormatVersion: 2 -guid: bc13409addc0175478468496602b7880 -folderAsset: yes -DefaultImporter: - userData: diff --git a/Assets/Fungus/Portrait/Prefabs/Stage.prefab b/Assets/Fungus/Portrait/Resources/Stage.prefab similarity index 99% rename from Assets/Fungus/Portrait/Prefabs/Stage.prefab rename to Assets/Fungus/Portrait/Resources/Stage.prefab index 6d8e59b5..1813ed92 100644 --- a/Assets/Fungus/Portrait/Prefabs/Stage.prefab +++ b/Assets/Fungus/Portrait/Resources/Stage.prefab @@ -44,7 +44,7 @@ GameObject: - 4: {fileID: 410270} - 114: {fileID: 11410274} m_Layer: 0 - m_Name: Stage + m_Name: FungusStage m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -233,8 +233,8 @@ MonoBehaviour: m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} m_Name: m_EditorClassIdentifier: - ignoreReversedGraphics: 1 - blockingObjects: 0 + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 m_BlockingMask: serializedVersion: 2 m_Bits: 4294967295 @@ -477,4 +477,3 @@ Prefab: m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 110274} m_IsPrefabParent: 1 - m_IsExploded: 1 diff --git a/Assets/Fungus/Portrait/Prefabs/Stage.prefab.meta b/Assets/Fungus/Portrait/Resources/Stage.prefab.meta similarity index 100% rename from Assets/Fungus/Portrait/Prefabs/Stage.prefab.meta rename to Assets/Fungus/Portrait/Resources/Stage.prefab.meta diff --git a/Assets/Fungus/Portrait/Prefabs/StagePosition.prefab b/Assets/Fungus/Portrait/Resources/StagePosition.prefab similarity index 97% rename from Assets/Fungus/Portrait/Prefabs/StagePosition.prefab rename to Assets/Fungus/Portrait/Resources/StagePosition.prefab index dbfbaa06..93900ddc 100644 --- a/Assets/Fungus/Portrait/Prefabs/StagePosition.prefab +++ b/Assets/Fungus/Portrait/Resources/StagePosition.prefab @@ -11,7 +11,7 @@ GameObject: - 222: {fileID: 22295640} - 114: {fileID: 11495640} m_Layer: 0 - m_Name: StagePosition + m_Name: FungusStagePosition m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -72,4 +72,3 @@ Prefab: m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 195640} m_IsPrefabParent: 1 - m_IsExploded: 1 diff --git a/Assets/Fungus/Portrait/Prefabs/StagePosition.prefab.meta b/Assets/Fungus/Portrait/Resources/StagePosition.prefab.meta similarity index 100% rename from Assets/Fungus/Portrait/Prefabs/StagePosition.prefab.meta rename to Assets/Fungus/Portrait/Resources/StagePosition.prefab.meta diff --git a/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs b/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs index b62333ae..32479899 100644 --- a/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs +++ b/Assets/Fungus/Sprite/Editor/SpriteMenuItems.cs @@ -10,25 +10,25 @@ namespace Fungus [MenuItem("GameObject/Fungus/Sprite/ClickableSprite")] static void CreateClickableSprite() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Sprite/Prefabs/ClickableSprite.prefab"); + FungusScriptMenuItems.SpawnPrefab("ClickableSprite"); } [MenuItem("GameObject/Fungus/Sprite/DraggableSprite")] static void CreateDraggableSprite() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Sprite/Prefabs/DraggableSprite.prefab"); + FungusScriptMenuItems.SpawnPrefab("DraggableSprite"); } [MenuItem("GameObject/Fungus/Sprite/DragTargetSprite")] static void CreateDragTargetSprite() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Sprite/Prefabs/DragTargetSprite.prefab"); + FungusScriptMenuItems.SpawnPrefab("DragTargetSprite"); } [MenuItem("GameObject/Fungus/Sprite/ParallaxSprite")] static void CreateParallaxSprite() { - FungusScriptMenuItems.SpawnPrefab("Assets/Fungus/Sprite/Prefabs/ParallaxSprite.prefab"); + FungusScriptMenuItems.SpawnPrefab("ParallaxSprite"); } } diff --git a/Assets/Fungus/Sprite/Prefabs.meta b/Assets/Fungus/Sprite/Resources.meta similarity index 100% rename from Assets/Fungus/Sprite/Prefabs.meta rename to Assets/Fungus/Sprite/Resources.meta diff --git a/Assets/Fungus/Sprite/Prefabs/ClickableSprite.prefab b/Assets/Fungus/Sprite/Resources/ClickableSprite.prefab similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/ClickableSprite.prefab rename to Assets/Fungus/Sprite/Resources/ClickableSprite.prefab diff --git a/Assets/Fungus/Sprite/Prefabs/ClickableSprite.prefab.meta b/Assets/Fungus/Sprite/Resources/ClickableSprite.prefab.meta similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/ClickableSprite.prefab.meta rename to Assets/Fungus/Sprite/Resources/ClickableSprite.prefab.meta diff --git a/Assets/Fungus/Sprite/Prefabs/DragTargetSprite.prefab b/Assets/Fungus/Sprite/Resources/DragTargetSprite.prefab similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/DragTargetSprite.prefab rename to Assets/Fungus/Sprite/Resources/DragTargetSprite.prefab diff --git a/Assets/Fungus/Sprite/Prefabs/DragTargetSprite.prefab.meta b/Assets/Fungus/Sprite/Resources/DragTargetSprite.prefab.meta similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/DragTargetSprite.prefab.meta rename to Assets/Fungus/Sprite/Resources/DragTargetSprite.prefab.meta diff --git a/Assets/Fungus/Sprite/Prefabs/DraggableSprite.prefab b/Assets/Fungus/Sprite/Resources/DraggableSprite.prefab similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/DraggableSprite.prefab rename to Assets/Fungus/Sprite/Resources/DraggableSprite.prefab diff --git a/Assets/Fungus/Sprite/Prefabs/DraggableSprite.prefab.meta b/Assets/Fungus/Sprite/Resources/DraggableSprite.prefab.meta similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/DraggableSprite.prefab.meta rename to Assets/Fungus/Sprite/Resources/DraggableSprite.prefab.meta diff --git a/Assets/Fungus/Sprite/Prefabs/ParallaxSprite.prefab b/Assets/Fungus/Sprite/Resources/ParallaxSprite.prefab similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/ParallaxSprite.prefab rename to Assets/Fungus/Sprite/Resources/ParallaxSprite.prefab diff --git a/Assets/Fungus/Sprite/Prefabs/ParallaxSprite.prefab.meta b/Assets/Fungus/Sprite/Resources/ParallaxSprite.prefab.meta similarity index 100% rename from Assets/Fungus/Sprite/Prefabs/ParallaxSprite.prefab.meta rename to Assets/Fungus/Sprite/Resources/ParallaxSprite.prefab.meta