diff --git a/Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs b/Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs index f958ec8c..f34bacd3 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs @@ -16,16 +16,16 @@ namespace Fungus public class PlayAnimState : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData animator = new AnimatorData(); + [SerializeField] protected AnimatorData animator = new AnimatorData(); [Tooltip("Name of the state you want to play")] - public StringData stateName = new StringData(); + [SerializeField] protected StringData stateName = new StringData(); [Tooltip("Layer to play animation on")] - public IntegerData layer = new IntegerData(-1); + [SerializeField] protected IntegerData layer = new IntegerData(-1); [Tooltip("Start time of animation")] - public FloatData time = new FloatData(0f); + [SerializeField] protected FloatData time = new FloatData(0f); public override void OnEnter() { diff --git a/Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs b/Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs index 9809d246..27a270fd 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs @@ -18,10 +18,10 @@ namespace Fungus public class ResetAnimTrigger : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData _animator; + [SerializeField] protected AnimatorData _animator; [Tooltip("Name of the trigger Animator parameter that will be reset")] - public StringData _parameterName; + [SerializeField] protected StringData _parameterName; public override void OnEnter() { diff --git a/Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs b/Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs index 30e22f5c..b7ef6dd4 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs @@ -18,13 +18,13 @@ namespace Fungus public class SetAnimBool : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData _animator; + [SerializeField] protected AnimatorData _animator; [Tooltip("Name of the boolean Animator parameter that will have its value changed")] - public StringData _parameterName; + [SerializeField] protected StringData _parameterName; [Tooltip("The boolean value to set the parameter to")] - public BooleanData value; + [SerializeField] protected BooleanData value; public override void OnEnter() { diff --git a/Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs b/Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs index 2040c701..3b4ca2af 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs @@ -18,13 +18,13 @@ namespace Fungus public class SetAnimFloat : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData _animator; + [SerializeField] protected AnimatorData _animator; [Tooltip("Name of the float Animator parameter that will have its value changed")] - public StringData _parameterName; + [SerializeField] protected StringData _parameterName; [Tooltip("The float value to set the parameter to")] - public FloatData value; + [SerializeField] protected FloatData value; public override void OnEnter() { diff --git a/Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs b/Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs index 96d723f5..39e77e5e 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs @@ -18,13 +18,13 @@ namespace Fungus public class SetAnimInteger : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData _animator; + [SerializeField] protected AnimatorData _animator; [Tooltip("Name of the integer Animator parameter that will have its value changed")] - public StringData _parameterName; + [SerializeField] protected StringData _parameterName; [Tooltip("The integer value to set the parameter to")] - public IntegerData value; + [SerializeField] protected IntegerData value; public override void OnEnter() { diff --git a/Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs b/Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs index da300a21..6b9f9cca 100644 --- a/Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs +++ b/Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs @@ -18,10 +18,10 @@ namespace Fungus public class SetAnimTrigger : Command { [Tooltip("Reference to an Animator component in a game object")] - public AnimatorData _animator; + [SerializeField] protected AnimatorData _animator; [Tooltip("Name of the trigger Animator parameter that will have its value changed")] - public StringData _parameterName; + [SerializeField] protected StringData _parameterName; public override void OnEnter() { diff --git a/Assets/Fungus/Audio/Editor/ControlAudioEditor.cs b/Assets/Fungus/Audio/Editor/ControlAudioEditor.cs index e6f7af58..2e06d4b1 100644 --- a/Assets/Fungus/Audio/Editor/ControlAudioEditor.cs +++ b/Assets/Fungus/Audio/Editor/ControlAudioEditor.cs @@ -49,11 +49,11 @@ namespace Fungus EditorGUILayout.PropertyField(controlProp); EditorGUILayout.PropertyField(audioSourceProp); string fadeLabel = "Fade Out Duration"; - if (t.control != ControlAudio.controlType.StopLoop && t.control != ControlAudio.controlType.PauseLoop) + if (t.Control != ControlAudio.controlType.StopLoop && t.Control != ControlAudio.controlType.PauseLoop) { fadeLabel = "Fade In Duration"; string volumeLabel = "End Volume"; - if (t.control == ControlAudio.controlType.ChangeVolume) + if (t.Control == ControlAudio.controlType.ChangeVolume) { fadeLabel = "Fade Duration"; volumeLabel = "New Volume"; diff --git a/Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs index a8abfd46..a23236f1 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs @@ -25,24 +25,26 @@ namespace Fungus } [Tooltip("What to do to audio")] - public controlType control; + [SerializeField] protected controlType control; + + public controlType Control { get { return control; } } [Tooltip("Audio clip to play")] - public AudioSourceData _audioSource; + [SerializeField] protected AudioSourceData _audioSource; [Range(0,1)] [Tooltip("Start audio at this volume")] - public float startVolume = 1; + [SerializeField] protected float startVolume = 1; [Range(0,1)] [Tooltip("End audio at this volume")] - public float endVolume = 1; + [SerializeField] protected float endVolume = 1; [Tooltip("Time to fade between current volume level and target volume level.")] - public float fadeDuration; + [SerializeField] protected float fadeDuration; [Tooltip("Wait until this command has finished before executing the next command.")] - public bool waitUntilFinished = false; + [SerializeField] protected bool waitUntilFinished = false; public override void OnEnter() { diff --git a/Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs b/Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs index a4e97d89..a2a124af 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs @@ -15,16 +15,16 @@ namespace Fungus public class PlayMusic : Command { [Tooltip("Music sound clip to play")] - public AudioClip musicClip; + [SerializeField] protected AudioClip musicClip; [Tooltip("Time to begin playing in seconds. If the audio file is compressed, the time index may be inaccurate.")] - public float atTime; + [SerializeField] protected float atTime; [Tooltip("The music will start playing again at end.")] - public bool loop = true; + [SerializeField] protected bool loop = true; [Tooltip("Length of time to fade out previous playing music.")] - public float fadeDuration = 1f; + [SerializeField] protected float fadeDuration = 1f; public override void OnEnter() { diff --git a/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs b/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs index 2d4b1839..a5c0f6b0 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs @@ -15,14 +15,14 @@ namespace Fungus public class PlaySound : Command { [Tooltip("Sound effect clip to play")] - public AudioClip soundClip; + [SerializeField] protected AudioClip soundClip; [Range(0,1)] [Tooltip("Volume level of the sound effect")] - public float volume = 1; + [SerializeField] protected float volume = 1; [Tooltip("Wait until the sound has finished playing before continuing execution.")] - public bool waitUntilFinished; + [SerializeField] protected bool waitUntilFinished; public override void OnEnter() { diff --git a/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs index be6259ec..86bbe13e 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs @@ -18,13 +18,13 @@ protected SfxrSynth _synth = new SfxrSynth(); [Tooltip("Transform to use for positional audio")] - public Transform ParentTransform = null; + [SerializeField] protected Transform ParentTransform = null; [Tooltip("Settings string which describes the audio")] - public StringDataMulti _SettingsString = new StringDataMulti(""); + [SerializeField] protected StringDataMulti _SettingsString = new StringDataMulti(""); [Tooltip("Time to wait before executing the next command")] - public float waitDuration = 0; + [SerializeField] protected float waitDuration = 0; //Call this if the settings have changed protected void UpdateCache() { diff --git a/Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs b/Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs index c565ea7c..0adc2cf9 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs @@ -16,14 +16,14 @@ namespace Fungus { [Range(0,1)] [Tooltip("Global pitch level for audio played using the Play Music and Play Sound commands")] - public float pitch = 1; + [SerializeField] protected float pitch = 1; [Range(0,30)] [Tooltip("Time to fade between current pitch level and target pitch level.")] - public float fadeDuration; + [SerializeField] protected float fadeDuration; [Tooltip("Wait until the pitch change has finished before executing next command")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; public override void OnEnter() { diff --git a/Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs b/Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs index ab90d8c5..ccdd9d4a 100644 --- a/Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs +++ b/Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs @@ -16,14 +16,14 @@ namespace Fungus { [Range(0,1)] [Tooltip("Global volume level for audio played using Play Music and Play Sound")] - public float volume = 1f; + [SerializeField] protected float volume = 1f; [Range(0,30)] [Tooltip("Time to fade between current volume level and target volume level.")] - public float fadeDuration = 1f; + [SerializeField] protected float fadeDuration = 1f; [Tooltip("Wait until the volume fade has completed before continuing.")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; public override void OnEnter() { diff --git a/Assets/Fungus/Camera/Editor/ViewEditor.cs b/Assets/Fungus/Camera/Editor/ViewEditor.cs index 6a5c8e4e..550386ca 100644 --- a/Assets/Fungus/Camera/Editor/ViewEditor.cs +++ b/Assets/Fungus/Camera/Editor/ViewEditor.cs @@ -176,11 +176,11 @@ namespace Fungus Flowchart flowchart = FlowchartWindow.GetFlowchart(); if (flowchart != null) { - foreach (Command command in flowchart.selectedCommands) + foreach (Command command in flowchart.SelectedCommands) { MoveToView moveToViewCommand = command as MoveToView; if (moveToViewCommand != null && - moveToViewCommand.targetView == view) + moveToViewCommand.TargetView == view) { highlight = true; } @@ -188,7 +188,7 @@ namespace Fungus { FadeToView fadeToViewCommand = command as FadeToView; if (fadeToViewCommand != null && - fadeToViewCommand.targetView == view) + fadeToViewCommand.TargetView == view) { highlight = true; } diff --git a/Assets/Fungus/Camera/Scripts/CameraController.cs b/Assets/Fungus/Camera/Scripts/CameraController.cs index 661658df..59e3551d 100644 --- a/Assets/Fungus/Camera/Scripts/CameraController.cs +++ b/Assets/Fungus/Camera/Scripts/CameraController.cs @@ -20,41 +20,39 @@ namespace Fungus /** * Full screen texture used for screen fade effect. */ - public Texture2D screenFadeTexture; - + [SerializeField] protected Texture2D screenFadeTexture; + + public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } } + /** * Icon to display when swipe pan mode is active. */ - public Texture2D swipePanIcon; + [SerializeField] protected Texture2D swipePanIcon; /** * Position of continue and swipe icons in normalized screen space coords. * (0,0) = top left, (1,1) = bottom right */ - public Vector2 swipeIconPosition = new Vector2(1,0); + [SerializeField] protected Vector2 swipeIconPosition = new Vector2(1,0); /** * Set the camera z coordinate to a fixed value every frame. */ - public bool setCameraZ = true; + [SerializeField] protected bool setCameraZ = true; /** * Fixed Z coordinate of main camera. */ - public float cameraZ = -10f; + [SerializeField] protected float cameraZ = -10f; + + [SerializeField] protected Camera swipeCamera; - [HideInInspector] - public bool waiting; - protected float fadeAlpha = 0f; // Swipe panning control - [HideInInspector] - public bool swipePanActive; - public Camera swipeCamera; + protected bool swipePanActive; - [HideInInspector] - public float swipeSpeedMultiplier = 1f; + protected float swipeSpeedMultiplier = 1f; protected View swipePanViewA; protected View swipePanViewB; protected Vector3 previousMousePos; diff --git a/Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs b/Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs index 5acc9a5b..113aae4e 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs @@ -17,42 +17,36 @@ namespace Fungus public class FadeScreen : Command { [Tooltip("Time for fade effect to complete")] - public float duration = 1f; + [SerializeField] protected float duration = 1f; [Tooltip("Current target alpha transparency value. The fade gradually adjusts the alpha to approach this target value.")] - public float targetAlpha = 1f; + [SerializeField] protected float targetAlpha = 1f; [Tooltip("Wait until the fade has finished before executing next command")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; [Tooltip("Color to render fullscreen fade texture with when screen is obscured.")] - public Color fadeColor = Color.black; + [SerializeField] protected Color fadeColor = Color.black; [Tooltip("Optional texture to use when rendering the fullscreen fade effect.")] - public Texture2D fadeTexture; + [SerializeField] protected Texture2D fadeTexture; public override void OnEnter() { CameraController cameraController = CameraController.GetInstance(); - if (waitUntilFinished) - { - cameraController.waiting = true; - } - if (fadeTexture) { - cameraController.screenFadeTexture = fadeTexture; + cameraController.ScreenFadeTexture = fadeTexture; } else { - cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); + cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); } cameraController.Fade(targetAlpha, duration, delegate { if (waitUntilFinished) { - cameraController.waiting = false; Continue(); } }); diff --git a/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs b/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs index da7a2677..301eca89 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs @@ -16,25 +16,27 @@ namespace Fungus public class FadeToView : Command { [Tooltip("Time for fade effect to complete")] - public float duration = 1f; + [SerializeField] protected float duration = 1f; [Tooltip("Fade from fully visible to opaque at start of fade")] - public bool fadeOut = true; + [SerializeField] protected bool fadeOut = true; [Tooltip("View to transition to when Fade is complete")] - public View targetView; + [SerializeField] protected View targetView; + + public View TargetView { get { return targetView; } } [Tooltip("Wait until the fade has finished before executing next command")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; [Tooltip("Color to render fullscreen fade texture with when screen is obscured.")] - public Color fadeColor = Color.black; + [SerializeField] protected Color fadeColor = Color.black; [Tooltip("Optional texture to use when rendering the fullscreen fade effect.")] - public Texture2D fadeTexture; + [SerializeField] protected Texture2D fadeTexture; [Tooltip("Camera to use for the fade. Will use main camera if set to none.")] - public Camera targetCamera; + [SerializeField] protected Camera targetCamera; protected virtual void AcquireCamera() { @@ -67,24 +69,18 @@ namespace Fungus CameraController cameraController = CameraController.GetInstance(); - if (waitUntilFinished) - { - cameraController.waiting = true; - } - if (fadeTexture) { - cameraController.screenFadeTexture = fadeTexture; + cameraController.ScreenFadeTexture = fadeTexture; } else { - cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); + cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32); } cameraController.FadeToView(targetCamera, targetView, duration, fadeOut, delegate { if (waitUntilFinished) { - cameraController.waiting = false; Continue(); } }); diff --git a/Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs b/Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs index bb0eb781..ff1741ff 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs @@ -22,7 +22,7 @@ namespace Fungus Windowed } - public FullscreenMode fullscreenMode; + [SerializeField] protected FullscreenMode fullscreenMode; public override void OnEnter() { diff --git a/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs b/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs index e8085121..8ef41774 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs @@ -16,16 +16,18 @@ namespace Fungus public class MoveToView : Command { [Tooltip("Time for move effect to complete")] - public float duration = 1; + [SerializeField] protected float duration = 1; [Tooltip("View to transition to when move is complete")] - public Fungus.View targetView; + [SerializeField] protected View targetView; + + public View TargetView { get { return targetView; } } [Tooltip("Wait until the fade has finished before executing next command")] - public bool waitUntilFinished = true; + [SerializeField] protected bool waitUntilFinished = true; [Tooltip("Camera to use for the pan. Will use main camera if set to none.")] - public Camera targetCamera; + [SerializeField] protected Camera targetCamera; protected virtual void AcquireCamera() { @@ -58,11 +60,6 @@ namespace Fungus CameraController cameraController = CameraController.GetInstance(); - if (waitUntilFinished) - { - cameraController.waiting = true; - } - Vector3 targetPosition = targetView.transform.position; Quaternion targetRotation = targetView.transform.rotation; float targetSize = targetView.viewSize; @@ -70,7 +67,6 @@ namespace Fungus cameraController.PanToPosition(targetCamera, targetPosition, targetRotation, targetSize, duration, delegate { if (waitUntilFinished) { - cameraController.waiting = false; Continue(); } }); diff --git a/Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs b/Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs index 3e33ca57..ac4ef411 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs @@ -16,13 +16,13 @@ namespace Fungus public class ShakeCamera : Command { [Tooltip("Time for camera shake effect to complete")] - public float duration = 0.5f; + [SerializeField] protected float duration = 0.5f; [Tooltip("Magnitude of shake effect in x & y axes")] - public Vector2 amount = new Vector2(1, 1); + [SerializeField] protected Vector2 amount = new Vector2(1, 1); [Tooltip("Wait until the shake effect has finished before executing next command")] - public bool waitUntilFinished; + [SerializeField] protected bool waitUntilFinished; public override void OnEnter() { diff --git a/Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs b/Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs index d4629578..02297cda 100644 --- a/Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs +++ b/Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs @@ -16,19 +16,19 @@ namespace Fungus public class StartSwipe : Command { [Tooltip("Defines one extreme of the scrollable area that the player can pan around")] - public View viewA; + [SerializeField] protected View viewA; [Tooltip("Defines one extreme of the scrollable area that the player can pan around")] - public View viewB; + [SerializeField] protected View viewB; [Tooltip("Time to move the camera to a valid starting position between the two views")] - public float duration = 0.5f; + [SerializeField] protected float duration = 0.5f; [Tooltip("Multiplier factor for speed of swipe pan")] - public float speedMultiplier = 1f; + [SerializeField] protected float speedMultiplier = 1f; [Tooltip("Camera to use for the pan. Will use main camera if set to none.")] - public Camera targetCamera; + [SerializeField] protected Camera targetCamera; public virtual void Start() { diff --git a/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs b/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs index 83854bef..4deddc94 100644 --- a/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs +++ b/Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs @@ -38,9 +38,9 @@ namespace Fungus Flowchart[] flowcharts = UnityEngine.Object.FindObjectsOfType(); foreach (Flowchart f in flowcharts) { - if (!f.saveSelection) + if (!f.SaveSelection) { - f.selectedBlock = null; + f.SelectedBlock = null; f.ClearSelectedCommands(); } } diff --git a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs index 0e5c1937..bb9b482d 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockEditor.cs @@ -64,7 +64,7 @@ namespace Fungus // Ensure block name is unique for this Flowchart Block block = target as Block; string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block); - if (uniqueName != block.blockName) + if (uniqueName != block.BlockName) { blockNameProperty.stringValue = uniqueName; } @@ -96,7 +96,7 @@ namespace Fungus SerializedProperty commandListProperty = serializedObject.FindProperty("commandList"); - if (block == flowchart.selectedBlock) + if (block == flowchart.SelectedBlock) { SerializedProperty descriptionProp = serializedObject.FindProperty("description"); EditorGUILayout.PropertyField(descriptionProp); @@ -106,22 +106,22 @@ namespace Fungus block.UpdateIndentLevels(); // Make sure each command has a reference to its parent block - foreach (Command command in block.commandList) + foreach (Command command in block.CommandList) { if (command == null) // Will be deleted from the list later on { continue; } - command.parentBlock = block; + command.ParentBlock = block; } ReorderableListGUI.Title("Commands"); CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0); - adaptor.nodeRect = block.nodeRect; + adaptor.nodeRect = block._NodeRect; ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu; - if (block.commandList.Count == 0) + if (block.CommandList.Count == 0) { EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info); } @@ -146,7 +146,7 @@ namespace Fungus // Copy keyboard shortcut if (e.type == EventType.ValidateCommand && e.commandName == "Copy") { - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { e.Use(); } @@ -161,7 +161,7 @@ namespace Fungus // Cut keyboard shortcut if (e.type == EventType.ValidateCommand && e.commandName == "Cut") { - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { e.Use(); } @@ -192,7 +192,7 @@ namespace Fungus // Duplicate keyboard shortcut if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate") { - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { e.Use(); } @@ -208,7 +208,7 @@ namespace Fungus // Delete keyboard shortcut if (e.type == EventType.ValidateCommand && e.commandName == "Delete") { - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { e.Use(); } @@ -311,9 +311,9 @@ namespace Fungus Block block = target as Block; System.Type currentType = null; - if (block.eventHandler != null) + if (block._EventHandler != null) { - currentType = block.eventHandler.GetType(); + currentType = block._EventHandler.GetType(); } string currentHandlerName = ""; @@ -372,9 +372,9 @@ namespace Fungus } EditorGUILayout.EndHorizontal(); - if (block.eventHandler != null) + if (block._EventHandler != null) { - EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block.eventHandler) as EventHandlerEditor; + EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block._EventHandler) as EventHandlerEditor; if (eventHandlerEditor != null) { eventHandlerEditor.DrawInspectorGUI(); @@ -395,16 +395,16 @@ namespace Fungus Undo.RecordObject(block, "Set Event Handler"); - if (block.eventHandler != null) + if (block._EventHandler != null) { - Undo.DestroyObjectImmediate(block.eventHandler); + Undo.DestroyObjectImmediate(block._EventHandler); } if (selectedType != null) { EventHandler newHandler = Undo.AddComponent(block.gameObject, selectedType) as EventHandler; - newHandler.parentBlock = block; - block.eventHandler = newHandler; + newHandler.ParentBlock = block; + block._EventHandler = newHandler; } // Because this is an async call, we need to force prefab instances to record changes @@ -428,7 +428,7 @@ namespace Fungus Block[] blocks = flowchart.GetComponents(); for (int i = 0; i < blocks.Length; ++i) { - blockNames.Add(new GUIContent(blocks[i].blockName)); + blockNames.Add(new GUIContent(blocks[i].BlockName)); if (block == blocks[i]) { @@ -641,16 +641,16 @@ namespace Fungus // Use index of last selected command in list, or end of list if nothing selected. int index = -1; - foreach (Command command in flowchart.selectedCommands) + foreach (Command command in flowchart.SelectedCommands) { - if (command.commandIndex + 1 > index) + if (command.CommandIndex + 1 > index) { - index = command.commandIndex + 1; + index = command.CommandIndex + 1; } } if (index == -1) { - index = block.commandList.Count; + index = block.CommandList.Count; } GenericMenu commandMenu = new GenericMenu(); @@ -738,20 +738,20 @@ namespace Fungus Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command; block.GetFlowchart().AddSelectedCommand(newCommand); - newCommand.parentBlock = block; - newCommand.itemId = flowchart.NextItemId(); + newCommand.ParentBlock = block; + newCommand.ItemId = flowchart.NextItemId(); // Let command know it has just been added to the block newCommand.OnCommandAdded(block); Undo.RecordObject(block, "Set command type"); - if (commandOperation.index < block.commandList.Count - 1) + if (commandOperation.index < block.CommandList.Count - 1) { - block.commandList.Insert(commandOperation.index, newCommand); + block.CommandList.Insert(commandOperation.index, newCommand); } else { - block.commandList.Add(newCommand); + block.CommandList.Add(newCommand); } // Because this is an async call, we need to force prefab instances to record changes @@ -774,12 +774,12 @@ namespace Fungus bool showPaste = false; bool showPlay = false; - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { showCut = true; showCopy = true; showDelete = true; - if (flowchart.selectedCommands.Count == 1 && Application.isPlaying) + if (flowchart.SelectedCommands.Count == 1 && Application.isPlaying) { showPlay = true; } @@ -852,14 +852,14 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || - flowchart.selectedBlock == null) + flowchart.SelectedBlock == null) { return; } flowchart.ClearSelectedCommands(); Undo.RecordObject(flowchart, "Select All"); - foreach (Command command in flowchart.selectedBlock.commandList) + foreach (Command command in flowchart.SelectedBlock.CommandList) { flowchart.AddSelectedCommand(command); } @@ -873,7 +873,7 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || - flowchart.selectedBlock == null) + flowchart.SelectedBlock == null) { return; } @@ -896,7 +896,7 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || - flowchart.selectedBlock == null) + flowchart.SelectedBlock == null) { return; } @@ -905,9 +905,9 @@ namespace Fungus commandCopyBuffer.Clear(); // Scan through all commands in execution order to see if each needs to be copied - foreach (Command command in flowchart.selectedBlock.commandList) + foreach (Command command in flowchart.SelectedBlock.CommandList) { - if (flowchart.selectedCommands.Contains(command)) + if (flowchart.SelectedCommands.Contains(command)) { System.Type type = command.GetType(); Command newCommand = Undo.AddComponent(commandCopyBuffer.gameObject, type) as Command; @@ -926,7 +926,7 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || - flowchart.selectedBlock == null) + flowchart.SelectedBlock == null) { return; } @@ -934,14 +934,14 @@ namespace Fungus CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance(); // Find where to paste commands in block (either at end or after last selected command) - int pasteIndex = flowchart.selectedBlock.commandList.Count; - if (flowchart.selectedCommands.Count > 0) + int pasteIndex = flowchart.SelectedBlock.CommandList.Count; + if (flowchart.SelectedCommands.Count > 0) { - for (int i = 0; i < flowchart.selectedBlock.commandList.Count; ++i) + for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; ++i) { - Command command = flowchart.selectedBlock.commandList[i]; + Command command = flowchart.SelectedBlock.CommandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (command == selectedCommand) { @@ -963,8 +963,8 @@ namespace Fungus Command pastedCommand = commands.Last(); if (pastedCommand != null) { - pastedCommand.itemId = flowchart.NextItemId(); - flowchart.selectedBlock.commandList.Insert(pasteIndex++, pastedCommand); + pastedCommand.ItemId = flowchart.NextItemId(); + flowchart.SelectedBlock.CommandList.Insert(pasteIndex++, pastedCommand); } } @@ -985,15 +985,15 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); if (flowchart == null || - flowchart.selectedBlock == null) + flowchart.SelectedBlock == null) { return; } int lastSelectedIndex = 0; - for (int i = flowchart.selectedBlock.commandList.Count - 1; i >= 0; --i) + for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >= 0; --i) { - Command command = flowchart.selectedBlock.commandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + Command command = flowchart.SelectedBlock.CommandList[i]; + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (command == selectedCommand) { @@ -1002,8 +1002,8 @@ namespace Fungus // Order of destruction is important here for undo to work Undo.DestroyObjectImmediate(command); - Undo.RecordObject(flowchart.selectedBlock, "Delete"); - flowchart.selectedBlock.commandList.RemoveAt(i); + Undo.RecordObject(flowchart.SelectedBlock, "Delete"); + flowchart.SelectedBlock.CommandList.RemoveAt(i); lastSelectedIndex = i; @@ -1015,9 +1015,9 @@ namespace Fungus Undo.RecordObject(flowchart, "Delete"); flowchart.ClearSelectedCommands(); - if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count) + if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count) { - Command nextCommand = flowchart.selectedBlock.commandList[lastSelectedIndex]; + Command nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex]; block.GetFlowchart().AddSelectedCommand(nextCommand); } @@ -1028,19 +1028,19 @@ namespace Fungus { Block targetBlock = target as Block; Flowchart flowchart = targetBlock.GetFlowchart(); - Command command = flowchart.selectedCommands[0]; + Command command = flowchart.SelectedCommands[0]; if (targetBlock.IsExecuting()) { // The Block is already executing. // Tell the Block to stop, wait a little while so the executing command has a // chance to stop, and then start execution again from the new command. targetBlock.Stop(); - flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f)); + flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.CommandIndex, 0.2f)); } else { // Block isn't executing yet so can start it now. - flowchart.ExecuteBlock(targetBlock, command.commandIndex); + flowchart.ExecuteBlock(targetBlock, command.CommandIndex); } } @@ -1048,11 +1048,11 @@ namespace Fungus { Block targetBlock = target as Block; Flowchart flowchart = targetBlock.GetFlowchart(); - Command command = flowchart.selectedCommands[0]; + Command command = flowchart.SelectedCommands[0]; // Stop all active blocks then run the selected block. flowchart.StopAllBlocks(); - flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f)); + flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.CommandIndex, 0.2f)); } protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay) @@ -1066,15 +1066,15 @@ namespace Fungus Block block = target as Block; Flowchart flowchart = block.GetFlowchart(); - int firstSelectedIndex = flowchart.selectedBlock.commandList.Count; + int firstSelectedIndex = flowchart.SelectedBlock.CommandList.Count; bool firstSelectedCommandFound = false; - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { - for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++) + for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++) { - Command commandInBlock = flowchart.selectedBlock.commandList[i]; + Command commandInBlock = flowchart.SelectedBlock.CommandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (commandInBlock == selectedCommand) { @@ -1095,7 +1095,7 @@ namespace Fungus if (firstSelectedIndex > 0) { flowchart.ClearSelectedCommands(); - flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[firstSelectedIndex-1]); + flowchart.AddSelectedCommand(flowchart.SelectedBlock.CommandList[firstSelectedIndex-1]); } Repaint(); @@ -1107,13 +1107,13 @@ namespace Fungus Flowchart flowchart = block.GetFlowchart(); int lastSelectedIndex = -1; - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { - for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++) + for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++) { - Command commandInBlock = flowchart.selectedBlock.commandList[i]; + Command commandInBlock = flowchart.SelectedBlock.CommandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (commandInBlock == selectedCommand) { @@ -1122,10 +1122,10 @@ namespace Fungus } } } - if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count-1) + if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count-1) { flowchart.ClearSelectedCommands(); - flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[lastSelectedIndex+1]); + flowchart.AddSelectedCommand(flowchart.SelectedBlock.CommandList[lastSelectedIndex+1]); } Repaint(); diff --git a/Assets/Fungus/Flowchart/Editor/BlockInspector.cs b/Assets/Fungus/Flowchart/Editor/BlockInspector.cs index 35961ef2..e4ce0660 100644 --- a/Assets/Fungus/Flowchart/Editor/BlockInspector.cs +++ b/Assets/Fungus/Flowchart/Editor/BlockInspector.cs @@ -101,19 +101,19 @@ namespace Fungus Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10); GUILayout.BeginArea(blockRect); - blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.blockViewHeight)); + blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight)); activeBlockEditor.DrawBlockGUI(flowchart); GUILayout.EndScrollView(); Command inspectCommand = null; - if (flowchart.selectedCommands.Count == 1) + if (flowchart.SelectedCommands.Count == 1) { - inspectCommand = flowchart.selectedCommands[0]; + inspectCommand = flowchart.SelectedCommands[0]; } if (Application.isPlaying && inspectCommand != null && - inspectCommand.parentBlock != block) + inspectCommand.ParentBlock != block) { GUILayout.EndArea(); Repaint(); @@ -189,7 +189,7 @@ namespace Fungus // Draw the resize bar after everything else has finished drawing // This is mainly to avoid incorrect indenting. - Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f); + Rect resizeRect = new Rect(0, topPanelHeight + flowchart.BlockViewHeight + 1, Screen.width, 4f); GUI.color = new Color(0.64f, 0.64f, 0.64f); GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture); resizeRect.height = 1; @@ -204,7 +204,7 @@ namespace Fungus private void ResizeScrollView(Flowchart flowchart) { - Rect cursorChangeRect = new Rect(0, flowchart.blockViewHeight + 1, Screen.width, 4f); + Rect cursorChangeRect = new Rect(0, flowchart.BlockViewHeight + 1, Screen.width, 4f); EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical); @@ -216,7 +216,7 @@ namespace Fungus if (resize) { Undo.RecordObject(flowchart, "Resize view"); - flowchart.blockViewHeight = Event.current.mousePosition.y; + flowchart.BlockViewHeight = Event.current.mousePosition.y; } ClampBlockViewHeight(flowchart); @@ -251,10 +251,10 @@ namespace Fungus if (clamp) { // Make sure block view is always clamped to visible area - float height = flowchart.blockViewHeight; + float height = flowchart.BlockViewHeight; height = Mathf.Max(200, height); height = Mathf.Min(Screen.height - 200,height); - flowchart.blockViewHeight = height; + flowchart.BlockViewHeight = height; } if (Event.current.type == EventType.Repaint) diff --git a/Assets/Fungus/Flowchart/Editor/CommandEditor.cs b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs index 285d43ab..bc142e56 100644 --- a/Assets/Fungus/Flowchart/Editor/CommandEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandEditor.cs @@ -1,3 +1,4 @@ + /** * This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). * It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) @@ -57,7 +58,7 @@ namespace Fungus if (t.enabled) { - if (flowchart.colorCommands) + if (flowchart.ColorCommands) { GUI.backgroundColor = t.GetButtonColor(); } @@ -77,7 +78,7 @@ namespace Fungus GUILayout.FlexibleSpace(); - GUILayout.Label(new GUIContent("(" + t.itemId + ")")); + GUILayout.Label(new GUIContent("(" + t.ItemId + ")")); GUILayout.Space(10); @@ -100,11 +101,11 @@ namespace Fungus EditorGUILayout.Separator(); - if (t.errorMessage.Length > 0) + if (t.ErrorMessage.Length > 0) { GUIStyle style = new GUIStyle(GUI.skin.label); style.normal.textColor = new Color(1,0,0); - EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); + EditorGUILayout.LabelField(new GUIContent("Error: " + t.ErrorMessage), style); } GUILayout.EndVertical(); diff --git a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs index 01e3a54a..ba473c35 100644 --- a/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs @@ -88,14 +88,14 @@ namespace Fungus return null; } - Block block = flowchart.selectedBlock; + Block block = flowchart.SelectedBlock; if (block == null) { return null; } Command newCommand = Undo.AddComponent(block.gameObject) as Command; - newCommand.itemId = flowchart.NextItemId(); + newCommand.ItemId = flowchart.NextItemId(); flowchart.ClearSelectedCommands(); flowchart.AddSelectedCommand(newCommand); @@ -111,7 +111,7 @@ namespace Fungus System.Type type = command.GetType(); Command newCommand = Undo.AddComponent(parentBlock.gameObject, type) as Command; - newCommand.itemId = newCommand.GetFlowchart().NextItemId(); + newCommand.ItemId = newCommand.GetFlowchart().NextItemId(); System.Reflection.FieldInfo[] fields = type.GetFields(); foreach (System.Reflection.FieldInfo field in fields) { @@ -205,7 +205,7 @@ namespace Fungus } bool commandIsSelected = false; - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (selectedCommand == command) { @@ -229,7 +229,7 @@ namespace Fungus commandLabelStyle.padding.top -= 1; float indentSize = 20; - for (int i = 0; i < command.indentLevel; ++i) + for (int i = 0; i < command.IndentLevel; ++i) { Rect indentRect = position; indentRect.x += i * indentSize - 21; @@ -241,12 +241,12 @@ namespace Fungus } float commandNameWidth = Mathf.Max(commandLabelStyle.CalcSize(new GUIContent(commandName)).x, 90f); - float indentWidth = command.indentLevel * indentSize; + float indentWidth = command.IndentLevel * indentSize; Rect commandLabelRect = position; commandLabelRect.x += indentWidth - 21; commandLabelRect.y -= 2; - commandLabelRect.width -= (indentSize * command.indentLevel - 22); + commandLabelRect.width -= (indentSize * command.IndentLevel - 22); commandLabelRect.height += 5; // There's a weird incompatibility between the Reorderable list control used for the command list and @@ -263,14 +263,14 @@ namespace Fungus Event.current.button == 0 && clickRect.Contains(Event.current.mousePosition)) { - if (flowchart.selectedCommands.Contains(command) && Event.current.button == 0) + if (flowchart.SelectedCommands.Contains(command) && Event.current.button == 0) { // Left click on already selected command // Command key and shift key is not pressed if (!EditorGUI.actionKey && !Event.current.shift) { BlockEditor.actionList.Add ( delegate { - flowchart.selectedCommands.Remove(command); + flowchart.SelectedCommands.Remove(command); flowchart.ClearSelectedCommands(); }); } @@ -279,7 +279,7 @@ namespace Fungus if (EditorGUI.actionKey) { BlockEditor.actionList.Add ( delegate { - flowchart.selectedCommands.Remove(command); + flowchart.SelectedCommands.Remove(command); }); Event.current.Use(); } @@ -304,14 +304,14 @@ namespace Fungus // Find first and last selected commands int firstSelectedIndex = -1; int lastSelectedIndex = -1; - if (flowchart.selectedCommands.Count > 0) + if (flowchart.SelectedCommands.Count > 0) { - if ( flowchart.selectedBlock != null) + if ( flowchart.SelectedBlock != null) { - for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++) + for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++) { - Command commandInBlock = flowchart.selectedBlock.commandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + Command commandInBlock = flowchart.SelectedBlock.CommandList[i]; + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (commandInBlock == selectedCommand) { @@ -320,10 +320,10 @@ namespace Fungus } } } - for (int i = flowchart.selectedBlock.commandList.Count - 1; i >=0; i--) + for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >=0; i--) { - Command commandInBlock = flowchart.selectedBlock.commandList[i]; - foreach (Command selectedCommand in flowchart.selectedCommands) + Command commandInBlock = flowchart.SelectedBlock.CommandList[i]; + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (commandInBlock == selectedCommand) { @@ -337,7 +337,7 @@ namespace Fungus if (shift) { - int currentIndex = command.commandIndex; + int currentIndex = command.CommandIndex; if (firstSelectedIndex == -1 || lastSelectedIndex == -1) { @@ -359,7 +359,7 @@ namespace Fungus for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i) { - Command selectedCommand = flowchart.selectedBlock.commandList[i]; + Command selectedCommand = flowchart.SelectedBlock.CommandList[i]; BlockEditor.actionList.Add ( delegate { flowchart.AddSelectedCommand(selectedCommand); }); @@ -372,7 +372,7 @@ namespace Fungus } Color commandLabelColor = Color.white; - if (flowchart.colorCommands) + if (flowchart.ColorCommands) { commandLabelColor = command.GetButtonColor(); } @@ -399,9 +399,9 @@ namespace Fungus else { string commandNameLabel; - if (flowchart.showLineNumbers) + if (flowchart.ShowLineNumbers) { - commandNameLabel = command.commandIndex.ToString() + ": " + commandName; + commandNameLabel = command.CommandIndex.ToString() + ": " + commandName; } else { @@ -411,7 +411,7 @@ namespace Fungus GUI.Label(commandLabelRect, commandNameLabel, commandLabelStyle); } - if (command.executingIconTimer > Time.realtimeSinceStartup) + if (command.ExecutingIconTimer > Time.realtimeSinceStartup) { Rect iconRect = new Rect(commandLabelRect); iconRect.x += iconRect.width - commandLabelRect.width - 20; @@ -420,7 +420,7 @@ namespace Fungus Color storeColor = GUI.color; - float alpha = (command.executingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime; + float alpha = (command.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime; alpha = Mathf.Clamp01(alpha); GUI.color = new Color(1f, 1f, 1f, alpha); diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs index 94c66893..9663f085 100644 --- a/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs @@ -91,8 +91,8 @@ namespace Fungus if (GUILayout.Button(new GUIContent("Center View", "Centers the window view at the center of all blocks in the Flowchart"))) { // Reset the zoom so we don't have adjust the center position depending on zoom - flowchart.scrollPos = flowchart.centerPosition; - flowchart.zoom = FlowchartWindow.maxZoomValue; + flowchart.ScrollPos = flowchart.CenterPosition; + flowchart.Zoom = FlowchartWindow.maxZoomValue; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); @@ -106,16 +106,16 @@ namespace Fungus Flowchart t = target as Flowchart; - if (t.variables.Count == 0) + if (t.Variables.Count == 0) { - t.variablesExpanded = true; + t.VariablesExpanded = true; } - if (!t.variablesExpanded) + if (!t.VariablesExpanded) { - if (GUILayout.Button ("Variables (" + t.variables.Count + ")", GUILayout.Height(24))) + if (GUILayout.Button ("Variables (" + t.Variables.Count + ")", GUILayout.Height(24))) { - t.variablesExpanded = true; + t.VariablesExpanded = true; } // Draw disclosure triangle @@ -128,15 +128,15 @@ namespace Fungus { Rect listRect = new Rect(); - if (t.variables.Count > 0) + if (t.Variables.Count > 0) { // Remove any null variables from the list // Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class) - for (int i = t.variables.Count - 1; i >= 0; i--) + for (int i = t.Variables.Count - 1; i >= 0; i--) { - if (t.variables[i] == null) + if (t.Variables[i] == null) { - t.variables.RemoveAt(i); + t.Variables.RemoveAt(i); } } @@ -170,7 +170,7 @@ namespace Fungus if (GUI.Button (buttonRect, "Variables")) { - t.variablesExpanded = false; + t.VariablesExpanded = false; } // Draw disclosure triangle @@ -249,8 +249,8 @@ namespace Fungus Undo.RecordObject(flowchart, "Add Variable"); Variable newVariable = flowchart.gameObject.AddComponent(variableType) as Variable; - newVariable.key = flowchart.GetUniqueVariableKey(""); - flowchart.variables.Add(newVariable); + 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); diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs index d4afc13d..acfa7488 100644 --- a/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs @@ -23,15 +23,15 @@ namespace Fungus Flowchart flowchart = go.GetComponent(); if (flowchart != null) { - flowchart.version = Flowchart.CURRENT_VERSION; + flowchart.Version = Flowchart.CURRENT_VERSION; } // Only the first created Flowchart in the scene should have a default GameStarted block if (GameObject.FindObjectsOfType().Length > 1) { Block block = go.GetComponent(); - block.eventHandler = null; - GameObject.DestroyImmediate(block.eventHandler); + block._EventHandler = null; + GameObject.DestroyImmediate(block._EventHandler); } } diff --git a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs index 7e7e5c7d..99f3dfae 100644 --- a/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs +++ b/Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs @@ -71,13 +71,13 @@ namespace Fungus } if (Selection.activeGameObject == null && - flowchart.selectedBlock != null) + flowchart.SelectedBlock != null) { if (blockInspector == null) { ShowBlockInspector(flowchart); } - blockInspector.block = flowchart.selectedBlock; + blockInspector.block = flowchart.SelectedBlock; } forceRepaintCount--; @@ -103,11 +103,11 @@ namespace Fungus Flowchart fs = Selection.activeGameObject.GetComponent(); if (fs != null) { - fungusState.selectedFlowchart = fs; + fungusState.SelectedFlowchart = fs; } } - return fungusState.selectedFlowchart; + return fungusState.SelectedFlowchart; } protected virtual void OnGUI() @@ -122,9 +122,9 @@ namespace Fungus // Delete any scheduled objects foreach (Block deleteBlock in deleteList) { - bool isSelected = (flowchart.selectedBlock == deleteBlock); + bool isSelected = (flowchart.SelectedBlock == deleteBlock); - foreach (Command command in deleteBlock.commandList) + foreach (Command command in deleteBlock.CommandList) { Undo.DestroyObjectImmediate(command); } @@ -160,22 +160,22 @@ namespace Fungus if (GUILayout.Button(new GUIContent(addTexture, "Add a new block"))) { - Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x, - 50 - flowchart.scrollPos.y); + Vector2 newNodePosition = new Vector2(50 - flowchart.ScrollPos.x, + 50 - flowchart.ScrollPos.y); CreateBlock(flowchart, newNodePosition); } GUILayout.Space(8); - flowchart.zoom = GUILayout.HorizontalSlider(flowchart.zoom, minZoomValue, maxZoomValue, GUILayout.Width(100)); + flowchart.Zoom = GUILayout.HorizontalSlider(flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.Width(100)); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel); - if (flowchart.description.Length > 0) + if (flowchart.Description.Length > 0) { - GUILayout.Label(flowchart.description, EditorStyles.helpBox); + GUILayout.Label(flowchart.Description, EditorStyles.helpBox); } GUILayout.EndVertical(); @@ -189,7 +189,7 @@ namespace Fungus GUILayout.FlexibleSpace(); - flowchart.variablesScrollPos = GUILayout.BeginScrollView(flowchart.variablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f)); + flowchart.VariablesScrollPos = GUILayout.BeginScrollView(flowchart.VariablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f)); GUILayout.FlexibleSpace(); @@ -200,8 +200,8 @@ namespace Fungus DestroyImmediate(flowchartEditor); Rect variableWindowRect = GUILayoutUtility.GetLastRect(); - if (flowchart.variablesExpanded && - flowchart.variables.Count > 0) + if (flowchart.VariablesExpanded && + flowchart.Variables.Count > 0) { variableWindowRect.y -= 20; variableWindowRect.height += 20; @@ -226,16 +226,18 @@ namespace Fungus foreach (Block block in blocks) { - flowchart.scrollViewRect.xMin = Mathf.Min(flowchart.scrollViewRect.xMin, block.nodeRect.xMin - 400); - flowchart.scrollViewRect.xMax = Mathf.Max(flowchart.scrollViewRect.xMax, block.nodeRect.xMax + 400); - flowchart.scrollViewRect.yMin = Mathf.Min(flowchart.scrollViewRect.yMin, block.nodeRect.yMin - 400); - flowchart.scrollViewRect.yMax = Mathf.Max(flowchart.scrollViewRect.yMax, block.nodeRect.yMax + 400); + var newRect = new Rect(); + newRect.xMin = Mathf.Min(flowchart.ScrollViewRect.xMin, block._NodeRect.xMin - 400); + newRect.xMax = Mathf.Max(flowchart.ScrollViewRect.xMax, block._NodeRect.xMax + 400); + newRect.yMin = Mathf.Min(flowchart.ScrollViewRect.yMin, block._NodeRect.yMin - 400); + newRect.yMax = Mathf.Max(flowchart.ScrollViewRect.yMax, block._NodeRect.yMax + 400); + flowchart.ScrollViewRect = newRect; } // Calc rect for script view - Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.zoom, this.position.height / flowchart.zoom); + Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.Zoom, this.position.height / flowchart.Zoom); - EditorZoomArea.Begin(flowchart.zoom, scriptViewRect); + EditorZoomArea.Begin(flowchart.Zoom, scriptViewRect); DrawGrid(flowchart); @@ -245,7 +247,7 @@ namespace Fungus Event.current.type == EventType.MouseDown && !mouseOverVariables) { - flowchart.selectedBlock = null; + flowchart.SelectedBlock = null; if (!EditorGUI.actionKey) { flowchart.ClearSelectedCommands(); @@ -277,46 +279,49 @@ namespace Fungus { Block block = blocks[i]; - float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.blockName)).x + 10; + float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.BlockName)).x + 10; float nodeWidthB = 0f; - if (block.eventHandler != null) + if (block._EventHandler != null) { - nodeWidthB = nodeStyle.CalcSize(new GUIContent(block.eventHandler.GetSummary())).x + 10; + nodeWidthB = nodeStyle.CalcSize(new GUIContent(block._EventHandler.GetSummary())).x + 10; } - - block.nodeRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120); - block.nodeRect.height = 40; - + if (Event.current.button == 0) { + Rect tempRect = block._NodeRect; + tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120); + tempRect.height = 40; + if (Event.current.type == EventType.MouseDrag && dragWindowId == i) { - block.nodeRect.x += Event.current.delta.x; - block.nodeRect.y += Event.current.delta.y; + tempRect.x += Event.current.delta.x; + tempRect.y += Event.current.delta.y; forceRepaintCount = 6; } else if (Event.current.type == EventType.MouseUp && dragWindowId == i) { - Vector2 newPos = new Vector2(block.nodeRect.x, block.nodeRect.y); + Vector2 newPos = new Vector2(tempRect.x, tempRect.y); - block.nodeRect.x = startDragPosition.x; - block.nodeRect.y = startDragPosition.y; + tempRect.x = startDragPosition.x; + tempRect.y = startDragPosition.y; Undo.RecordObject(block, "Node Position"); - block.nodeRect.x = newPos.x; - block.nodeRect.y = newPos.y; + tempRect.x = newPos.x; + tempRect.y = newPos.y; dragWindowId = -1; forceRepaintCount = 6; } + + block._NodeRect = tempRect; } - Rect windowRect = new Rect(block.nodeRect); - windowRect.x += flowchart.scrollPos.x; - windowRect.y += flowchart.scrollPos.y; + Rect windowRect = new Rect(block._NodeRect); + windowRect.x += flowchart.ScrollPos.x; + windowRect.y += flowchart.ScrollPos.y; GUILayout.Window(i, windowRect, DrawWindow, "", windowStyle); @@ -330,10 +335,10 @@ namespace Fungus // Draw Event Handler labels foreach (Block block in blocks) { - if (block.eventHandler != null) + if (block._EventHandler != null) { string handlerLabel = ""; - EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType()); + EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block._EventHandler.GetType()); if (info != null) { handlerLabel = "<" + info.EventHandlerName + "> "; @@ -345,10 +350,10 @@ namespace Fungus handlerStyle.margin.bottom = 0; handlerStyle.alignment = TextAnchor.MiddleCenter; - Rect rect = new Rect(block.nodeRect); - rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width); - rect.x += flowchart.scrollPos.x; - rect.y += flowchart.scrollPos.y - rect.height; + Rect rect = new Rect(block._NodeRect); + rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width); + rect.x += flowchart.ScrollPos.x; + rect.y += flowchart.ScrollPos.y - rect.height; GUI.Label(rect, handlerLabel, handlerStyle); } @@ -362,23 +367,23 @@ namespace Fungus { if (b.IsExecuting()) { - b.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime; - b.activeCommand.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime; + b.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime; + b.ActiveCommand.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime; forceRepaintCount = 6; } - if (b.executingIconTimer > Time.realtimeSinceStartup) + if (b.ExecutingIconTimer > Time.realtimeSinceStartup) { - Rect rect = new Rect(b.nodeRect); + Rect rect = new Rect(b._NodeRect); - rect.x += flowchart.scrollPos.x - 37; - rect.y += flowchart.scrollPos.y + 3; + rect.x += flowchart.ScrollPos.x - 37; + rect.y += flowchart.ScrollPos.y + 3; rect.width = 34; rect.height = 34; if (!b.IsExecuting()) { - float alpha = (b.executingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime; + float alpha = (b.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime; alpha = Mathf.Clamp01(alpha); GUI.color = new Color(1f, 1f, 1f, alpha); } @@ -408,15 +413,15 @@ namespace Fungus return; } - Vector2 min = blocks[0].nodeRect.min; - Vector2 max = blocks[0].nodeRect.max; + Vector2 min = blocks[0]._NodeRect.min; + Vector2 max = blocks[0]._NodeRect.max; foreach (Block block in blocks) { - min.x = Mathf.Min(min.x, block.nodeRect.center.x); - min.y = Mathf.Min(min.y, block.nodeRect.center.y); - max.x = Mathf.Max(max.x, block.nodeRect.center.x); - max.y = Mathf.Max(max.y, block.nodeRect.center.y); + min.x = Mathf.Min(min.x, block._NodeRect.center.x); + min.y = Mathf.Min(min.y, block._NodeRect.center.y); + max.x = Mathf.Max(max.x, block._NodeRect.center.x); + max.y = Mathf.Max(max.y, block._NodeRect.center.y); } Vector2 center = (min + max) * -0.5f; @@ -424,7 +429,7 @@ namespace Fungus center.x += position.width * 0.5f; center.y += position.height * 0.5f; - flowchart.centerPosition = center; + flowchart.CenterPosition = center; } protected virtual void PanAndZoom(Flowchart flowchart) @@ -454,7 +459,7 @@ namespace Fungus if (drag) { - flowchart.scrollPos += Event.current.delta; + flowchart.ScrollPos += Event.current.delta; forceRepaintCount = 6; } @@ -475,16 +480,16 @@ namespace Fungus if (zoom) { - flowchart.zoom -= Event.current.delta.y * 0.01f; - flowchart.zoom = Mathf.Clamp(flowchart.zoom, minZoomValue, maxZoomValue); + flowchart.Zoom -= Event.current.delta.y * 0.01f; + flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, minZoomValue, maxZoomValue); forceRepaintCount = 6; } } protected virtual void DrawGrid(Flowchart flowchart) { - float width = this.position.width / flowchart.zoom; - float height = this.position.height / flowchart.zoom; + float width = this.position.width / flowchart.Zoom; + float height = this.position.height / flowchart.Zoom; // Match background color of scene view if (EditorGUIUtility.isProSkin) @@ -502,14 +507,14 @@ namespace Fungus float gridSize = 128f; - float x = flowchart.scrollPos.x % gridSize; + float x = flowchart.ScrollPos.x % gridSize; while (x < width) { GLDraw.DrawLine(new Vector2(x, 0), new Vector2(x, height), color, 1f); x += gridSize; } - float y = (flowchart.scrollPos.y % gridSize); + float y = (flowchart.ScrollPos.y % gridSize); while (y < height) { if (y >= 0) @@ -524,11 +529,11 @@ namespace Fungus { // Select the block and also select currently executing command ShowBlockInspector(flowchart); - flowchart.selectedBlock = block; + flowchart.SelectedBlock = block; flowchart.ClearSelectedCommands(); - if (block.activeCommand != null) + if (block.ActiveCommand != null) { - flowchart.AddSelectedCommand(block.activeCommand); + flowchart.AddSelectedCommand(block.ActiveCommand); } } @@ -537,7 +542,7 @@ namespace Fungus Block newBlock = flowchart.CreateBlock(position); Undo.RegisterCreatedObjectUndo(newBlock, "New Block"); ShowBlockInspector(flowchart); - flowchart.selectedBlock = newBlock; + flowchart.SelectedBlock = newBlock; flowchart.ClearSelectedCommands(); return newBlock; @@ -545,7 +550,7 @@ namespace Fungus protected virtual void DeleteBlock(Flowchart flowchart, Block block) { - foreach (Command command in block.commandList) + foreach (Command command in block.CommandList) { Undo.DestroyObjectImmediate(command); } @@ -574,8 +579,8 @@ namespace Fungus Event.current.alt == false) { dragWindowId = windowId; - startDragPosition.x = block.nodeRect.x; - startDragPosition.y = block.nodeRect.y; + startDragPosition.x = block._NodeRect.x; + startDragPosition.y = block._NodeRect.y; } if (windowId < windowBlockMap.Count) @@ -588,11 +593,11 @@ namespace Fungus } } - bool selected = (flowchart.selectedBlock == block); + bool selected = (flowchart.SelectedBlock == block); GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle); - if (block.eventHandler != null) + if (block._EventHandler != null) { nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff; } @@ -624,17 +629,19 @@ namespace Fungus nodeStyleCopy.normal.textColor = Color.black; // Make sure node is wide enough to fit the node name text - float width = nodeStyleCopy.CalcSize(new GUIContent(block.blockName)).x; - block.nodeRect.width = Mathf.Max (block.nodeRect.width, width); + float width = nodeStyleCopy.CalcSize(new GUIContent(block.BlockName)).x; + Rect tempRect = block._NodeRect; + tempRect.width = Mathf.Max (block._NodeRect.width, width); + block._NodeRect = tempRect; GUI.backgroundColor = Color.white; - GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height)); + GUILayout.Box(block.BlockName, nodeStyleCopy, GUILayout.Width(block._NodeRect.width), GUILayout.Height(block._NodeRect.height)); - if (block.description.Length > 0) + if (block.Description.Length > 0) { GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox); descriptionStyle.wordWrap = true; - GUILayout.Label(block.description, descriptionStyle); + GUILayout.Label(block.Description, descriptionStyle); } if (Event.current.type == EventType.ContextClick) @@ -657,9 +664,9 @@ namespace Fungus List connectedBlocks = new List(); - bool blockIsSelected = (flowchart.selectedBlock == block); + bool blockIsSelected = (flowchart.SelectedBlock == block); - foreach (Command command in block.commandList) + foreach (Command command in block.CommandList) { if (command == null) { @@ -667,7 +674,7 @@ namespace Fungus } bool commandIsSelected = false; - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (selectedCommand == command) { @@ -676,7 +683,7 @@ namespace Fungus } } - bool highlight = command.isExecuting || (blockIsSelected && commandIsSelected); + bool highlight = command.IsExecuting || (blockIsSelected && commandIsSelected); if (highlightedOnly && !highlight || !highlightedOnly && highlight) @@ -696,13 +703,13 @@ namespace Fungus continue; } - Rect startRect = new Rect(block.nodeRect); - startRect.x += flowchart.scrollPos.x; - startRect.y += flowchart.scrollPos.y; + Rect startRect = new Rect(block._NodeRect); + startRect.x += flowchart.ScrollPos.x; + startRect.y += flowchart.ScrollPos.y; - Rect endRect = new Rect(blockB.nodeRect); - endRect.x += flowchart.scrollPos.x; - endRect.y += flowchart.scrollPos.y; + Rect endRect = new Rect(blockB._NodeRect); + endRect.x += flowchart.ScrollPos.x; + endRect.y += flowchart.ScrollPos.y; DrawRectConnection(startRect, endRect, highlight); } @@ -769,18 +776,18 @@ namespace Fungus Flowchart flowchart = GetFlowchart(); Block block = obj as Block; - Vector2 newPosition = new Vector2(block.nodeRect.position.x + - block.nodeRect.width + 20, - block.nodeRect.y); + Vector2 newPosition = new Vector2(block._NodeRect.position.x + + block._NodeRect.width + 20, + block._NodeRect.y); Block oldBlock = block; Block newBlock = FlowchartWindow.CreateBlock(flowchart, newPosition); - newBlock.blockName = flowchart.GetUniqueBlockKey(oldBlock.blockName + " (Copy)"); + newBlock.BlockName = flowchart.GetUniqueBlockKey(oldBlock.BlockName + " (Copy)"); Undo.RecordObject(newBlock, "Duplicate Block"); - foreach (Command command in oldBlock.commandList) + foreach (Command command in oldBlock.CommandList) { if (ComponentUtility.CopyComponent(command)) { @@ -790,8 +797,8 @@ namespace Fungus Command pastedCommand = commands.Last(); if (pastedCommand != null) { - pastedCommand.itemId = flowchart.NextItemId(); - newBlock.commandList.Add (pastedCommand); + pastedCommand.ItemId = flowchart.NextItemId(); + newBlock.CommandList.Add (pastedCommand); } } @@ -800,9 +807,9 @@ namespace Fungus } } - if (oldBlock.eventHandler != null) + if (oldBlock._EventHandler != null) { - if (ComponentUtility.CopyComponent(oldBlock.eventHandler)) + if (ComponentUtility.CopyComponent(oldBlock._EventHandler)) { if (ComponentUtility.PasteComponentAsNew(flowchart.gameObject)) { @@ -810,8 +817,8 @@ namespace Fungus EventHandler pastedEventHandler = eventHandlers.Last(); if (pastedEventHandler != null) { - pastedEventHandler.parentBlock = newBlock; - newBlock.eventHandler = pastedEventHandler; + pastedEventHandler.ParentBlock = newBlock; + newBlock._EventHandler = pastedEventHandler; } } } diff --git a/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs index c654d5e2..0b06acaa 100644 --- a/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs @@ -26,23 +26,23 @@ namespace Fungus targetMethod = target as InvokeMethod; - if (targetMethod == null || targetMethod.targetObject == null) + if (targetMethod == null || targetMethod.TargetObject == null) return; SerializedObject objSerializedTarget = new SerializedObject(targetMethod); - string component = ShowComponents(objSerializedTarget, targetMethod.targetObject); + string component = ShowComponents(objSerializedTarget, targetMethod.TargetObject); // show component methods if selected if (!string.IsNullOrEmpty(component)) { - var method = ShowMethods(objSerializedTarget, targetMethod.targetObject, component); + var method = ShowMethods(objSerializedTarget, targetMethod.TargetObject, component); // show method parameters if selected if (method != null) { objSerializedTarget.ApplyModifiedProperties(); - ShowParameters(objSerializedTarget, targetMethod.targetObject, method); + ShowParameters(objSerializedTarget, targetMethod.TargetObject, method); ShowReturnValue(objSerializedTarget, method); } } @@ -172,7 +172,7 @@ namespace Fungus if (isDrawn) { - var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, objParam.ParameterType); + var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().Variables, objParam.ParameterType); var values = new string[] { "" }; var displayValue = values.Concat(vars).ToList(); @@ -241,7 +241,7 @@ namespace Fungus if (saveReturnValueProp.boolValue) { - var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, method.ReturnType).ToList(); + var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().Variables, method.ReturnType).ToList(); int index = vars.IndexOf(returnValueKeyProp.stringValue); index = EditorGUILayout.Popup(method.ReturnType.Name, index, vars.ToArray()); @@ -367,51 +367,51 @@ namespace Fungus if (type == typeof(int)) { - result = (from v in variables where v.GetType() == typeof(IntegerVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(IntegerVariable) select v.Key).ToArray(); } else if (type == typeof(bool)) { - result = (from v in variables where v.GetType() == typeof(BooleanVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(BooleanVariable) select v.Key).ToArray(); } else if (type == typeof(float)) { - result = (from v in variables where v.GetType() == typeof(FloatVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(FloatVariable) select v.Key).ToArray(); } else if (type == typeof(string)) { - result = (from v in variables where v.GetType() == typeof(StringVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(StringVariable) select v.Key).ToArray(); } else if (type == typeof(Color)) { - result = (from v in variables where v.GetType() == typeof(ColorVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(ColorVariable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.GameObject)) { - result = (from v in variables where v.GetType() == typeof(GameObjectVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(GameObjectVariable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.Material)) { - result = (from v in variables where v.GetType() == typeof(MaterialVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(MaterialVariable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.Sprite)) { - result = (from v in variables where v.GetType() == typeof(SpriteVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(SpriteVariable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.Texture)) { - result = (from v in variables where v.GetType() == typeof(TextureVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(TextureVariable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.Vector2)) { - result = (from v in variables where v.GetType() == typeof(Vector2Variable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(Vector2Variable) select v.Key).ToArray(); } else if (type == typeof(UnityEngine.Vector3)) { - result = (from v in variables where v.GetType() == typeof(Vector3Variable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(Vector3Variable) select v.Key).ToArray(); } else if (type.IsSubclassOf(typeof(UnityEngine.Object))) { - result = (from v in variables where v.GetType() == typeof(ObjectVariable) select v.key).ToArray(); + result = (from v in variables where v.GetType() == typeof(ObjectVariable) select v.Key).ToArray(); } return result; diff --git a/Assets/Fungus/Flowchart/Editor/LabelEditor.cs b/Assets/Fungus/Flowchart/Editor/LabelEditor.cs index 3656e3c8..c3ad7248 100644 --- a/Assets/Fungus/Flowchart/Editor/LabelEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/LabelEditor.cs @@ -32,7 +32,7 @@ namespace Fungus int index = 0; int selectedIndex = 0; - foreach (Command command in block.commandList) + foreach (Command command in block.CommandList) { Label label = command as Label; if (label == null) @@ -40,7 +40,7 @@ namespace Fungus continue; } - labelKeys.Add(label.key); + labelKeys.Add(label.Key); labelObjects.Add(label); index++; diff --git a/Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs b/Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs index c9dd38a4..8da3d510 100644 --- a/Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs @@ -73,7 +73,7 @@ namespace Fungus } int selectedIndex = 0; - switch (t.setOperator) + switch (t._SetOperator) { default: case SetVariable.SetOperator.Assign: diff --git a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs index 9ed8e0b0..27031afc 100644 --- a/Assets/Fungus/Flowchart/Editor/VariableEditor.cs +++ b/Assets/Fungus/Flowchart/Editor/VariableEditor.cs @@ -50,7 +50,7 @@ namespace Fungus variableKeys.Add(defaultText); variableObjects.Add(null); - List variables = flowchart.variables; + List variables = flowchart.Variables; int index = 0; int selectedIndex = 0; @@ -63,7 +63,7 @@ namespace Fungus // occurs we just skip displaying the property for this frame. if (selectedVariable != null && selectedVariable.gameObject != flowchart.gameObject && - selectedVariable.scope == VariableScope.Private) + selectedVariable.Scope == VariableScope.Private) { property.objectReferenceValue = null; return; @@ -79,7 +79,7 @@ namespace Fungus } } - variableKeys.Add(v.key); + variableKeys.Add(v.Key); variableObjects.Add(v); index++; @@ -109,7 +109,7 @@ namespace Fungus } } - variableKeys.Add(fs.name + " / " + v.key); + variableKeys.Add(fs.name + " / " + v.Key); variableObjects.Add(v); index++; diff --git a/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs b/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs index 57421118..7222fdcc 100644 --- a/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs +++ b/Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs @@ -133,15 +133,15 @@ namespace Fungus // Highlight if an active or selected command is referencing this variable bool highlight = false; - if (flowchart.selectedBlock != null) + if (flowchart.SelectedBlock != null) { - if (Application.isPlaying && flowchart.selectedBlock.IsExecuting()) + if (Application.isPlaying && flowchart.SelectedBlock.IsExecuting()) { - highlight = flowchart.selectedBlock.activeCommand.HasReference(variable); + highlight = flowchart.SelectedBlock.ActiveCommand.HasReference(variable); } - else if (!Application.isPlaying && flowchart.selectedCommands.Count > 0) + else if (!Application.isPlaying && flowchart.SelectedCommands.Count > 0) { - foreach (Command selectedCommand in flowchart.selectedCommands) + foreach (Command selectedCommand in flowchart.SelectedCommands) { if (selectedCommand == null) { @@ -163,8 +163,8 @@ namespace Fungus GUI.Box(position, ""); } - string key = variable.key; - VariableScope scope = variable.scope; + string key = variable.Key; + VariableScope scope = variable.Scope; // To access properties in a monobehavior, you have to new a SerializedObject // http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html @@ -174,7 +174,7 @@ namespace Fungus GUI.Label(rects[0], variableInfo.VariableType); - key = EditorGUI.TextField(rects[1], variable.key); + key = EditorGUI.TextField(rects[1], variable.Key); SerializedProperty keyProp = variableObject.FindProperty("key"); keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable); @@ -182,7 +182,7 @@ namespace Fungus EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent("")); SerializedProperty scopeProp = variableObject.FindProperty("scope"); - scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.scope); + scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.Scope); scopeProp.enumValueIndex = (int)scope; variableObject.ApplyModifiedProperties(); diff --git a/Assets/Fungus/Flowchart/Scripts/Block.cs b/Assets/Fungus/Flowchart/Scripts/Block.cs index 2dd8b26d..cb18b76a 100644 --- a/Assets/Fungus/Flowchart/Scripts/Block.cs +++ b/Assets/Fungus/Flowchart/Scripts/Block.cs @@ -22,39 +22,44 @@ namespace Fungus Executing, } - [NonSerialized] - public ExecutionState executionState; + protected ExecutionState executionState; - [HideInInspector] - public int itemId = -1; // Invalid flowchart item id + public ExecutionState State { get { return executionState; } } + + [SerializeField] protected int itemId = -1; // Invalid flowchart item id + + public int ItemId { get { return itemId; } set { itemId = value; } } [FormerlySerializedAs("sequenceName")] [Tooltip("The name of the block node as displayed in the Flowchart window")] - public string blockName = "New Block"; + [SerializeField] protected string blockName = "New Block"; + + public string BlockName { get { return blockName; } set { blockName = value; } } [TextArea(2, 5)] [Tooltip("Description text to display under the block node")] - public string description = ""; + [SerializeField] protected string description = ""; + + public string Description { get { return description; } } [Tooltip("An optional Event Handler which can execute the block when an event occurs")] - public EventHandler eventHandler; + [SerializeField] protected EventHandler eventHandler; + + public EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } } - [HideInInspector] - [System.NonSerialized] - public Command activeCommand; + protected Command activeCommand; + + public Command ActiveCommand { get { return activeCommand; } } // Index of last command executed before the current one // -1 indicates no previous command - [HideInInspector] - [System.NonSerialized] - public int previousActiveCommandIndex = -1; + protected int previousActiveCommandIndex = -1; + + public float ExecutingIconTimer { get; set; } - [HideInInspector] - [System.NonSerialized] - public float executingIconTimer; + [SerializeField] protected List commandList = new List(); - [HideInInspector] - public List commandList = new List(); + public List CommandList { get { return commandList; } } protected int executionCount; @@ -66,8 +71,9 @@ namespace Fungus /** * Controls the next command to execute in the block execution coroutine. */ - [NonSerialized] - public int jumpToCommandIndex = -1; + protected int jumpToCommandIndex = -1; + + public int JumpToCommandIndex { set { jumpToCommandIndex = value; } } protected bool executionInfoSet = false; @@ -88,8 +94,8 @@ namespace Fungus continue; } - command.parentBlock = this; - command.commandIndex = index++; + command.ParentBlock = this; + command.CommandIndex = index++; } // Ensure all commands are at their correct indent level @@ -114,7 +120,7 @@ namespace Fungus continue; } - command.commandIndex = index++; + command.CommandIndex = index++; } } #endif @@ -124,19 +130,6 @@ namespace Fungus return GetComponent(); } - public virtual bool HasError() - { - foreach (Command command in commandList) - { - if (command.errorMessage.Length > 0) - { - return true; - } - } - - return false; - } - public virtual bool IsExecuting() { return (executionState == ExecutionState.Executing); @@ -179,7 +172,7 @@ namespace Fungus #if UNITY_EDITOR // Select the executing block & the first command - flowchart.selectedBlock = this; + flowchart.SelectedBlock = this; if (commandList.Count > 0) { flowchart.ClearSelectedCommands(); @@ -205,7 +198,7 @@ namespace Fungus commandList[i].GetType() == typeof(Comment) || commandList[i].GetType() == typeof(Label))) { - i = commandList[i].commandIndex + 1; + i = commandList[i].CommandIndex + 1; } if (i >= commandList.Count) @@ -220,7 +213,7 @@ namespace Fungus } else { - previousActiveCommandIndex = activeCommand.commandIndex; + previousActiveCommandIndex = activeCommand.CommandIndex; } Command command = commandList[i]; @@ -229,18 +222,18 @@ namespace Fungus if (flowchart.gameObject.activeInHierarchy) { // Auto select a command in some situations - if ((flowchart.selectedCommands.Count == 0 && i == 0) || - (flowchart.selectedCommands.Count == 1 && flowchart.selectedCommands[0].commandIndex == previousActiveCommandIndex)) + if ((flowchart.SelectedCommands.Count == 0 && i == 0) || + (flowchart.SelectedCommands.Count == 1 && flowchart.SelectedCommands[0].CommandIndex == previousActiveCommandIndex)) { flowchart.ClearSelectedCommands(); flowchart.AddSelectedCommand(commandList[i]); } } - command.isExecuting = true; + command.IsExecuting = true; // This icon timer is managed by the FlowchartWindow class, but we also need to // set it here in case a command starts and finishes execution before the next window update. - command.executingIconTimer = Time.realtimeSinceStartup + executingIconFadeTime; + command.ExecutingIconTimer = Time.realtimeSinceStartup + executingIconFadeTime; command.Execute(); // Wait until the executing command sets another command to jump to via Command.Continue() @@ -250,13 +243,13 @@ namespace Fungus } #if UNITY_EDITOR - if (flowchart.stepPause > 0f) + if (flowchart.StepPause > 0f) { - yield return new WaitForSeconds(flowchart.stepPause); + yield return new WaitForSeconds(flowchart.StepPause); } #endif - command.isExecuting = false; + command.IsExecuting = false; } executionState = ExecutionState.Idle; @@ -273,7 +266,7 @@ namespace Fungus // Tell the executing command to stop immediately if (activeCommand != null) { - activeCommand.isExecuting = false; + activeCommand.IsExecuting = false; activeCommand.OnStopExecuting(); } @@ -323,7 +316,7 @@ namespace Fungus // Negative indent level is not permitted indentLevel = Math.Max(indentLevel, 0); - command.indentLevel = indentLevel; + command.IndentLevel = indentLevel; if (command.OpenBlock()) { diff --git a/Assets/Fungus/Flowchart/Scripts/Command.cs b/Assets/Fungus/Flowchart/Scripts/Command.cs index 43bea187..1b6205cf 100644 --- a/Assets/Fungus/Flowchart/Scripts/Command.cs +++ b/Assets/Fungus/Flowchart/Scripts/Command.cs @@ -39,36 +39,37 @@ namespace Fungus { [FormerlySerializedAs("commandId")] [HideInInspector] - public int itemId = -1; // Invalid flowchart item id + [SerializeField] protected int itemId = -1; // Invalid flowchart item id - [HideInInspector] - public string errorMessage = ""; + public int ItemId { get { return itemId; } set { itemId = value; } } + + protected string errorMessage = ""; + + public string ErrorMessage { get { return errorMessage; } } [HideInInspector] - public int indentLevel; + [SerializeField] protected int indentLevel; + + public int IndentLevel { get { return indentLevel; } set { indentLevel = value; } } - [NonSerialized] - public int commandIndex; + public int CommandIndex { get; set; } /** * Set to true by the parent block while the command is executing. */ - [NonSerialized] - public bool isExecuting; + public bool IsExecuting { get; set; } /** * Timer used to control appearance of executing icon in inspector. */ - [NonSerialized] - public float executingIconTimer; + public float ExecutingIconTimer { get; set; } /** * Reference to the Block object that this command belongs to. * This reference is only populated at runtime and in the editor when the * block is selected. */ - [NonSerialized] - public Block parentBlock; + public Block ParentBlock { get; set; } public virtual Flowchart GetFlowchart() { @@ -89,27 +90,27 @@ namespace Fungus public virtual void Continue() { // This is a noop if the Block has already been stopped - if (isExecuting) + if (IsExecuting) { - Continue(commandIndex + 1); + Continue(CommandIndex + 1); } } public virtual void Continue(int nextCommandIndex) { OnExit(); - if (parentBlock != null) + if (ParentBlock != null) { - parentBlock.jumpToCommandIndex = nextCommandIndex; + ParentBlock.JumpToCommandIndex = nextCommandIndex; } } public virtual void StopParentBlock() { OnExit(); - if (parentBlock != null) + if (ParentBlock != null) { - parentBlock.Stop(); + ParentBlock.Stop(); } } @@ -215,7 +216,7 @@ namespace Fungus return ""; } - string localizationId = GetFlowchart().localizationId; + string localizationId = GetFlowchart().LocalizationId; if (localizationId.Length == 0) { localizationId = flowchart.name; diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Break.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Break.cs index a130a336..4c1ac184 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Break.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Break.cs @@ -21,13 +21,13 @@ namespace Fungus // Find index of previous while command int whileIndex = -1; int whileIndentLevel = -1; - for (int i = commandIndex - 1; i >=0; --i) + for (int i = CommandIndex - 1; i >=0; --i) { - While whileCommand = parentBlock.commandList[i] as While; + While whileCommand = ParentBlock.CommandList[i] as While; if (whileCommand != null) { whileIndex = i; - whileIndentLevel = whileCommand.indentLevel; + whileIndentLevel = whileCommand.IndentLevel; break; } } @@ -40,18 +40,18 @@ namespace Fungus } // Find matching End statement at same indent level as While - for (int i = whileIndex + 1; i < parentBlock.commandList.Count; ++i) + for (int i = whileIndex + 1; i < ParentBlock.CommandList.Count; ++i) { - End endCommand = parentBlock.commandList[i] as End; + End endCommand = ParentBlock.CommandList[i] as End; if (endCommand != null && - endCommand.indentLevel == whileIndentLevel) + endCommand.IndentLevel == whileIndentLevel) { // Sanity check that break command is actually between the While and End commands - if (commandIndex > whileIndex && commandIndex < endCommand.commandIndex) + if (CommandIndex > whileIndex && CommandIndex < endCommand.CommandIndex) { // Continue at next command after End - Continue (endCommand.commandIndex + 1); + Continue (endCommand.CommandIndex + 1); return; } else diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Call.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Call.cs index 85e0f226..d05bee84 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Call.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Call.cs @@ -19,15 +19,15 @@ namespace Fungus public class Call : Command { [Tooltip("Flowchart which contains the block to execute. If none is specified then the current Flowchart is used.")] - public Flowchart targetFlowchart; + [SerializeField] protected Flowchart targetFlowchart; [FormerlySerializedAs("targetSequence")] [Tooltip("Block to start executing")] - public Block targetBlock; + [SerializeField] protected Block targetBlock; [Tooltip("Command index to start executing")] [FormerlySerializedAs("commandIndex")] - public int startIndex; + [SerializeField] protected int startIndex; public enum CallMode { @@ -37,7 +37,7 @@ namespace Fungus } [Tooltip("Select if the calling block should stop or continue executing commands, or wait until the called block finishes.")] - public CallMode callMode; + [SerializeField] protected CallMode callMode; public override void OnEnter() { @@ -46,7 +46,7 @@ namespace Fungus if (targetBlock != null) { // Check if calling your own parent block - if (targetBlock == parentBlock) + if (targetBlock == ParentBlock) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); @@ -58,7 +58,7 @@ namespace Fungus if (callMode == CallMode.WaitUntilFinished) { onComplete = delegate { - flowchart.selectedBlock = parentBlock; + flowchart.SelectedBlock = ParentBlock; Continue(); }; } @@ -68,9 +68,9 @@ namespace Fungus { // If the executing block is currently selected then follow the execution // onto the next block in the inspector. - if (flowchart.selectedBlock == parentBlock) + if (flowchart.SelectedBlock == ParentBlock) { - flowchart.selectedBlock = targetBlock; + flowchart.SelectedBlock = targetBlock; } StartCoroutine(targetBlock.Execute(startIndex, onComplete)); @@ -110,7 +110,7 @@ namespace Fungus } else { - summary = targetBlock.blockName; + summary = targetBlock.BlockName; } switch (callMode) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs index c3771fa2..11576d8b 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs @@ -18,13 +18,13 @@ namespace Fungus public class CallMethod : Command { [Tooltip("Target monobehavior which contains the method we want to call")] - public GameObject targetObject; + [SerializeField] protected GameObject targetObject; [Tooltip("Name of the method to call")] - public string methodName = ""; + [SerializeField] protected string methodName = ""; [Tooltip("Delay (in seconds) before the method will be called")] - public float delay; + [SerializeField] protected float delay; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs index 8017fb48..0d2718e1 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs @@ -16,11 +16,11 @@ namespace Fungus public class Comment : Command { [Tooltip("Name of Commenter")] - public string commenterName = ""; + [SerializeField] protected string commenterName = ""; [Tooltip("Text to display for this comment")] [TextArea(2,4)] - public string commentText = ""; + [SerializeField] protected string commentText = ""; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs index 50b2030c..4122418c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs @@ -23,7 +23,7 @@ namespace Fungus public abstract class Condition : Command { [Tooltip("The type of comparison to be performed")] - public CompareOperator compareOperator; + [SerializeField] protected CompareOperator compareOperator; public static string GetOperatorDescription(CompareOperator compareOperator) { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs index 2232cdc8..99f9083c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs @@ -22,10 +22,10 @@ namespace Fungus } [Tooltip("Display type of debug log info")] - public DebugLogType logType; + [SerializeField] protected DebugLogType logType; [Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")] - public StringDataMulti logMessage; + [SerializeField] protected StringDataMulti logMessage; public override void OnEnter () { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs b/Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs index d10c7489..31eac414 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs @@ -16,7 +16,7 @@ namespace Fungus public class DeleteSaveKey : Command { [Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}")] - public string key = ""; + [SerializeField] protected string key = ""; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs index 99f6daa2..6270b1f4 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs @@ -18,7 +18,7 @@ namespace Fungus public class Destroy : Command { [Tooltip("Reference to game object to destroy")] - public GameObjectData _targetGameObject; + [SerializeField] protected GameObjectData _targetGameObject; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Else.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Else.cs index 6957f23e..99e7354c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Else.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Else.cs @@ -17,13 +17,13 @@ namespace Fungus { public override void OnEnter() { - if (parentBlock == null) + if (ParentBlock == null) { return; } // Stop if this is the last command in the list - if (commandIndex >= parentBlock.commandList.Count - 1) + if (CommandIndex >= ParentBlock.CommandList.Count - 1) { StopParentBlock(); return; @@ -31,17 +31,17 @@ namespace Fungus // Find the next End command at the same indent level as this Else command int indent = indentLevel; - for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i) + for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { - Command command = parentBlock.commandList[i]; + Command command = ParentBlock.CommandList[i]; - if (command.indentLevel == indent) + if (command.IndentLevel == indent) { System.Type type = command.GetType(); if (type == typeof(End)) { // Execute command immediately after the EndIf command - Continue(command.commandIndex + 1); + Continue(command.CommandIndex + 1); return; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs b/Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs index 579c749d..61bea8b2 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs @@ -20,7 +20,7 @@ namespace Fungus public override void OnEnter() { - System.Type previousCommandType = parentBlock.GetPreviousActiveCommandType(); + System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); if (previousCommandType == typeof(If) || previousCommandType == typeof(ElseIf) ) @@ -34,7 +34,7 @@ namespace Fungus // but will also jump to a following Else command. // Stop if this is the last command in the list - if (commandIndex >= parentBlock.commandList.Count - 1) + if (CommandIndex >= ParentBlock.CommandList.Count - 1) { StopParentBlock(); return; @@ -42,17 +42,17 @@ namespace Fungus // Find the next End command at the same indent level as this Else If command int indent = indentLevel; - for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i) + for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { - Command command = parentBlock.commandList[i]; + Command command = ParentBlock.CommandList[i]; - if (command.indentLevel == indent) + if (command.IndentLevel == indent) { System.Type type = command.GetType(); if (type == typeof(End)) { // Execute command immediately after the Else or End command - Continue(command.commandIndex + 1); + Continue(command.CommandIndex + 1); return; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/End.cs b/Assets/Fungus/Flowchart/Scripts/Commands/End.cs index 48ae0643..916e8032 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/End.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/End.cs @@ -16,16 +16,15 @@ namespace Fungus [AddComponentMenu("")] public class End : Command { - [NonSerialized] - public bool loop = false; + public bool Loop { get; set; } public override void OnEnter() { - if (loop) + if (Loop) { - for (int i = commandIndex - 1; i >= 0; --i) + for (int i = CommandIndex - 1; i >= 0; --i) { - System.Type commandType = parentBlock.commandList[i].GetType(); + System.Type commandType = ParentBlock.CommandList[i].GetType(); if (commandType == typeof(While)) { Continue(i); diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/If.cs b/Assets/Fungus/Flowchart/Scripts/Commands/If.cs index 66c3ad73..64081c00 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/If.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/If.cs @@ -21,23 +21,23 @@ namespace Fungus typeof(IntegerVariable), typeof(FloatVariable), typeof(StringVariable))] - public Variable variable; + [SerializeField] protected Variable variable; [Tooltip("Boolean value to compare against")] - public BooleanData booleanData; + [SerializeField] protected BooleanData booleanData; [Tooltip("Integer value to compare against")] - public IntegerData integerData; + [SerializeField] protected IntegerData integerData; [Tooltip("Float value to compare against")] - public FloatData floatData; + [SerializeField] protected FloatData floatData; [Tooltip("String value to compare against")] - public StringDataMulti stringData; + [SerializeField] protected StringDataMulti stringData; public override void OnEnter() { - if (parentBlock == null) + if (ParentBlock == null) { return; } @@ -100,16 +100,16 @@ namespace Fungus protected virtual void OnFalse() { // Last command in block - if (commandIndex >= parentBlock.commandList.Count) + if (CommandIndex >= ParentBlock.CommandList.Count) { StopParentBlock(); return; } // Find the next Else, ElseIf or End command at the same indent level as this If command - for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i) + for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { - Command nextCommand = parentBlock.commandList[i]; + Command nextCommand = ParentBlock.CommandList[i]; if (nextCommand == null) { @@ -121,7 +121,7 @@ namespace Fungus if (!nextCommand.enabled || nextCommand.GetType() == typeof(Comment) || nextCommand.GetType() == typeof(Label) || - nextCommand.indentLevel != indentLevel) + nextCommand.IndentLevel != indentLevel) { continue; } @@ -130,7 +130,7 @@ namespace Fungus if (type == typeof(Else) || type == typeof(End)) { - if (i >= parentBlock.commandList.Count - 1) + if (i >= ParentBlock.CommandList.Count - 1) { // Last command in Block, so stop StopParentBlock(); @@ -138,7 +138,7 @@ namespace Fungus else { // Execute command immediately after the Else or End command - Continue(nextCommand.commandIndex + 1); + Continue(nextCommand.CommandIndex + 1); return; } } @@ -162,7 +162,7 @@ namespace Fungus return "Error: No variable selected"; } - string summary = variable.key + " "; + string summary = variable.Key + " "; summary += Condition.GetOperatorDescription(compareOperator) + " "; if (variable.GetType() == typeof(BooleanVariable)) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs index 0ef10fd7..68bc778f 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs @@ -35,36 +35,36 @@ namespace Fungus } [Tooltip("Delay (in seconds) before the methods will be called")] - public float delay; + [SerializeField] protected float delay; - public InvokeType invokeType; + [SerializeField] protected InvokeType invokeType; [Tooltip("List of methods to call. Supports methods with no parameters or exactly one string, int, float or object parameter.")] - public UnityEvent staticEvent = new UnityEvent(); + [SerializeField] protected UnityEvent staticEvent = new UnityEvent(); [Tooltip("Boolean parameter to pass to the invoked methods.")] - public BooleanData booleanParameter; + [SerializeField] protected BooleanData booleanParameter; [Tooltip("List of methods to call. Supports methods with one boolean parameter.")] - public BooleanEvent booleanEvent = new BooleanEvent(); + [SerializeField] protected BooleanEvent booleanEvent = new BooleanEvent(); [Tooltip("Integer parameter to pass to the invoked methods.")] - public IntegerData integerParameter; + [SerializeField] protected IntegerData integerParameter; [Tooltip("List of methods to call. Supports methods with one integer parameter.")] - public IntegerEvent integerEvent = new IntegerEvent(); + [SerializeField] protected IntegerEvent integerEvent = new IntegerEvent(); [Tooltip("Float parameter to pass to the invoked methods.")] - public FloatData floatParameter; + [SerializeField] protected FloatData floatParameter; [Tooltip("List of methods to call. Supports methods with one float parameter.")] - public FloatEvent floatEvent = new FloatEvent(); + [SerializeField] protected FloatEvent floatEvent = new FloatEvent(); [Tooltip("String parameter to pass to the invoked methods.")] - public StringDataMulti stringParameter; + [SerializeField] protected StringDataMulti stringParameter; [Tooltip("List of methods to call. Supports methods with one string parameter.")] - public StringEvent stringEvent = new StringEvent(); + [SerializeField] protected StringEvent stringEvent = new StringEvent(); public override void OnEnter() { @@ -89,16 +89,16 @@ namespace Fungus staticEvent.Invoke(); break; case InvokeType.DynamicBoolean: - booleanEvent.Invoke(booleanParameter); + booleanEvent.Invoke(booleanParameter.Value); break; case InvokeType.DynamicInteger: - integerEvent.Invoke(integerParameter); + integerEvent.Invoke(integerParameter.Value); break; case InvokeType.DynamicFloat: - floatEvent.Invoke(floatParameter); + floatEvent.Invoke(floatParameter.Value); break; case InvokeType.DynamicString: - stringEvent.Invoke(stringParameter); + stringEvent.Invoke(stringParameter.Value); break; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs index bbc9e099..73715a70 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs @@ -21,51 +21,53 @@ namespace Fungus public class InvokeMethod : Command { [Tooltip("GameObject containing the component method to be invoked")] - public GameObject targetObject; + [SerializeField] protected GameObject targetObject; + + public GameObject TargetObject { get { return targetObject; } } [HideInInspector] [Tooltip("Name of assembly containing the target component")] - public string targetComponentAssemblyName; + [SerializeField] protected string targetComponentAssemblyName; [HideInInspector] [Tooltip("Full name of the target component")] - public string targetComponentFullname; + [SerializeField] protected string targetComponentFullname; [HideInInspector] [Tooltip("Display name of the target component")] - public string targetComponentText; + [SerializeField] protected string targetComponentText; [HideInInspector] [Tooltip("Name of target method to invoke on the target component")] - public string targetMethod; + [SerializeField] protected string targetMethod; [HideInInspector] [Tooltip("Display name of target method to invoke on the target component")] - public string targetMethodText; + [SerializeField] protected string targetMethodText; [HideInInspector] [Tooltip("List of parameters to pass to the invoked method")] - public InvokeMethodParameter[] methodParameters; + [SerializeField] protected InvokeMethodParameter[] methodParameters; [HideInInspector] [Tooltip("If true, store the return value in a flowchart variable of the same type.")] - public bool saveReturnValue; + [SerializeField] protected bool saveReturnValue; [HideInInspector] [Tooltip("Name of Fungus variable to store the return value in")] - public string returnValueVariableKey; + [SerializeField] protected string returnValueVariableKey; [HideInInspector] [Tooltip("The type of the return value")] - public string returnValueType; + [SerializeField] protected string returnValueType; [HideInInspector] [Tooltip("If true, list all inherited methods for the component")] - public bool showInherited; + [SerializeField] protected bool showInherited; [HideInInspector] [Tooltip("The coroutine call behavior for methods that return IEnumerator")] - public Fungus.Call.CallMode callMode; + [SerializeField] protected Call.CallMode callMode; protected Type componentType; protected Component objComponent; diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs index 99baf005..8b344b56 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs @@ -16,7 +16,7 @@ namespace Fungus public class Jump : Command { [Tooltip("Name of a label in this block to jump to")] - public StringData _targetLabel = new StringData(""); + [SerializeField] protected StringData _targetLabel = new StringData(""); public override void OnEnter() { @@ -26,13 +26,13 @@ namespace Fungus return; } - foreach (Command command in parentBlock.commandList) + foreach (Command command in ParentBlock.CommandList) { Label label = command as Label; if (label != null && - label.key == _targetLabel.Value) + label.Key == _targetLabel.Value) { - Continue(label.commandIndex + 1); + Continue(label.CommandIndex + 1); return; } } @@ -65,7 +65,7 @@ namespace Fungus { if (targetLabelOLD != null) { - _targetLabel.Value = targetLabelOLD.key; + _targetLabel.Value = targetLabelOLD.Key; targetLabelOLD = null; } } diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Label.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Label.cs index 4fb27787..c92ab861 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Label.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Label.cs @@ -16,7 +16,9 @@ namespace Fungus public class Label : Command { [Tooltip("Display name for the label")] - public string key = ""; + [SerializeField] protected string key = ""; + + public string Key { get { return key; } } public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs index e40a0f0a..2b0f86d5 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs @@ -21,10 +21,10 @@ namespace Fungus public class LoadScene : Command { [Tooltip("Name of the scene to load. The scene must also be added to the build settings.")] - public StringData _sceneName = new StringData(""); + [SerializeField] protected StringData _sceneName = new StringData(""); [Tooltip("Image to display while loading the scene")] - public Texture2D loadingImage; + [SerializeField] protected Texture2D loadingImage; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs index 514a94a8..e93d6e3a 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs @@ -16,7 +16,7 @@ namespace Fungus public class LoadVariable : Command { [Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}\"")] - public string key = ""; + [SerializeField] protected string key = ""; [Tooltip("Variable to store the value in.")] [VariableProperty(typeof(BooleanVariable), @@ -90,7 +90,7 @@ namespace Fungus return "Error: No variable selected"; } - return "'" + key + "' into " + variable.key; + return "'" + key + "' into " + variable.Key; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs index 1f925166..f54ece81 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs @@ -16,7 +16,7 @@ namespace Fungus public class LinkToWebsite : Command { [Tooltip("URL to open in the browser")] - public StringData url = new StringData(); + [SerializeField] protected StringData url = new StringData(); public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs index edfaf95b..670268c6 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs @@ -16,13 +16,13 @@ namespace Fungus { [Tooltip("The variable whos value will be set")] [VariableProperty(typeof(FloatVariable))] - public FloatVariable variable; + [SerializeField] protected FloatVariable variable; [Tooltip("Minimum value for random range")] - public FloatData minValue; + [SerializeField] protected FloatData minValue; [Tooltip("Maximum value for random range")] - public FloatData maxValue; + [SerializeField] protected FloatData maxValue; public override void OnEnter() { @@ -41,7 +41,7 @@ namespace Fungus return "Error: Variable not selected"; } - return variable.key; + return variable.Key; } public override bool HasReference(Variable variable) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs index 8eb5e3bb..c0b20112 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs @@ -16,13 +16,13 @@ namespace Fungus { [Tooltip("The variable whos value will be set")] [VariableProperty(typeof(IntegerVariable))] - public IntegerVariable variable; + [SerializeField] protected IntegerVariable variable; [Tooltip("Minimum value for random range")] - public IntegerData minValue; + [SerializeField] protected IntegerData minValue; [Tooltip("Maximum value for random range")] - public IntegerData maxValue; + [SerializeField] protected IntegerData maxValue; public override void OnEnter() { @@ -41,7 +41,7 @@ namespace Fungus return "Error: Variable not selected"; } - return variable.key; + return variable.Key; } public override bool HasReference(Variable variable) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs b/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs index 144dc9e6..e4b4fe2a 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs @@ -16,11 +16,11 @@ namespace Fungus public class ReadTextFile : Command { [Tooltip("Text file to read into the string variable")] - public TextAsset textFile; + [SerializeField] protected TextAsset textFile; [Tooltip("String variable to store the tex file contents in")] [VariableProperty(typeof(StringVariable))] - public StringVariable stringVariable; + [SerializeField] protected StringVariable stringVariable; public override void OnEnter() { @@ -48,7 +48,7 @@ namespace Fungus return "Error: Text file not selected"; } - return stringVariable.key; + return stringVariable.Key; } public override bool HasReference(Variable variable) diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs index cebec1fc..32be1d32 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs @@ -16,10 +16,10 @@ namespace Fungus public class Reset : Command { [Tooltip("Reset state of all commands in the script")] - public bool resetCommands = true; + [SerializeField] protected bool resetCommands = true; [Tooltip("Reset variables back to their default values")] - public bool resetVariables = true; + [SerializeField] protected bool resetVariables = true; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs index 38d5e9ed..c95f1a5a 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs @@ -18,7 +18,7 @@ namespace Fungus public class SaveVariable : Command { [Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}")] - public string key = ""; + [SerializeField] protected string key = ""; [Tooltip("Variable to read the value from. Only Boolean, Integer, Float and String are supported.")] [VariableProperty(typeof(BooleanVariable), @@ -92,7 +92,7 @@ namespace Fungus return "Error: No variable selected"; } - return variable.key + " into '" + key + "'"; + return variable.Key + " into '" + key + "'"; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs index c0e371fc..bc641c8c 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs @@ -23,10 +23,10 @@ namespace Fungus } [Tooltip("Target flowchart(s) to send the message to")] - public MessageTarget messageTarget; + [SerializeField] protected MessageTarget messageTarget; [Tooltip("Name of the message to send")] - public StringData _message = new StringData(""); + [SerializeField] protected StringData _message = new StringData(""); public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs index 8cfdb195..45cabdc4 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs @@ -18,10 +18,10 @@ namespace Fungus public class SetActive : Command { [Tooltip("Reference to game object to enable / disable")] - public GameObjectData _targetGameObject; + [SerializeField] protected GameObjectData _targetGameObject; [Tooltip("Set to true to enable the game object")] - public BooleanData activeState; + [SerializeField] protected BooleanData activeState; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs index 245f9f79..5feb81e3 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs @@ -21,7 +21,7 @@ namespace Fungus public static string saveProfile = ""; [Tooltip("Name of save profile to make active.")] - public string saveProfileName = ""; + [SerializeField] protected string saveProfileName = ""; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs index fb41c59d..3805a214 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs @@ -29,22 +29,24 @@ namespace Fungus typeof(IntegerVariable), typeof(FloatVariable), typeof(StringVariable))] - public Variable variable; + [SerializeField] protected Variable variable; [Tooltip("The type of math operation to be performed")] - public SetOperator setOperator; + [SerializeField] protected SetOperator setOperator; + + public SetOperator _SetOperator { get { return setOperator; } } [Tooltip("Boolean value to set with")] - public BooleanData booleanData; + [SerializeField] protected BooleanData booleanData; [Tooltip("Integer value to set with")] - public IntegerData integerData; + [SerializeField] protected IntegerData integerData; [Tooltip("Float value to set with")] - public FloatData floatData; + [SerializeField] protected FloatData floatData; [Tooltip("String value to set with")] - public StringDataMulti stringData; + [SerializeField] protected StringDataMulti stringData; public override void OnEnter() { @@ -60,7 +62,7 @@ namespace Fungus return "Error: Variable not selected"; } - string description = variable.key; + string description = variable.Key; switch (setOperator) { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs b/Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs index 65fc88d7..537399e8 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs @@ -20,16 +20,16 @@ namespace Fungus public class SpawnObject : Command { [Tooltip("Game object to copy when spawning. Can be a scene object or a prefab.")] - public GameObjectData _sourceObject; + [SerializeField] protected GameObjectData _sourceObject; [Tooltip("Transform to use for position of newly spawned object.")] - public TransformData _parentTransform; + [SerializeField] protected TransformData _parentTransform; [Tooltip("Local position of newly spawned object.")] - public Vector3Data _spawnPosition; + [SerializeField] protected Vector3Data _spawnPosition; [Tooltip("Local rotation of newly spawned object.")] - public Vector3Data _spawnRotation; + [SerializeField] protected Vector3Data _spawnRotation; public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs index 1084e6c1..7f4c3aa8 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs @@ -15,10 +15,10 @@ namespace Fungus public class StopBlock : Command { [Tooltip("Flowchart containing the Block. If none is specified, the parent Flowchart is used.")] - public Flowchart flowchart; + [SerializeField] protected Flowchart flowchart; [Tooltip("Name of the Block to stop")] - public StringData blockName = new StringData(""); + [SerializeField] protected StringData blockName = new StringData(""); public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs b/Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs index f98c5cba..067363c8 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs @@ -16,10 +16,10 @@ namespace Fungus public class StopFlowchart : Command { [Tooltip("Stop all executing Blocks in the Flowchart that contains this command")] - public bool stopParentFlowchart; + [SerializeField] protected bool stopParentFlowchart; [Tooltip("Stop all executing Blocks in a list of target Flowcharts")] - public List targetFlowcharts = new List(); + [SerializeField] protected List targetFlowcharts = new List(); public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs b/Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs index 141675e4..960569b8 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs @@ -18,7 +18,7 @@ namespace Fungus public class Wait : Command { [Tooltip("Duration to wait for")] - public FloatData _duration = new FloatData(1); + [SerializeField] protected FloatData _duration = new FloatData(1); public override void OnEnter() { diff --git a/Assets/Fungus/Flowchart/Scripts/Commands/While.cs b/Assets/Fungus/Flowchart/Scripts/Commands/While.cs index fc025f75..9ca478e6 100644 --- a/Assets/Fungus/Flowchart/Scripts/Commands/While.cs +++ b/Assets/Fungus/Flowchart/Scripts/Commands/While.cs @@ -26,12 +26,12 @@ namespace Fungus // Find next End statement at same indent level End endCommand = null; - for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i) + for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { - End command = parentBlock.commandList[i] as End; + End command = ParentBlock.CommandList[i] as End; if (command != null && - command.indentLevel == indentLevel) + command.IndentLevel == indentLevel) { endCommand = command; break; @@ -41,13 +41,13 @@ namespace Fungus if (execute) { // Tell the following end command to loop back - endCommand.loop = true; + endCommand.Loop = true; Continue(); } else { // Continue at next command after End - Continue (endCommand.commandIndex + 1); + Continue (endCommand.CommandIndex + 1); } } diff --git a/Assets/Fungus/Flowchart/Scripts/EventHandler.cs b/Assets/Fungus/Flowchart/Scripts/EventHandler.cs index 0ae07130..dc406283 100644 --- a/Assets/Fungus/Flowchart/Scripts/EventHandler.cs +++ b/Assets/Fungus/Flowchart/Scripts/EventHandler.cs @@ -41,7 +41,9 @@ namespace Fungus { [HideInInspector] [FormerlySerializedAs("parentSequence")] - public Block parentBlock; + [SerializeField] protected Block parentBlock; + + public Block ParentBlock { get { return parentBlock; } set { parentBlock = value; } } /** * The Event Handler should call this method when the event is detected. @@ -53,7 +55,7 @@ namespace Fungus return false; } - if (parentBlock.eventHandler != this) + if (parentBlock._EventHandler != this) { return false; } @@ -61,9 +63,9 @@ namespace Fungus Flowchart flowchart = parentBlock.GetFlowchart(); // Auto-follow the executing block if none is currently selected - if (flowchart.selectedBlock == null) + if (flowchart.SelectedBlock == null) { - flowchart.selectedBlock = parentBlock; + flowchart.SelectedBlock = parentBlock; } return flowchart.ExecuteBlock(parentBlock); diff --git a/Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs b/Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs index ecf973fa..1f7788c1 100644 --- a/Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs +++ b/Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs @@ -22,10 +22,10 @@ namespace Fungus } [Tooltip("The type of keypress to activate on")] - public KeyPressType keyPressType; + [SerializeField] protected KeyPressType keyPressType; [Tooltip("Keycode of the key to activate on")] - public KeyCode keyCode; + [SerializeField] protected KeyCode keyCode; protected virtual void Update() { diff --git a/Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs b/Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs index c21c01e4..95885b26 100644 --- a/Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs +++ b/Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs @@ -15,7 +15,7 @@ namespace Fungus public class MessageReceived : EventHandler { [Tooltip("Fungus message to listen for")] - public string message = ""; + [SerializeField] protected string message = ""; public void OnSendFungusMessage(string message) { diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index b9b13320..63a08506 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -45,126 +45,161 @@ namespace Fungus * Variable to track flowchart's version so components can update to new versions. */ [HideInInspector] - public int version = 0; // Default to 0 to always trigger an update for older versions of Fungus. + [SerializeField] protected int version = 0; // Default to 0 to always trigger an update for older versions of Fungus. + + public int Version { set { version = value; } } /** * Scroll position of Flowchart editor window. */ [HideInInspector] - public Vector2 scrollPos; + [SerializeField] protected Vector2 scrollPos; + + public Vector2 ScrollPos { get { return scrollPos; } set { scrollPos = value; } } /** * Scroll position of Flowchart variables window. */ [HideInInspector] - public Vector2 variablesScrollPos; + [SerializeField] protected Vector2 variablesScrollPos; + + public Vector2 VariablesScrollPos { get { return variablesScrollPos; } set { variablesScrollPos = value; } } /** * Show the variables pane. */ [HideInInspector] - public bool variablesExpanded = true; + [SerializeField] protected bool variablesExpanded = true; + + public bool VariablesExpanded { get { return variablesExpanded; } set { variablesExpanded = value; } } /** * Height of command block view in inspector. */ [HideInInspector] - public float blockViewHeight = 400; + [SerializeField] protected float blockViewHeight = 400; + + public float BlockViewHeight { get { return blockViewHeight; } set { blockViewHeight = value; } } /** * Zoom level of Flowchart editor window */ [HideInInspector] - public float zoom = 1f; + [SerializeField] protected float zoom = 1f; + + public float Zoom { get { return zoom; } set { zoom = value; } } /** * Scrollable area for Flowchart editor window. */ [HideInInspector] - public Rect scrollViewRect; + [SerializeField] protected Rect scrollViewRect; + + public Rect ScrollViewRect { get { return scrollViewRect; } set { scrollViewRect = value; } } /** * Currently selected block in the Flowchart editor. */ [HideInInspector] [FormerlySerializedAs("selectedSequence")] - public Block selectedBlock; + [SerializeField] protected Block selectedBlock; + + public Block SelectedBlock { get { return selectedBlock; } set { selectedBlock = value; } } /** * Currently selected command in the Flowchart editor. */ [HideInInspector] - public List selectedCommands = new List(); + [SerializeField] protected List selectedCommands = new List(); + + public List SelectedCommands { get { return selectedCommands; } } /** * The list of variables that can be accessed by the Flowchart. */ [HideInInspector] - public List variables = new List(); + [SerializeField] protected List variables = new List(); + + public List Variables { get { return variables; } } [TextArea(3, 5)] [Tooltip("Description text displayed in the Flowchart editor window")] - public string description = ""; + [SerializeField] protected string description = ""; + + public string Description { get { return description; } } /** * Slow down execution in the editor to make it easier to visualise program flow. */ [Range(0f, 5f)] [Tooltip("Adds a pause after each execution step to make it easier to visualise program flow. Editor only, has no effect in platform builds.")] - public float stepPause = 0f; + [SerializeField] protected float stepPause = 0f; + + public float StepPause { get { return stepPause; } } /** * Use command color when displaying the command list in the inspector. */ [Tooltip("Use command color when displaying the command list in the Fungus Editor window")] - public bool colorCommands = true; + [SerializeField] protected bool colorCommands = true; + + public bool ColorCommands { get { return colorCommands; } } /** * Hides the Flowchart block and command components in the inspector. * Deselect to inspect the block and command components that make up the Flowchart. */ [Tooltip("Hides the Flowchart block and command components in the inspector")] - public bool hideComponents = true; + [SerializeField] protected bool hideComponents = true; /** * Saves the selected block and commands when saving the scene. * Helps avoid version control conflicts if you've only changed the active selection. */ [Tooltip("Saves the selected block and commands when saving the scene.")] - public bool saveSelection = true; + [SerializeField] protected bool saveSelection = true; + + public bool SaveSelection { get { return saveSelection; } } /** * Unique identifier for identifying this flowchart in localized string keys. */ [Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")] - public string localizationId = ""; + [SerializeField] protected string localizationId = ""; + + public string LocalizationId { get { return localizationId; } } /** * Display line numbers in the command list in the Block inspector. */ [Tooltip("Display line numbers in the command list in the Block inspector.")] - public bool showLineNumbers = false; + [SerializeField] protected bool showLineNumbers = false; + + public bool ShowLineNumbers { get { return showLineNumbers; } } /** * List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart. */ [Tooltip("List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart.")] - public List hideCommands = new List(); + [SerializeField] protected List hideCommands = new List(); [Tooltip("Lua Environment to be used by default for all Execute Lua commands in this Flowchart")] - public LuaEnvironment luaEnvironment; + [SerializeField] protected LuaEnvironment luaEnvironment; + + public LuaEnvironment _LuaEnvironment { get { return luaEnvironment; } } /** * The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing. */ [Tooltip("The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.")] - public string luaBindingName = "flowchart"; + [SerializeField] protected string luaBindingName = "flowchart"; + + public string LuaBindingName { get { return luaBindingName; } } /** * Position in the center of all blocks in the flowchart. */ - [NonSerialized] - public Vector2 centerPosition = Vector2.zero; + public Vector2 CenterPosition { set; get; } /** * Cached list of flowchart objects in the scene for fast lookup @@ -186,13 +221,13 @@ namespace Fungus Block[] blocks = GetComponents(); foreach (Block block in blocks) { - maxId = Math.Max(maxId, block.itemId); + maxId = Math.Max(maxId, block.ItemId); } Command[] commands = GetComponents(); foreach (Command command in commands) { - maxId = Math.Max(maxId, command.itemId); + maxId = Math.Max(maxId, command.ItemId); } return maxId + 1; } @@ -292,23 +327,23 @@ namespace Fungus Block[] blocks = GetComponents(); foreach (Block block in blocks) { - if (block.itemId == -1 || - usedIds.Contains(block.itemId)) + if (block.ItemId == -1 || + usedIds.Contains(block.ItemId)) { - block.itemId = NextItemId(); + block.ItemId = NextItemId(); } - usedIds.Add(block.itemId); + usedIds.Add(block.ItemId); } Command[] commands = GetComponents(); foreach (Command command in commands) { - if (command.itemId == -1 || - usedIds.Contains(command.itemId)) + if (command.ItemId == -1 || + usedIds.Contains(command.ItemId)) { - command.itemId = NextItemId(); + command.ItemId = NextItemId(); } - usedIds.Add(command.itemId); + usedIds.Add(command.ItemId); } } @@ -337,7 +372,7 @@ namespace Fungus bool found = false; foreach (Block block in blocks) { - if (block.commandList.Contains(command)) + if (block.CommandList.Contains(command)) { found = true; break; @@ -355,7 +390,7 @@ namespace Fungus bool found = false; foreach (Block block in blocks) { - if (block.eventHandler == eventHandler) + if (block._EventHandler == eventHandler) { found = true; break; @@ -381,10 +416,9 @@ namespace Fungus public virtual Block CreateBlock(Vector2 position) { Block b = CreateBlockComponent(gameObject); - b.nodeRect.x = position.x; - b.nodeRect.y = position.y; - b.blockName = GetUniqueBlockKey(b.blockName, b); - b.itemId = NextItemId(); + b._NodeRect = new Rect(position.x, position.y, 0, 0); + b.BlockName = GetUniqueBlockKey(b.BlockName, b); + b.ItemId = NextItemId(); return b; } @@ -397,7 +431,7 @@ namespace Fungus Block [] blocks = GetComponents(); foreach (Block block in blocks) { - if (block.blockName == blockName) + if (block.BlockName == blockName) { return block; } @@ -416,7 +450,7 @@ namespace Fungus Block block = null; foreach (Block b in GetComponents()) { - if (b.blockName == blockName) + if (b.BlockName == blockName) { block = b; break; @@ -537,12 +571,12 @@ namespace Fungus { if (variable == null || variable == ignoreVariable || - variable.key == null) + variable.Key == null) { continue; } - if (variable.key.Equals(key, StringComparison.CurrentCultureIgnoreCase)) + if (variable.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)) { collision = true; suffix++; @@ -580,12 +614,12 @@ namespace Fungus foreach(Block block in blocks) { if (block == ignoreBlock || - block.blockName == null) + block.BlockName == null) { continue; } - if (block.blockName.Equals(key, StringComparison.CurrentCultureIgnoreCase)) + if (block.BlockName.Equals(key, StringComparison.CurrentCultureIgnoreCase)) { collision = true; suffix++; @@ -614,13 +648,13 @@ namespace Fungus baseKey = "New Label"; } - Block block = ignoreLabel.parentBlock; + Block block = ignoreLabel.ParentBlock; string key = baseKey; while (true) { bool collision = false; - foreach(Command command in block.commandList) + foreach(Command command in block.CommandList) { Label label = command as Label; if (label == null || @@ -629,7 +663,7 @@ namespace Fungus continue; } - if (label.key.Equals(key, StringComparison.CurrentCultureIgnoreCase)) + if (label.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase)) { collision = true; suffix++; @@ -655,7 +689,7 @@ namespace Fungus { foreach (Variable variable in variables) { - if (variable != null && variable.key == key) + if (variable != null && variable.Key == key) { return variable; } @@ -674,7 +708,7 @@ namespace Fungus { foreach (Variable variable in variables) { - if (variable != null && variable.key == key) + if (variable != null && variable.Key == key) { return variable as T; } @@ -692,7 +726,7 @@ namespace Fungus { foreach (Variable v in variables) { - if (v != null && v.key == key) + if (v != null && v.Key == key) { T variable = v as T; if (variable != null) @@ -714,7 +748,7 @@ namespace Fungus List publicVariables = new List(); foreach (Variable v in variables) { - if (v != null && v.scope == VariableScope.Public) + if (v != null && v.Scope == VariableScope.Public) { publicVariables.Add(v); } @@ -1004,8 +1038,8 @@ namespace Fungus if (variable == null) continue; - if (variable.scope == VariableScope.Public && - variable.key == key) + if (variable.Scope == VariableScope.Public && + variable.Key == key) { string value = variable.ToString(); input.Replace(match.Value, value); @@ -1032,7 +1066,7 @@ namespace Fungus } // Use the string builder from StringSubstituter for efficiency. - StringBuilder sb = stringSubstituer.stringBuilder; + StringBuilder sb = stringSubstituer._StringBuilder; sb.Length = 0; sb.Append(input); @@ -1053,8 +1087,8 @@ namespace Fungus if (variable == null) continue; - if (variable.scope == VariableScope.Private && - variable.key == key) + if (variable.Scope == VariableScope.Private && + variable.Key == key) { string value = variable.ToString(); sb.Replace(match.Value, value); diff --git a/Assets/Fungus/Flowchart/Scripts/FungusState.cs b/Assets/Fungus/Flowchart/Scripts/FungusState.cs index 5ae21d8e..db7e07d9 100644 --- a/Assets/Fungus/Flowchart/Scripts/FungusState.cs +++ b/Assets/Fungus/Flowchart/Scripts/FungusState.cs @@ -14,7 +14,9 @@ namespace Fungus [AddComponentMenu("")] public class FungusState : MonoBehaviour { - public Flowchart selectedFlowchart; + [SerializeField] protected Flowchart selectedFlowchart; + + public Flowchart SelectedFlowchart { get { return selectedFlowchart; } set { selectedFlowchart = value; } } } } \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/Node.cs b/Assets/Fungus/Flowchart/Scripts/Node.cs index fbc013da..40b74b85 100644 --- a/Assets/Fungus/Flowchart/Scripts/Node.cs +++ b/Assets/Fungus/Flowchart/Scripts/Node.cs @@ -12,7 +12,9 @@ namespace Fungus [AddComponentMenu("")] public class Node : MonoBehaviour { - public Rect nodeRect = new Rect(0, 0, 120, 30); + [SerializeField] protected Rect nodeRect = new Rect(0, 0, 120, 30); + + public Rect _NodeRect { get { return nodeRect; } set { nodeRect = value; } } } } \ No newline at end of file diff --git a/Assets/Fungus/Flowchart/Scripts/Variable.cs b/Assets/Fungus/Flowchart/Scripts/Variable.cs index f8a7645f..2b6f6d17 100644 --- a/Assets/Fungus/Flowchart/Scripts/Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/Variable.cs @@ -51,9 +51,13 @@ namespace Fungus [RequireComponent(typeof(Flowchart))] public abstract class Variable : MonoBehaviour { - public VariableScope scope; + [SerializeField] protected VariableScope scope; - public string key = ""; + public VariableScope Scope { get { return scope; } } + + [SerializeField] protected string key = ""; + + public string Key { get { return key; } set { key = value; } } public abstract void OnReset(); } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs index 5e59691b..96759529 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return animatorRef.key; + return animatorRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs index d65ff6e1..439f97c4 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return audioSourceRef.key; + return audioSourceRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs index 939da10f..cdd752d2 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs @@ -73,7 +73,7 @@ namespace Fungus } else { - return booleanRef.key; + return booleanRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs index d14c28c2..40c802c0 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return colorRef.key; + return colorRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs index cf842778..09a9a953 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs @@ -81,7 +81,7 @@ namespace Fungus } else { - return floatRef.key; + return floatRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs index 9aaba0ca..f6fa5d3f 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return gameObjectRef.key; + return gameObjectRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs index 47ec0f2b..2ecbfd37 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs @@ -81,7 +81,7 @@ namespace Fungus } else { - return integerRef.key; + return integerRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs index 7ccb0a79..c27b5e2d 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return materialRef.key; + return materialRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs index ee890185..2ffbe3e0 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return objectRef.key; + return objectRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs index 675b5c44..04bae03d 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return spriteRef.key; + return spriteRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs index 4d0ffba1..1be6aa09 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs @@ -80,7 +80,7 @@ namespace Fungus } else { - return stringRef.key; + return stringRef.Key; } } } @@ -130,7 +130,7 @@ namespace Fungus } else { - return stringRef.key; + return stringRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs index d39cc232..016011d9 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return textureRef.key; + return textureRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs index 1514e684..d15d72cf 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return transformRef.key; + return transformRef.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs index 7d031eaa..f3e73d9e 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return vector2Ref.key; + return vector2Ref.Key; } } } diff --git a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs index 34436f32..fa4d857f 100644 --- a/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs +++ b/Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs @@ -49,7 +49,7 @@ namespace Fungus } else { - return vector3Ref.key; + return vector3Ref.Key; } } } diff --git a/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs index be7da86b..7cbebea5 100644 --- a/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs +++ b/Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs @@ -59,14 +59,14 @@ namespace Fungus } // Cache a descriptive name to use in Lua error messages - friendlyName = gameObject.name + "." + parentBlock.blockName + "." + "ExecuteLua #" + commandIndex.ToString(); + friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + "ExecuteLua #" + CommandIndex.ToString(); Flowchart flowchart = GetFlowchart(); // See if a Lua Environment has been assigned to this Flowchart if (luaEnvironment == null) { - luaEnvironment = flowchart.luaEnvironment; + luaEnvironment = flowchart._LuaEnvironment; } // No Lua Environment specified so just use any available or create one. @@ -79,12 +79,12 @@ namespace Fungus luaFunction = luaEnvironment.LoadLuaString(s, friendlyName); // Add a binding to the parent flowchart - if (flowchart.luaBindingName != "") + if (flowchart.LuaBindingName != "") { Table globals = luaEnvironment.Interpreter.Globals; if (globals != null) { - globals[flowchart.luaBindingName] = flowchart; + globals[flowchart.LuaBindingName] = flowchart; } } diff --git a/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs b/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs index 9f03b1cf..18bfcab2 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs +++ b/Assets/Fungus/Narrative/Scripts/Commands/Menu.cs @@ -83,7 +83,7 @@ namespace Fungus return "Error: No button text selected"; } - return text + " : " + targetBlock.blockName; + return text + " : " + targetBlock.BlockName; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs index 2933abd1..d5c43bea 100644 --- a/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs +++ b/Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs @@ -54,7 +54,7 @@ namespace Fungus return "Error: No target block selected"; } - return targetBlock.blockName; + return targetBlock.BlockName; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Narrative/Scripts/Localization.cs b/Assets/Fungus/Narrative/Scripts/Localization.cs index 72cf2930..02b3a6da 100644 --- a/Assets/Fungus/Narrative/Scripts/Localization.cs +++ b/Assets/Fungus/Narrative/Scripts/Localization.cs @@ -232,7 +232,7 @@ namespace Fungus Block[] blocks = flowchart.GetComponents(); foreach (Block block in blocks) { - foreach (Command command in block.commandList) + foreach (Command command in block.CommandList) { ILocalizable localizable = command as ILocalizable; if (localizable != null) diff --git a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs index 2f778406..5580eed6 100644 --- a/Assets/Fungus/Narrative/Scripts/MenuDialog.cs +++ b/Assets/Fungus/Narrative/Scripts/MenuDialog.cs @@ -142,7 +142,7 @@ namespace Fungus #if UNITY_EDITOR // Select the new target block in the Flowchart window Flowchart flowchart = block.GetFlowchart(); - flowchart.selectedBlock = block; + flowchart.SelectedBlock = block; #endif gameObject.SetActive(false); diff --git a/Assets/Fungus/Sprite/Scripts/Clickable2D.cs b/Assets/Fungus/Sprite/Scripts/Clickable2D.cs index e09b0a40..cb5b99fc 100644 --- a/Assets/Fungus/Sprite/Scripts/Clickable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Clickable2D.cs @@ -16,13 +16,15 @@ namespace Fungus public class Clickable2D : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler { [Tooltip("Is object clicking enabled")] - public bool clickEnabled = true; + [SerializeField] protected bool clickEnabled = true; + + public bool ClickEnabled { set { clickEnabled = value; } } [Tooltip("Mouse texture to use when hovering mouse over object")] - public Texture2D hoverCursor; + [SerializeField] protected Texture2D hoverCursor; [Tooltip("Use the UI Event System to check for clicks. Clicks that hit an overlapping UI object will be ignored. Camera must have a PhysicsRaycaster component, or a Physics2DRaycaster for 2D colliders.")] - public bool useEventSystem; + [SerializeField] protected bool useEventSystem; #region Legacy OnMouseX methods protected virtual void OnMouseDown() diff --git a/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs index 5bcbd46b..2ecd3d6e 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs @@ -37,17 +37,9 @@ namespace Fungus return; } - CameraController cameraController = CameraController.GetInstance(); - - if (waitUntilFinished) - { - cameraController.waiting = true; - } - SpriteFader.FadeSprite(spriteRenderer, _targetColor.Value, _duration.Value, Vector2.zero, delegate { if (waitUntilFinished) { - cameraController.waiting = false; Continue(); } }); diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs index d8423f4c..60549c29 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs @@ -16,16 +16,16 @@ namespace Fungus public class SetClickable2D : Command { [Tooltip("Reference to Clickable2D component on a gameobject")] - public Clickable2D targetClickable2D; + [SerializeField] protected Clickable2D targetClickable2D; [Tooltip("Set to true to enable the component")] - public BooleanData activeState; + [SerializeField] protected BooleanData activeState; public override void OnEnter() { if (targetClickable2D != null) { - targetClickable2D.clickEnabled = activeState.Value; + targetClickable2D.ClickEnabled = activeState.Value; } Continue(); diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs index 9dfff43a..afc94a7c 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs @@ -16,13 +16,13 @@ namespace Fungus public class SetCollider : Command { [Tooltip("A list of gameobjects containing collider components to be set active / inactive")] - public List targetObjects = new List(); + [SerializeField] protected List targetObjects = new List(); [Tooltip("All objects with this tag will have their collider set active / inactive")] - public string targetTag = ""; + [SerializeField] protected string targetTag = ""; [Tooltip("Set to true to enable the collider components")] - public BooleanData activeState; + [SerializeField] protected BooleanData activeState; public override void OnEnter() { diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs index 7183bf97..3f093b04 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs @@ -16,16 +16,16 @@ namespace Fungus public class SetDraggable2D : Command { [Tooltip("Reference to Draggable2D component on a gameobject")] - public Draggable2D targetDraggable2D; + [SerializeField] protected Draggable2D targetDraggable2D; [Tooltip("Set to true to enable the component")] - public BooleanData activeState; + [SerializeField] protected BooleanData activeState; public override void OnEnter() { if (targetDraggable2D != null) { - targetDraggable2D.dragEnabled = activeState.Value; + targetDraggable2D.DragEnabled = activeState.Value; } Continue(); diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs index 04fd7f3c..05af3412 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs @@ -16,10 +16,10 @@ namespace Fungus public class SetSortingLayer : Command { [Tooltip("Root Object that will have the Sorting Layer set. Any children will also be affected")] - public GameObject targetObject; + [SerializeField] protected GameObject targetObject; [Tooltip("The New Layer Name to apply")] - public string sortingLayer; + [SerializeField] protected string sortingLayer; public override void OnEnter() { diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs index 11258890..0848a21d 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs @@ -15,10 +15,10 @@ namespace Fungus public class SetMouseCursor : Command { [Tooltip("Texture to use for cursor. Will use default mouse cursor if no sprite is specified")] - public Texture2D cursorTexture; + [SerializeField] protected Texture2D cursorTexture; [Tooltip("The offset from the top left of the texture to use as the target point")] - public Vector2 hotSpot; + [SerializeField] protected Vector2 hotSpot; // Cached static cursor settings protected static Texture2D activeCursorTexture; diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs index 74a2c562..071a10e3 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs @@ -16,10 +16,10 @@ namespace Fungus public class SetSpriteOrder : Command { [Tooltip("List of sprites to set the order in layer property on")] - public List targetSprites = new List(); + [SerializeField] protected List targetSprites = new List(); [Tooltip("The order in layer value to set on the target sprites")] - public IntegerData orderInLayer; + [SerializeField] protected IntegerData orderInLayer; public override void OnEnter() { diff --git a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs index edc85516..6f2a9184 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs @@ -18,13 +18,13 @@ namespace Fungus public class ShowSprite : Command { [Tooltip("Sprite object to be made visible / invisible")] - public SpriteRenderer spriteRenderer; + [SerializeField] protected SpriteRenderer spriteRenderer; [Tooltip("Make the sprite visible or invisible")] - public BooleanData _visible = new BooleanData(false); + [SerializeField] protected BooleanData _visible = new BooleanData(false); [Tooltip("Affect the visibility of child sprites")] - public bool affectChildren = true; + [SerializeField] protected bool affectChildren = true; public override void OnEnter() { diff --git a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs index 8bbb82d1..2682c0fe 100644 --- a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs @@ -21,23 +21,25 @@ namespace Fungus public class Draggable2D : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler { [Tooltip("Is object dragging enabled")] - public bool dragEnabled = true; + [SerializeField] protected bool dragEnabled = true; + + public bool DragEnabled { set { dragEnabled = value; } } [Tooltip("Move object back to its starting position when drag is cancelled")] [FormerlySerializedAs("returnToStartPos")] - public bool returnOnCancelled = true; + [SerializeField] protected bool returnOnCancelled = true; [Tooltip("Move object back to its starting position when drag is completed")] - public bool returnOnCompleted = true; + [SerializeField] protected bool returnOnCompleted = true; [Tooltip("Time object takes to return to its starting position")] - public float returnDuration = 1f; + [SerializeField] protected float returnDuration = 1f; [Tooltip("Mouse texture to use when hovering mouse over object")] - public Texture2D hoverCursor; + [SerializeField] protected Texture2D hoverCursor; [Tooltip("Use the UI Event System to check for drag events. Clicks that hit an overlapping UI object will be ignored. Camera must have a PhysicsRaycaster component, or a Physics2DRaycaster for 2D colliders.")] - public bool useEventSystem; + [SerializeField] protected bool useEventSystem; protected Vector3 startingPosition; protected bool updatePosition = false; @@ -225,7 +227,7 @@ namespace Fungus DragCompleted[] handlers = GetHandlers(); foreach (DragCompleted handler in handlers) { - if (handler.draggableObject == this) + if (handler.DraggableObject == this) { if (handler.IsOverTarget()) { diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs index 2ca36212..9cac6617 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs @@ -17,7 +17,7 @@ namespace Fungus public class DragCancelled : EventHandler { [Tooltip("Draggable object to listen for drag events on")] - public Draggable2D draggableObject; + [SerializeField] protected Draggable2D draggableObject; public virtual void OnDragCancelled(Draggable2D draggableObject) { diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs index e60991cf..29011142 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs @@ -17,10 +17,12 @@ namespace Fungus public class DragCompleted : EventHandler { [Tooltip("Draggable object to listen for drag events on")] - public Draggable2D draggableObject; + [SerializeField] protected Draggable2D draggableObject; + + public Draggable2D DraggableObject { get { return draggableObject; } } [Tooltip("Drag target object to listen for drag events on")] - public Collider2D targetObject; + [SerializeField] protected Collider2D targetObject; // There's no way to poll if an object is touching another object, so // we have to listen to the callbacks and track the touching state ourselves. diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs index 71d03fd9..ef15f252 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs @@ -18,10 +18,10 @@ namespace Fungus public class DragEntered : EventHandler { [Tooltip("Draggable object to listen for drag events on")] - public Draggable2D draggableObject; + [SerializeField] protected Draggable2D draggableObject; [Tooltip("Drag target object to listen for drag events on")] - public Collider2D targetObject; + [SerializeField] protected Collider2D targetObject; public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject) { diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs index e84f935a..aad6653d 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs @@ -18,10 +18,10 @@ namespace Fungus public class DragExited : EventHandler { [Tooltip("Draggable object to listen for drag events on")] - public Draggable2D draggableObject; + [SerializeField] protected Draggable2D draggableObject; [Tooltip("Drag target object to listen for drag events on")] - public Collider2D targetObject; + [SerializeField] protected Collider2D targetObject; public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject) { diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs index 4696c3c6..01f257c7 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs @@ -16,7 +16,7 @@ namespace Fungus [AddComponentMenu("")] public class DragStarted : EventHandler { - public Draggable2D draggableObject; + [SerializeField] protected Draggable2D draggableObject; public virtual void OnDragStarted(Draggable2D draggableObject) { diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs index ecfb07c8..0adf3e89 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs @@ -15,7 +15,7 @@ namespace Fungus public class ObjectClicked : EventHandler { [Tooltip("Object that the user can click or tap on")] - public Clickable2D clickableObject; + [SerializeField] protected Clickable2D clickableObject; public virtual void OnObjectClicked(Clickable2D clickableObject) { diff --git a/Assets/Fungus/Sprite/Scripts/Parallax.cs b/Assets/Fungus/Sprite/Scripts/Parallax.cs index 988f3a37..730c299b 100644 --- a/Assets/Fungus/Sprite/Scripts/Parallax.cs +++ b/Assets/Fungus/Sprite/Scripts/Parallax.cs @@ -20,18 +20,18 @@ namespace Fungus * The background sprite which this sprite is layered on top of. * The position of this sprite is used to calculate the parallax offset. */ - public SpriteRenderer backgroundSprite; + [SerializeField] protected SpriteRenderer backgroundSprite; /** * Scale factor for calculating the parallax offset. */ - public Vector2 parallaxScale = new Vector2(0.25f, 0f); + [SerializeField] protected Vector2 parallaxScale = new Vector2(0.25f, 0f); /** * Scale factor for calculating parallax offset based on device accelerometer tilt angle. * Set this to 0 to disable the accelerometer parallax effect. */ - public float accelerometerScale = 0.5f; + [SerializeField] protected float accelerometerScale = 0.5f; protected Vector3 startPosition; protected Vector3 acceleration; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaBindingsEditor.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaBindingsEditor.cs index 2734a569..c0ad1cac 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaBindingsEditor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaBindingsEditor.cs @@ -205,7 +205,7 @@ namespace Fungus details.Add(""); LuaBindings luaBindings = target as LuaBindings; - foreach (LuaBindings.BoundObject boundObject in luaBindings.boundObjects) + foreach (LuaBindings.BoundObject boundObject in luaBindings.BoundObjects) { UnityEngine.Object inspectObject = boundObject.obj; if (boundObject.component != null) @@ -367,14 +367,14 @@ namespace Fungus // Build a hash of all keys currently in use HashSet keyhash = new HashSet(); - for (int i = 0; i < luaBindings.boundObjects.Count; ++i) + for (int i = 0; i < luaBindings.BoundObjects.Count; ++i) { if (i == ignoreIndex) { continue; } - keyhash.Add(luaBindings.boundObjects[i].key); + keyhash.Add(luaBindings.BoundObjects[i].key); } // Append a suffix to make the key unique @@ -412,7 +412,7 @@ namespace Fungus // Use a temp HashSet to store the list of types. // The final list is stored as a list of type strings. HashSet typeSet = new HashSet(); - foreach (LuaBindings.BoundObject boundObject in luaBindings.boundObjects) + foreach (LuaBindings.BoundObject boundObject in luaBindings.BoundObjects) { if (boundObject.obj == null) { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs index 1bdc81e9..9f2c7032 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaScriptEditor.cs @@ -44,7 +44,7 @@ namespace Fungus { // Reinitialise if the Lua script is changed while running in editor LuaScript luaScript = target as LuaScript; - luaScript.initialised = false; + luaScript.Initialised = false; } EditorGUILayout.PropertyField(runAsCoroutineProp); diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaStoreEditor.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaStoreEditor.cs index 1d00226f..dea23354 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaStoreEditor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/LuaStoreEditor.cs @@ -21,10 +21,10 @@ namespace Fungus // Use the Serialization extension to display the contents of the prime table. LuaStore luaStore = target as LuaStore; - if (luaStore.primeTable != null) + if (luaStore.PrimeTable != null) { EditorGUILayout.PrefixLabel(new GUIContent("Inspect Table", "Displays the contents of the fungus.store prime table.")); - string serialized = luaStore.primeTable.Serialize(); + string serialized = luaStore.PrimeTable.Serialize(); EditorGUILayout.SelectableLabel(serialized, GUILayout.ExpandHeight(true)); } } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs index ba08e207..32b1d149 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/ExecuteHandler.cs @@ -63,7 +63,7 @@ namespace Fungus [SerializeField] public ExecuteMethod executeMethods = ExecuteMethod.Start; [Tooltip("Name of the method on a component in this gameobject to call when executing.")] - public string executeMethodName = "OnExecute"; + [SerializeField] protected string executeMethodName = "OnExecute"; private int m_ExecuteOnFrame; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/InfoText.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/InfoText.cs index 4278240b..c4478333 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/InfoText.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/InfoText.cs @@ -16,7 +16,7 @@ namespace Fungus { [Tooltip("The information text to display")] [TextArea(20, 20)] - public string info = ""; + [SerializeField] protected string info = ""; void OnGUI() { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaBindings.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaBindings.cs index 34b3bbe3..0740d208 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaBindings.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaBindings.cs @@ -45,31 +45,33 @@ namespace Fungus } [Tooltip("Add bindings to every Lua Environment in the scene. If false, only add bindings to a specific Lua Environment.")] - public bool allEnvironments = true; + [SerializeField] protected bool allEnvironments = true; [Tooltip("The specific LuaEnvironment to register the bindings in.")] - public LuaEnvironment luaEnvironment; + [SerializeField] protected LuaEnvironment luaEnvironment; /// /// Name of global table variable to store bindings in. If left blank then each binding will be added as a global variable. /// [Tooltip("Name of global table variable to store bindings in. If left blank then each binding will be added as a global variable.")] - public string tableName = ""; + [SerializeField] protected string tableName = ""; [Tooltip("Register all CLR types used by the bound objects so that they can be accessed from Lua. If you don't use this option you will need to register these types yourself.")] - public bool registerTypes = true; + [SerializeField] protected bool registerTypes = true; [HideInInspector] - public List boundTypes = new List(); + [SerializeField] protected List boundTypes = new List(); /// /// The list of Unity objects to be bound for access in Lua. /// [Tooltip("The list of Unity objects to be bound to make them accessible in Lua script.")] - public List boundObjects = new List(); + [SerializeField] protected List boundObjects = new List(); + + public List BoundObjects { get { return boundObjects; } } [Tooltip("Show inherited public members.")] - public bool showInherited; + [SerializeField] protected bool showInherited; /// /// Always ensure there is at least one row in the bound objects list. diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs index fde2fb40..5a8fb649 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaEnvironment.cs @@ -114,7 +114,7 @@ namespace Fungus /// Launches the remote Lua debugger in your browser and breaks execution at the first executed Lua command. /// [Tooltip("Launches the remote Lua debugger in your browser and breaks execution at the first executed Lua command. Standalone platform only.")] - public bool remoteDebugger = false; + [SerializeField] protected bool remoteDebugger = false; /// /// Instance of remote debugging service when debugging option is enabled. diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs index 1195026f..55c2ab65 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs @@ -25,32 +25,33 @@ namespace Fungus /// The Lua Environment to use when executing Lua script. /// [Tooltip("The Lua Environment to use when executing Lua script.")] - public LuaEnvironment luaEnvironment; + [SerializeField] protected LuaEnvironment luaEnvironment; /// /// Text file containing Lua script to be executed. /// [Tooltip("Text file containing Lua script to be executed.")] - public TextAsset luaFile; + [SerializeField] protected TextAsset luaFile; /// /// Lua script to execute. /// [Tooltip("A Lua string to execute, appended to the contents of Lua File (if one is specified).")] [TextArea(5, 50)] - public string luaScript = ""; + [SerializeField] protected string luaScript = ""; /// /// Run the script as a Lua coroutine so execution can be yielded for asynchronous operations. /// [Tooltip("Run the script as a Lua coroutine so execution can be yielded for asynchronous operations.")] - public bool runAsCoroutine = true; + [SerializeField] protected bool runAsCoroutine = true; protected string friendlyName = ""; + protected bool initialised; + // This is public so the editor code can force the component to reinitialise - [NonSerialized] - public bool initialised; + public bool Initialised { set { initialised = value; } } // Stores the compiled Lua code for fast execution later. protected Closure luaFunction; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaStore.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaStore.cs index 25d9e1d1..b41bf496 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaStore.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaStore.cs @@ -22,7 +22,9 @@ namespace Fungus /// /// A Lua table that can be shared between multiple LuaEnvironments. /// - public Table primeTable; + protected Table primeTable; + + public Table PrimeTable { get { return primeTable; } } protected bool initialized; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs index 3d19c8de..8ccbe4b9 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaUtils.cs @@ -33,27 +33,27 @@ namespace Fungus /// You can also choose to disable loading the fungus module if it's not required by your script. /// [Tooltip("Controls if the fungus utilities are accessed from globals (e.g. say) or via a fungus variable (e.g. fungus.say)")] - public FungusModuleOptions fungusModule = FungusModuleOptions.UseGlobalVariables; + [SerializeField] protected FungusModuleOptions fungusModule = FungusModuleOptions.UseGlobalVariables; /// /// The currently selected language in the string table. Affects variable substitution. /// [Tooltip("The currently selected language in the string table. Affects variable substitution.")] - public string activeLanguage = "en"; + [SerializeField] protected string activeLanguage = "en"; /// /// Lua script file which defines the global string table used for localisation. /// [HideInInspector] [Tooltip("List of JSON text files which contain localized strings. These strings are added to the 'stringTable' table in the Lua environment at startup.")] - public List stringTables = new List(); + [SerializeField] protected List stringTables = new List(); /// /// JSON text files listing the c# types that can be accessed from Lua. /// [HideInInspector] [Tooltip("JSON text files listing the c# types that can be accessed from Lua.")] - public List registerTypes = new List(); + [SerializeField] protected List registerTypes = new List(); /// /// Flag used to avoid startup dependency issues. diff --git a/Assets/Fungus/Thirdparty/FungusLua/Scripts/StringSubstituter.cs b/Assets/Fungus/Thirdparty/FungusLua/Scripts/StringSubstituter.cs index 50203741..7a50c2c4 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Scripts/StringSubstituter.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Scripts/StringSubstituter.cs @@ -36,7 +36,9 @@ namespace Fungus * The StringBuilder instance used to substitute strings optimally. * This property is public to support client code optimisations. */ - public StringBuilder stringBuilder; + protected StringBuilder stringBuilder; + + public StringBuilder _StringBuilder { get { return stringBuilder; } } private int recursionDepth; diff --git a/Assets/Fungus/UI/Scripts/Writer.cs b/Assets/Fungus/UI/Scripts/Writer.cs index 9de6b00e..c33cbe6d 100644 --- a/Assets/Fungus/UI/Scripts/Writer.cs +++ b/Assets/Fungus/UI/Scripts/Writer.cs @@ -828,9 +828,9 @@ namespace Fungus protected virtual void Flash(float duration) { CameraController cameraController = CameraController.GetInstance(); - cameraController.screenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); + cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); cameraController.Fade(1f, duration, delegate { - cameraController.screenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); + cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); cameraController.Fade(0f, duration, null); }); }