Browse Source

Added itemId to Blocks

master
chrisgregan 10 years ago
parent
commit
2f97ab7ff6
  1. 42
      Assets/Fungus/Flowchart/Resources/Flowchart.prefab
  2. 3
      Assets/Fungus/Flowchart/Scripts/Block.cs
  3. 15
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs

42
Assets/Fungus/Flowchart/Resources/Flowchart.prefab

@ -9,8 +9,9 @@ GameObject:
m_Component:
- 4: {fileID: 467082}
- 114: {fileID: 11430050}
- 114: {fileID: 11467182}
- 114: {fileID: 11417010}
- 114: {fileID: 11433304}
- 114: {fileID: 11462346}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
@ -41,7 +42,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentSequence: {fileID: 11467182}
parentBlock: {fileID: 0}
--- !u!114 &11430050
MonoBehaviour:
m_ObjectHideFlags: 1
@ -56,15 +57,15 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
sequenceViewHeight: 400
blockViewHeight: 400
zoom: 1
scrollViewRect:
serializedVersion: 2
x: -340
x: -343
y: -340
width: 926
height: 840
selectedSequence: {fileID: 0}
width: 1114
height: 859
selectedBlock: {fileID: 11433304}
selectedCommands: []
variables: []
description:
@ -72,8 +73,8 @@ MonoBehaviour:
colorCommands: 1
hideComponents: 1
saveSelection: 1
nextCommandId: 0
--- !u!114 &11467182
nextItemId: 1
--- !u!114 &11433304
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
@ -86,15 +87,28 @@ MonoBehaviour:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 60
y: 60
width: 126
x: 67
y: 69
width: 120
height: 40
sequenceName: New Sequence
itemId: 0
blockName: New Block
description:
runSlowInEditor: 1
eventHandler: {fileID: 11417010}
eventHandler: {fileID: 11462346}
commandList: []
--- !u!114 &11462346
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: 11433304}
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1

3
Assets/Fungus/Flowchart/Scripts/Block.cs

@ -21,6 +21,9 @@ namespace Fungus
[AddComponentMenu("")]
public class Block : Node
{
[HideInInspector]
public int itemId = -1; // Invalid flowchart item id
[FormerlySerializedAs("sequenceName")]
public string blockName = "New Block";

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

@ -129,10 +129,19 @@ namespace Fungus
public virtual void OnEnable()
{
// Assign an item id to any command that doesn't have one yet.
// Assign an item id to any block or command that doesn't have one yet.
// This should only happen after loading a legacy Flowchart
Block[] blocks = GetComponentsInChildren<Block>();
foreach (Block block in blocks)
{
if (block.itemId == -1)
{
block.itemId = NextItemId();
}
}
Command[] commands = GetComponentsInChildren<Command>();
foreach (Command command in commands)
foreach (Command command in commands)
{
if (command.itemId == -1)
{
@ -156,6 +165,8 @@ namespace Fungus
b.nodeRect.x = position.x;
b.nodeRect.y = position.y;
b.blockName = GetUniqueBlockKey(b.blockName, b);
b.itemId = NextItemId();
return b;
}

Loading…
Cancel
Save