Browse Source

Fixed Child Object gets deleted when having a flowchart on parent and child. #475

master
Christopher 9 years ago
parent
commit
6a7878552e
  1. 4
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs
  2. 2
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs
  3. 2
      Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs
  4. 34
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  5. 2
      Assets/Fungus/Narrative/Scripts/Localization.cs
  6. 2
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs

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

@ -420,7 +420,7 @@ namespace Fungus
int selectedIndex = 0; int selectedIndex = 0;
blockNames.Add(nullLabel); blockNames.Add(nullLabel);
Block[] blocks = flowchart.GetComponentsInChildren<Block>(true); Block[] blocks = flowchart.GetComponents<Block>();
for (int i = 0; i < blocks.Length; ++i) for (int i = 0; i < blocks.Length; ++i)
{ {
blockNames.Add(new GUIContent(blocks[i].blockName)); blockNames.Add(new GUIContent(blocks[i].blockName));
@ -458,7 +458,7 @@ namespace Fungus
int selectedIndex = 0; int selectedIndex = 0;
blockNames.Add(nullLabel); blockNames.Add(nullLabel);
Block[] blocks = flowchart.GetComponentsInChildren<Block>(); Block[] blocks = flowchart.GetComponents<Block>();
for (int i = 0; i < blocks.Length; ++i) for (int i = 0; i < blocks.Length; ++i)
{ {
blockNames.Add(new GUIContent(blocks[i].name)); blockNames.Add(new GUIContent(blocks[i].name));

2
Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

@ -217,7 +217,7 @@ namespace Fungus
protected virtual void DrawFlowchartView(Flowchart flowchart) protected virtual void DrawFlowchartView(Flowchart flowchart)
{ {
Block[] blocks = flowchart.GetComponentsInChildren<Block>(true); Block[] blocks = flowchart.GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {

2
Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs

@ -36,7 +36,7 @@ namespace Fungus
MessageReceived[] receivers = null; MessageReceived[] receivers = null;
if (messageTarget == MessageTarget.SameFlowchart) if (messageTarget == MessageTarget.SameFlowchart)
{ {
receivers = flowchart.GetComponentsInChildren<MessageReceived>(); receivers = flowchart.GetComponents<MessageReceived>();
} }
else else
{ {

34
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -169,13 +169,13 @@ namespace Fungus
public int NextItemId() public int NextItemId()
{ {
int maxId = -1; int maxId = -1;
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
maxId = Math.Max(maxId, block.itemId); maxId = Math.Max(maxId, block.itemId);
} }
Command[] commands = GetComponentsInChildren<Command>(); Command[] commands = GetComponents<Command>();
foreach (Command command in commands) foreach (Command command in commands)
{ {
maxId = Math.Max(maxId, command.itemId); maxId = Math.Max(maxId, command.itemId);
@ -275,7 +275,7 @@ namespace Fungus
// Make sure item ids are unique and monotonically increasing. // Make sure item ids are unique and monotonically increasing.
// This should always be the case, but some legacy Flowcharts may have issues. // This should always be the case, but some legacy Flowcharts may have issues.
List<int> usedIds = new List<int>(); List<int> usedIds = new List<int>();
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
if (block.itemId == -1 || if (block.itemId == -1 ||
@ -286,7 +286,7 @@ namespace Fungus
usedIds.Add(block.itemId); usedIds.Add(block.itemId);
} }
Command[] commands = GetComponentsInChildren<Command>(); Command[] commands = GetComponents<Command>();
foreach (Command command in commands) foreach (Command command in commands)
{ {
if (command.itemId == -1 || if (command.itemId == -1 ||
@ -304,7 +304,7 @@ namespace Fungus
// Unreferenced components don't have any effect on the flowchart behavior, but // Unreferenced components don't have any effect on the flowchart behavior, but
// they waste memory so should be cleared out periodically. // they waste memory so should be cleared out periodically.
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
// Remove any null entries in the variables list // Remove any null entries in the variables list
// It shouldn't happen but it seemed to occur for a user on the forum // It shouldn't happen but it seemed to occur for a user on the forum
@ -380,7 +380,7 @@ namespace Fungus
*/ */
public virtual Block FindBlock(string blockName) public virtual Block FindBlock(string blockName)
{ {
Block [] blocks = GetComponentsInChildren<Block>(); Block [] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
if (block.blockName == blockName) if (block.blockName == blockName)
@ -400,7 +400,7 @@ namespace Fungus
public virtual bool ExecuteBlock(string blockName) public virtual bool ExecuteBlock(string blockName)
{ {
Block block = null; Block block = null;
foreach (Block b in GetComponentsInChildren<Block>()) foreach (Block b in GetComponents<Block>())
{ {
if (b.blockName == blockName) if (b.blockName == blockName)
{ {
@ -455,7 +455,7 @@ namespace Fungus
*/ */
public virtual void StopAllBlocks() public virtual void StopAllBlocks()
{ {
Block [] blocks = GetComponentsInChildren<Block>(); Block [] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
if (block.IsExecuting()) if (block.IsExecuting())
@ -471,7 +471,7 @@ namespace Fungus
*/ */
public virtual void SendFungusMessage(string messageName) public virtual void SendFungusMessage(string messageName)
{ {
MessageReceived[] eventHandlers = GetComponentsInChildren<MessageReceived>(); MessageReceived[] eventHandlers = GetComponents<MessageReceived>();
foreach (MessageReceived eventHandler in eventHandlers) foreach (MessageReceived eventHandler in eventHandlers)
{ {
eventHandler.OnSendFungusMessage(messageName); eventHandler.OnSendFungusMessage(messageName);
@ -554,7 +554,7 @@ namespace Fungus
baseKey = "New Block"; baseKey = "New Block";
} }
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
string key = baseKey; string key = baseKey;
while (true) while (true)
@ -837,7 +837,7 @@ namespace Fungus
{ {
if (hideComponents) if (hideComponents)
{ {
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
block.hideFlags = HideFlags.HideInInspector; block.hideFlags = HideFlags.HideInInspector;
@ -847,13 +847,13 @@ namespace Fungus
} }
} }
Command[] commands = GetComponentsInChildren<Command>(); Command[] commands = GetComponents<Command>();
foreach (Command command in commands) foreach (Command command in commands)
{ {
command.hideFlags = HideFlags.HideInInspector; command.hideFlags = HideFlags.HideInInspector;
} }
EventHandler[] eventHandlers = GetComponentsInChildren<EventHandler>(); EventHandler[] eventHandlers = GetComponents<EventHandler>();
foreach (EventHandler eventHandler in eventHandlers) foreach (EventHandler eventHandler in eventHandlers)
{ {
eventHandler.hideFlags = HideFlags.HideInInspector; eventHandler.hideFlags = HideFlags.HideInInspector;
@ -861,7 +861,7 @@ namespace Fungus
} }
else else
{ {
MonoBehaviour[] monoBehaviours = GetComponentsInChildren<MonoBehaviour>(); MonoBehaviour[] monoBehaviours = GetComponents<MonoBehaviour>();
foreach (MonoBehaviour monoBehaviour in monoBehaviours) foreach (MonoBehaviour monoBehaviour in monoBehaviours)
{ {
if (monoBehaviour == null) if (monoBehaviour == null)
@ -893,7 +893,7 @@ namespace Fungus
{ {
if (resetCommands) if (resetCommands)
{ {
Command[] commands = GetComponentsInChildren<Command>(); Command[] commands = GetComponents<Command>();
foreach (Command command in commands) foreach (Command command in commands)
{ {
command.OnReset(); command.OnReset();
@ -932,7 +932,7 @@ namespace Fungus
*/ */
public virtual bool HasExecutingBlocks() public virtual bool HasExecutingBlocks()
{ {
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
if (block.IsExecuting()) if (block.IsExecuting())
@ -950,7 +950,7 @@ namespace Fungus
{ {
List<Block> executingBlocks = new List<Block>(); List<Block> executingBlocks = new List<Block>();
Block[] blocks = GetComponentsInChildren<Block>(); Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
if (block.IsExecuting()) if (block.IsExecuting())

2
Assets/Fungus/Narrative/Scripts/Localization.cs

@ -223,7 +223,7 @@ namespace Fungus
Flowchart[] flowcharts = GameObject.FindObjectsOfType<Flowchart>(); Flowchart[] flowcharts = GameObject.FindObjectsOfType<Flowchart>();
foreach (Flowchart flowchart in flowcharts) foreach (Flowchart flowchart in flowcharts)
{ {
Block[] blocks = flowchart.GetComponentsInChildren<Block>(); Block[] blocks = flowchart.GetComponents<Block>();
foreach (Block block in blocks) foreach (Block block in blocks)
{ {
foreach (Command command in block.commandList) foreach (Command command in block.commandList)

2
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs vendored

@ -141,7 +141,7 @@ namespace Fungus
InitLuaScriptFiles(); InitLuaScriptFiles();
// Initialize any attached initializer components (e.g. LuaUtils) // Initialize any attached initializer components (e.g. LuaUtils)
Initializer[] initializers = GetComponentsInChildren<Initializer>(); Initializer[] initializers = GetComponents<Initializer>();
foreach (Initializer initializer in initializers) foreach (Initializer initializer in initializers)
{ {
initializer.Initialize(); initializer.Initialize();

Loading…
Cancel
Save