diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs index b40e96c4..2dd72482 100644 --- a/Assets/Fungus/Scripts/Commands/Menu.cs +++ b/Assets/Fungus/Scripts/Commands/Menu.cs @@ -41,7 +41,7 @@ namespace Fungus.Commands if (setMenuDialog != null) { // Override the active menu dialog - MenuDialog.activeMenuDialog = setMenuDialog; + MenuDialog.ActiveMenuDialog = setMenuDialog; } bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0); diff --git a/Assets/Fungus/Scripts/Commands/Say.cs b/Assets/Fungus/Scripts/Commands/Say.cs index f322d648..fe1af4eb 100644 --- a/Assets/Fungus/Scripts/Commands/Say.cs +++ b/Assets/Fungus/Scripts/Commands/Say.cs @@ -69,12 +69,12 @@ namespace Fungus.Commands // Override the active say dialog if needed if (character != null && character.SetSayDialog != null) { - SayDialog.activeSayDialog = character.SetSayDialog; + SayDialog.ActiveSayDialog = character.SetSayDialog; } if (setSayDialog != null) { - SayDialog.activeSayDialog = setSayDialog; + SayDialog.ActiveSayDialog = setSayDialog; } var sayDialog = SayDialog.GetSayDialog(); diff --git a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs index 152191f1..0661f512 100644 --- a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs +++ b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs @@ -21,7 +21,7 @@ namespace Fungus.Commands { if (menuDialog != null) { - MenuDialog.activeMenuDialog = menuDialog; + MenuDialog.ActiveMenuDialog = menuDialog; } Continue(); diff --git a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs index cb088169..b7662546 100644 --- a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs +++ b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs @@ -21,7 +21,7 @@ namespace Fungus.Commands { if (sayDialog != null) { - SayDialog.activeSayDialog = sayDialog; + SayDialog.ActiveSayDialog = sayDialog; } Continue(); diff --git a/Assets/Fungus/Scripts/Components/CameraController.cs b/Assets/Fungus/Scripts/Components/CameraController.cs index 3ed376a5..746ec9cb 100644 --- a/Assets/Fungus/Scripts/Components/CameraController.cs +++ b/Assets/Fungus/Scripts/Components/CameraController.cs @@ -68,20 +68,6 @@ namespace Fungus return instance; } - public static Texture2D CreateColorTexture(Color color, int width, int height) - { - Color[] pixels = new Color[width * height]; - for (int i = 0; i < pixels.Length; i++) - { - pixels[i] = color; - } - Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false); - texture.SetPixels(pixels); - texture.Apply(); - - return texture; - } - protected virtual void OnGUI() { if (swipePanActive) @@ -366,6 +352,23 @@ namespace Fungus #region Public methods + /// + /// Creates a flat colored texture. + /// + public static Texture2D CreateColorTexture(Color color, int width, int height) + { + Color[] pixels = new Color[width * height]; + for (int i = 0; i < pixels.Length; i++) + { + pixels[i] = color; + } + Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false); + texture.SetPixels(pixels); + texture.Apply(); + + return texture; + } + /// /// Full screen texture used for screen fade effect. /// diff --git a/Assets/Fungus/Scripts/Components/DialogInput.cs b/Assets/Fungus/Scripts/Components/DialogInput.cs index b601ef6a..b9a5b2f5 100644 --- a/Assets/Fungus/Scripts/Components/DialogInput.cs +++ b/Assets/Fungus/Scripts/Components/DialogInput.cs @@ -102,9 +102,9 @@ namespace Fungus if (ignoreMenuClicks) { // Ignore input events if a Menu is being displayed - if (MenuDialog.activeMenuDialog != null && - MenuDialog.activeMenuDialog.IsActive() && - MenuDialog.activeMenuDialog.DisplayedOptionsCount > 0) + if (MenuDialog.ActiveMenuDialog != null && + MenuDialog.ActiveMenuDialog.IsActive() && + MenuDialog.ActiveMenuDialog.DisplayedOptionsCount > 0) { dialogClickedFlag = false; nextLineInputFlag = false; diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 12fd828e..c359b56e 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -86,28 +86,12 @@ namespace Fungus [Tooltip("The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.")] [SerializeField] protected string luaBindingName = "flowchart"; + protected static List cachedFlowcharts = new List(); + protected static bool eventSystemPresent; protected StringSubstituter stringSubstituer; - /// - /// Cached list of flowchart objects in the scene for fast lookup. - /// - public static List cachedFlowcharts = new List(); - - /// - /// Sends a message to all Flowchart objects in the current scene. - /// Any block with a matching MessageReceived event handler will start executing. - /// - public static void BroadcastFungusMessage(string messageName) - { - MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType(); - foreach (MessageReceived eventHandler in eventHandlers) - { - eventHandler.OnSendFungusMessage(messageName); - } - } - #if UNITY_5_4_OR_NEWER protected virtual void Awake() { @@ -288,6 +272,24 @@ namespace Fungus #region Public methods + /// + /// Cached list of flowchart objects in the scene for fast lookup. + /// + public static List CachedFlowcharts { get { return cachedFlowcharts; } } + + /// + /// Sends a message to all Flowchart objects in the current scene. + /// Any block with a matching MessageReceived event handler will start executing. + /// + public static void BroadcastFungusMessage(string messageName) + { + MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType(); + foreach (MessageReceived eventHandler in eventHandlers) + { + eventHandler.OnSendFungusMessage(messageName); + } + } + /// /// Scroll position of Flowchart editor window. /// diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs index bde6070a..f5095faa 100644 --- a/Assets/Fungus/Scripts/Components/Localization.cs +++ b/Assets/Fungus/Scripts/Components/Localization.cs @@ -93,26 +93,6 @@ namespace Fungus initialized = true; } - /// - /// Looks up the specified string in the localized strings table. - /// For this to work, a localization file and active language must have been set previously. - /// Return null if the string is not found. - /// - public static string GetLocalizedString(string stringId) - { - if (localizedStrings == null) - { - return null; - } - - if (localizedStrings.ContainsKey(stringId)) - { - return localizedStrings[stringId]; - } - - return null; - } - // Build a cache of all the localizeable objects in the scene protected virtual void CacheLocalizeableObjects() { @@ -249,6 +229,26 @@ namespace Fungus #region Public methods + /// + /// Looks up the specified string in the localized strings table. + /// For this to work, a localization file and active language must have been set previously. + /// Return null if the string is not found. + /// + public static string GetLocalizedString(string stringId) + { + if (localizedStrings == null) + { + return null; + } + + if (localizedStrings.ContainsKey(stringId)) + { + return localizedStrings[stringId]; + } + + return null; + } + /// /// Language to use at startup, usually defined by a two letter language code (e.g DE = German). /// diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index 9c3db6ef..6637b093 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -22,37 +22,6 @@ namespace Fungus protected Slider cachedSlider; - // Currently active Menu Dialog used to display Menu options - public static MenuDialog activeMenuDialog; - - public static MenuDialog GetMenuDialog() - { - if (activeMenuDialog == null) - { - // Use first Menu Dialog found in the scene (if any) - var md = GameObject.FindObjectOfType(); - if (md != null) - { - activeMenuDialog = md; - } - - if (activeMenuDialog == null) - { - // Auto spawn a menu dialog object from the prefab - GameObject prefab = Resources.Load("Prefabs/MenuDialog"); - if (prefab != null) - { - GameObject go = Instantiate(prefab) as GameObject; - go.SetActive(false); - go.name = "MenuDialog"; - activeMenuDialog = go.GetComponent(); - } - } - } - - return activeMenuDialog; - } - protected virtual void Awake() { Button[] optionButtons = GetComponentsInChildren