Browse Source

Merge pull request #287 from FungusGames/flowchart-prefabs

Flowchart prefabs
master
Chris Gregan 9 years ago
parent
commit
4cab039d46
  1. 9
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs
  2. 3
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  3. 8
      Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs
  4. 26
      Assets/Fungus/Flowchart/Resources/Flowchart.prefab
  5. 15
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs

9
Assets/Fungus/Flowchart/Editor/BlockEditor.cs

@ -399,6 +399,9 @@ namespace Fungus
newHandler.parentBlock = block;
block.eventHandler = newHandler;
}
// Because this is an async call, we need to force prefab instances to record changes
PrefabUtility.RecordPrefabInstancePropertyModifications(block);
}
protected virtual void UpdateIndentLevels(Block block)
@ -764,6 +767,9 @@ namespace Fungus
{
block.commandList.Add(newCommand);
}
// Because this is an async call, we need to force prefab instances to record changes
PrefabUtility.RecordPrefabInstancePropertyModifications(block);
}
public virtual void ShowContextMenu()
@ -968,6 +974,9 @@ namespace Fungus
}
}
// Because this is an async call, we need to force prefab instances to record changes
PrefabUtility.RecordPrefabInstancePropertyModifications(block);
Repaint();
}

3
Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs

@ -229,6 +229,9 @@ namespace Fungus
Variable newVariable = flowchart.gameObject.AddComponent(variableType) as Variable;
newVariable.key = flowchart.GetUniqueVariableKey("");
flowchart.variables.Add(newVariable);
// Because this is an async call, we need to force prefab instances to record changes
PrefabUtility.RecordPrefabInstancePropertyModifications(flowchart);
}
public static List<System.Type> FindAllDerivedTypes<T>()

8
Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs

@ -13,6 +13,14 @@ namespace Fungus
{
GameObject go = SpawnPrefab("Flowchart");
go.transform.position = Vector3.zero;
// Only the first created Flowchart in the scene should have a default GameStarted block
if (GameObject.FindObjectsOfType<Flowchart>().Length > 1)
{
Block block = go.GetComponent<Block>();
block.eventHandler = null;
GameObject.DestroyImmediate(block.eventHandler);
}
}
[MenuItem("Tools/Fungus/Create/Fungus Logo", false, 1000)]

26
Assets/Fungus/Flowchart/Resources/Flowchart.prefab

@ -9,7 +9,6 @@ GameObject:
m_Component:
- 4: {fileID: 467082}
- 114: {fileID: 11430050}
- 114: {fileID: 11417010}
- 114: {fileID: 11433304}
- 114: {fileID: 11462346}
m_Layer: 0
@ -31,18 +30,6 @@ Transform:
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:
parentBlock: {fileID: 0}
--- !u!114 &11430050
MonoBehaviour:
m_ObjectHideFlags: 1
@ -54,6 +41,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1.0
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
@ -69,11 +57,12 @@ MonoBehaviour:
selectedCommands: []
variables: []
description:
runSlowDuration: .25
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
nextItemId: 1
localizationId:
hideCommands: []
--- !u!114 &11433304
MonoBehaviour:
m_ObjectHideFlags: 1
@ -94,7 +83,6 @@ MonoBehaviour:
itemId: 0
blockName: New Block
description:
runSlowInEditor: 1
eventHandler: {fileID: 11462346}
commandList: []
--- !u!114 &11462346
@ -115,7 +103,11 @@ Prefab:
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_Modifications:
- target: {fileID: 0}
propertyPath: hideComponents
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 142980}

15
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -246,7 +246,11 @@ namespace Fungus
// they waste memory so should be cleared out periodically.
Block[] blocks = GetComponentsInChildren<Block>();
// Remove any null entries in the variables list
// It shouldn't happen but it seemed to occur for a user on the forum
variables.RemoveAll(item => item == null);
foreach (Variable variable in GetComponents<Variable>())
{
if (!variables.Contains(variable))
@ -310,14 +314,7 @@ namespace Fungus
}
protected virtual void Initialize()
{
// If there are other flowcharts in the scene and the selected block has the default name, then this is probably a new block.
// Reset the event handler of the new flowchart's default block to avoid crashes.
if (selectedBlock && cachedFlowcharts.Count > 1 && selectedBlock.blockName == DEFAULT_BLOCK_NAME)
{
selectedBlock.eventHandler = null;
}
}
{}
protected virtual Block CreateBlockComponent(GameObject parent)
{

Loading…
Cancel
Save