From 5e21f98bb7841017a8e591ba2a445cb842843b8d Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 26 Mar 2015 17:49:34 +0000 Subject: [PATCH] Undo doesn't work on FungusScripts created from GameObject menu #91 Fix was to make a FungusScript prefab and spawn it the same way as all other prefabs. --- .../Editor/FungusScriptMenuItems.cs | 13 +-- Assets/Fungus/FungusScript/Resources.meta | 9 ++ .../Resources/FungusScript.prefab | 108 ++++++++++++++++++ .../Resources/FungusScript.prefab.meta | 8 ++ 4 files changed, 126 insertions(+), 12 deletions(-) create mode 100644 Assets/Fungus/FungusScript/Resources.meta create mode 100644 Assets/Fungus/FungusScript/Resources/FungusScript.prefab create mode 100644 Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs index 38fcf085..36215689 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs @@ -11,18 +11,7 @@ namespace Fungus [MenuItem("GameObject/Fungus/Fungus Script")] static void CreateFungusScript() { - GameObject newFungusScriptGO = new GameObject(); - newFungusScriptGO.name = "FungusScript"; - FungusScript fungusScript = newFungusScriptGO.AddComponent(); - Sequence sequence = Undo.AddComponent(newFungusScriptGO); - sequence.nodeRect.x += 60; - sequence.nodeRect.y += 60; - GameStarted gameStarted = Undo.AddComponent(newFungusScriptGO); - gameStarted.parentSequence = sequence; - sequence.eventHandler = gameStarted; - fungusScript.selectedSequence = sequence; - fungusScript.scrollPos = Vector2.zero; - Undo.RegisterCreatedObjectUndo(newFungusScriptGO, "Create Fungus Script"); + SpawnPrefab("Assets/Fungus/FungusScript/Resources/FungusScript.prefab"); } public static GameObject SpawnPrefab(string prefabFile) diff --git a/Assets/Fungus/FungusScript/Resources.meta b/Assets/Fungus/FungusScript/Resources.meta new file mode 100644 index 00000000..8e38972d --- /dev/null +++ b/Assets/Fungus/FungusScript/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3c8cc55d1747d47c3a62002c9fbe8011 +folderAsset: yes +timeCreated: 1427386140 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fungus/FungusScript/Resources/FungusScript.prefab b/Assets/Fungus/FungusScript/Resources/FungusScript.prefab new file mode 100644 index 00000000..b4fd2aea --- /dev/null +++ b/Assets/Fungus/FungusScript/Resources/FungusScript.prefab @@ -0,0 +1,108 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &142980 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 467082} + - 114: {fileID: 11430050} + - 114: {fileID: 11467182} + - 114: {fileID: 11417010} + m_Layer: 0 + m_Name: FungusScript + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &467082 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 142980} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11417010 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 142980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} + m_Name: + m_EditorClassIdentifier: + parentSequence: {fileID: 11467182} +--- !u!114 &11430050 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 142980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} + m_Name: + m_EditorClassIdentifier: + scrollPos: {x: 0, y: 0} + variablesScrollPos: {x: 0, y: 0} + variablesExpanded: 1 + sequenceViewHeight: 400 + zoom: 1 + scrollViewRect: + serializedVersion: 2 + x: -340 + y: -340 + width: 926 + height: 840 + selectedSequence: {fileID: 11467182} + selectedCommands: [] + variables: [] + description: + runSlowDuration: .25 + colorCommands: 1 + hideComponents: 1 + saveSelection: 1 + nextCommandId: 0 +--- !u!114 &11467182 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 142980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 60 + y: 60 + width: 126 + height: 40 + sequenceName: New Sequence + description: + runSlowInEditor: 1 + eventHandler: {fileID: 11417010} + commandList: [] +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 142980} + m_IsPrefabParent: 1 diff --git a/Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta b/Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta new file mode 100644 index 00000000..f05a64ea --- /dev/null +++ b/Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e7fbc8d4eb714b279eeeef2262c1e1a +timeCreated: 1427386150 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: