Browse Source

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.
master
chrisgregan 10 years ago
parent
commit
5e21f98bb7
  1. 13
      Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs
  2. 9
      Assets/Fungus/FungusScript/Resources.meta
  3. 108
      Assets/Fungus/FungusScript/Resources/FungusScript.prefab
  4. 8
      Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta

13
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<FungusScript>();
Sequence sequence = Undo.AddComponent<Sequence>(newFungusScriptGO);
sequence.nodeRect.x += 60;
sequence.nodeRect.y += 60;
GameStarted gameStarted = Undo.AddComponent<GameStarted>(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)

9
Assets/Fungus/FungusScript/Resources.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3c8cc55d1747d47c3a62002c9fbe8011
folderAsset: yes
timeCreated: 1427386140
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

108
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

8
Assets/Fungus/FungusScript/Resources/FungusScript.prefab.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5e7fbc8d4eb714b279eeeef2262c1e1a
timeCreated: 1427386150
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save