Browse Source

Support for Flowchart versioning and initialization

master
Brian Dean Jennings 9 years ago
parent
commit
8c5facccda
  1. 32
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs

32
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -15,6 +15,17 @@ namespace Fungus
[ExecuteInEditMode]
public class Flowchart : MonoBehaviour
{
/**
* Current version used to compare with the previous version so older versions can be custom-updated from previous versions.
*/
public const string CURRENT_VERSION = "1.0";
/**
* Variable to track flowchart's version and if initial set up has completed.
*/
[HideInInspector]
public string version;
/**
* Scroll position of Flowchart editor window.
*/
@ -143,6 +154,7 @@ namespace Fungus
CheckItemIds();
CleanupComponents();
UpdateVersion();
}
public virtual void OnDisable()
@ -231,6 +243,26 @@ namespace Fungus
}
}
private void UpdateVersion()
{
// If versions match, then we are already using the latest.
if (version == CURRENT_VERSION) return;
switch (version)
{
// Version never set, so we are initializing on first creation or this flowchart is pre-versioning.
case null:
Initialize();
break;
}
version = CURRENT_VERSION;
}
protected virtual void Initialize()
{
}
protected virtual Block CreateBlockComponent(GameObject parent)
{
Block block = parent.AddComponent<Block>();

Loading…
Cancel
Save