From 3510fc7f9a744316f2974c5de9cf1f9376ced980 Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 10 Oct 2016 13:10:21 +0100 Subject: [PATCH] Converted all foreach statement to act on simple variables. --- .../Fungus/Scripts/Commands/ControlAudio.cs | 4 +- .../Fungus/Scripts/Commands/ControlStage.cs | 6 +- Assets/Fungus/Scripts/Commands/FadeUI.cs | 93 ++++++++++--------- Assets/Fungus/Scripts/Commands/Jump.cs | 3 +- Assets/Fungus/Scripts/Commands/Say.cs | 3 +- Assets/Fungus/Scripts/Commands/SendMessage.cs | 2 +- Assets/Fungus/Scripts/Commands/SetCollider.cs | 10 +- .../Scripts/Commands/SetInteractable.cs | 7 +- .../Fungus/Scripts/Commands/SetLayerOrder.cs | 5 +- .../Fungus/Scripts/Commands/SetSpriteOrder.cs | 4 +- Assets/Fungus/Scripts/Commands/ShowSprite.cs | 4 +- Assets/Fungus/Scripts/Commands/TweenUI.cs | 4 +- .../Fungus/Scripts/Commands/iTweenCommand.cs | 5 +- .../Fungus/Scripts/Components/Clickable2D.cs | 4 +- .../Scripts/Components/CommandCopyBuffer.cs | 3 +- .../Fungus/Scripts/Components/DialogInput.cs | 4 +- .../Fungus/Scripts/Components/Draggable2D.cs | 22 +++-- Assets/Fungus/Scripts/Components/Flowchart.cs | 56 +++++------ .../Fungus/Scripts/Components/Localization.cs | 20 ++-- .../Fungus/Scripts/Components/MenuDialog.cs | 10 +- Assets/Fungus/Scripts/Components/SayDialog.cs | 9 +- .../Fungus/Scripts/Components/SpriteFader.cs | 8 +- Assets/Fungus/Scripts/Components/Writer.cs | 18 ++-- .../Scripts/Editor/EventHandlerEditor.cs | 2 +- .../Fungus/Scripts/Editor/FlowchartEditor.cs | 4 +- .../Fungus/Scripts/Editor/FlowchartWindow.cs | 25 +++-- Assets/Fungus/Scripts/Editor/LabelEditor.cs | 3 +- Assets/Fungus/Scripts/Editor/ViewEditor.cs | 3 +- Assets/Fungus/Scripts/Utils/TextTagParser.cs | 2 +- 29 files changed, 191 insertions(+), 152 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Scripts/Commands/ControlAudio.cs index 09677625..6df428bf 100644 --- a/Assets/Fungus/Scripts/Commands/ControlAudio.cs +++ b/Assets/Fungus/Scripts/Commands/ControlAudio.cs @@ -65,8 +65,8 @@ namespace Fungus return; } - AudioSource[] audioSources = GameObject.FindObjectsOfType(); - foreach (AudioSource a in audioSources) + var audioSources = GameObject.FindObjectsOfType(); + foreach (var a in audioSources) { if ((a.GetComponent() != _audioSource.Value) && (a.tag == _audioSource.Value.tag)) { diff --git a/Assets/Fungus/Scripts/Commands/ControlStage.cs b/Assets/Fungus/Scripts/Commands/ControlStage.cs index 877b79f8..4fb3b385 100644 --- a/Assets/Fungus/Scripts/Commands/ControlStage.cs +++ b/Assets/Fungus/Scripts/Commands/ControlStage.cs @@ -72,7 +72,8 @@ namespace Fungus protected virtual void MoveToFront(Stage stage) { - foreach (Stage s in Stage.ActiveStages) + var activeStages = Stage.ActiveStages; + foreach (var s in activeStages) { if (s == stage) { @@ -88,7 +89,8 @@ namespace Fungus protected virtual void UndimAllPortraits(Stage stage) { stage.DimPortraits = false; - foreach (Character character in stage.CharactersOnStage) + var charactersOnStage = stage.CharactersOnStage; + foreach (var character in charactersOnStage) { stage.SetDimmed(character, false); } diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs index 35fb781e..f02682db 100644 --- a/Assets/Fungus/Scripts/Commands/FadeUI.cs +++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs @@ -33,92 +33,95 @@ namespace Fungus protected override void ApplyTween(GameObject go) { - foreach (Image image in go.GetComponentsInChildren()) + var images = go.GetComponentsInChildren(); + foreach (var image in images) { if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { - case FadeMode.Alpha: - Color tempColor = image.color; - tempColor.a = targetAlpha; - image.color = tempColor; - break; - case FadeMode.Color: - image.color = targetColor; - break; + case FadeMode.Alpha: + Color tempColor = image.color; + tempColor.a = targetAlpha; + image.color = tempColor; + break; + case FadeMode.Color: + image.color = targetColor; + break; } } else { switch (fadeMode) { - case FadeMode.Alpha: - LeanTween.alpha(image.rectTransform, targetAlpha, duration).setEase(tweenType).setEase(tweenType); - break; - case FadeMode.Color: - LeanTween.color(image.rectTransform, targetColor, duration).setEase(tweenType).setEase(tweenType); - break; + case FadeMode.Alpha: + LeanTween.alpha(image.rectTransform, targetAlpha, duration).setEase(tweenType).setEase(tweenType); + break; + case FadeMode.Color: + LeanTween.color(image.rectTransform, targetColor, duration).setEase(tweenType).setEase(tweenType); + break; } } } - foreach (Text text in go.GetComponentsInChildren()) + var texts = go.GetComponentsInChildren(); + foreach (var text in texts) { if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { - case FadeMode.Alpha: - Color tempColor = text.color; - tempColor.a = targetAlpha; - text.color = tempColor; - break; - case FadeMode.Color: - text.color = targetColor; - break; + case FadeMode.Alpha: + Color tempColor = text.color; + tempColor.a = targetAlpha; + text.color = tempColor; + break; + case FadeMode.Color: + text.color = targetColor; + break; } } else { switch (fadeMode) { - case FadeMode.Alpha: - LeanTween.textAlpha(text.rectTransform, targetAlpha, duration).setEase(tweenType); - break; - case FadeMode.Color: - LeanTween.textColor(text.rectTransform, targetColor, duration).setEase(tweenType); - break; + case FadeMode.Alpha: + LeanTween.textAlpha(text.rectTransform, targetAlpha, duration).setEase(tweenType); + break; + case FadeMode.Color: + LeanTween.textColor(text.rectTransform, targetColor, duration).setEase(tweenType); + break; } } } - foreach (TextMesh textMesh in go.GetComponentsInChildren()) + var textMeshes = go.GetComponentsInChildren(); + foreach (var textMesh in textMeshes) { if (Mathf.Approximately(duration, 0f)) { switch (fadeMode) { - case FadeMode.Alpha: - Color tempColor = textMesh.color; - tempColor.a = targetAlpha; - textMesh.color = tempColor; - break; - case FadeMode.Color: - textMesh.color = targetColor; - break; + case FadeMode.Alpha: + Color tempColor = textMesh.color; + tempColor.a = targetAlpha; + textMesh.color = tempColor; + break; + case FadeMode.Color: + textMesh.color = targetColor; + break; } } else { switch (fadeMode) { - case FadeMode.Alpha: - LeanTween.alpha(go, targetAlpha, duration).setEase(tweenType); - break; - case FadeMode.Color: - LeanTween.color(go, targetColor, duration).setEase(tweenType); - break; + case FadeMode.Alpha: + LeanTween.alpha(go, targetAlpha, duration).setEase(tweenType); + break; + case FadeMode.Color: + LeanTween.color(go, targetColor, duration).setEase(tweenType); + break; } } } diff --git a/Assets/Fungus/Scripts/Commands/Jump.cs b/Assets/Fungus/Scripts/Commands/Jump.cs index 26849578..dc20214d 100644 --- a/Assets/Fungus/Scripts/Commands/Jump.cs +++ b/Assets/Fungus/Scripts/Commands/Jump.cs @@ -29,7 +29,8 @@ namespace Fungus return; } - foreach (var command in ParentBlock.CommandList) + var commandList = ParentBlock.CommandList; + foreach (var command in commandList) { Label label = command as Label; if (label != null && diff --git a/Assets/Fungus/Scripts/Commands/Say.cs b/Assets/Fungus/Scripts/Commands/Say.cs index aae38e81..6672a365 100644 --- a/Assets/Fungus/Scripts/Commands/Say.cs +++ b/Assets/Fungus/Scripts/Commands/Say.cs @@ -107,7 +107,8 @@ namespace Fungus string displayText = storyText; - foreach (CustomTag ct in CustomTag.activeCustomTags) + var activeCustomTags = CustomTag.activeCustomTags; + foreach (var ct in activeCustomTags) { displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith); if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "") diff --git a/Assets/Fungus/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Scripts/Commands/SendMessage.cs index a9499ed4..336f0c7f 100644 --- a/Assets/Fungus/Scripts/Commands/SendMessage.cs +++ b/Assets/Fungus/Scripts/Commands/SendMessage.cs @@ -59,7 +59,7 @@ namespace Fungus if (receivers != null) { - foreach (MessageReceived receiver in receivers) + foreach (var receiver in receivers) { receiver.OnSendFungusMessage(_message.Value); } diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs index 2d8ea4a1..6d7176a7 100644 --- a/Assets/Fungus/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs @@ -29,13 +29,15 @@ namespace Fungus if (go != null) { // 3D objects - foreach (Collider c in go.GetComponentsInChildren()) + var colliders = go.GetComponentsInChildren(); + foreach (var c in colliders) { c.enabled = activeState.Value; } // 2D objects - foreach (Collider2D c in go.GetComponentsInChildren()) + var collider2Ds = go.GetComponentsInChildren(); + foreach (var c in collider2Ds) { c.enabled = activeState.Value; } @@ -46,7 +48,7 @@ namespace Fungus public override void OnEnter() { - foreach (GameObject go in targetObjects) + foreach (var go in targetObjects) { SetColliderActive(go); } @@ -63,7 +65,7 @@ namespace Fungus if (taggedObjects != null) { - foreach (GameObject go in taggedObjects) + foreach (var go in taggedObjects) { SetColliderActive(go); } diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs index 07f54537..ef06ca9f 100644 --- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs +++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs @@ -31,9 +31,10 @@ namespace Fungus return; } - foreach (GameObject targetObject in targetObjects) + foreach (var targetObject in targetObjects) { - foreach (Selectable selectable in targetObject.GetComponents()) + var selectables = targetObject.GetComponents(); + foreach (var selectable in selectables) { selectable.interactable = interactableState.Value; } @@ -58,7 +59,7 @@ namespace Fungus } string objectList = ""; - foreach (GameObject gameObject in targetObjects) + foreach (var gameObject in targetObjects) { if (gameObject == null) { diff --git a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs index 112d37c7..4eb82244 100644 --- a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs @@ -22,14 +22,15 @@ namespace Fungus protected void ApplySortingLayer(Transform target, string layerName) { - Renderer renderer = target.gameObject.GetComponent(); + var renderer = target.gameObject.GetComponent(); if (renderer) { renderer.sortingLayerName = layerName; Debug.Log(target.name); } - foreach (Transform child in target.transform) + var targetTransform = target.transform; + foreach (Transform child in targetTransform) { ApplySortingLayer(child, layerName); } diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs index 96c8300e..08bc9798 100644 --- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs @@ -25,7 +25,7 @@ namespace Fungus public override void OnEnter() { - foreach (SpriteRenderer spriteRenderer in targetSprites) + foreach (var spriteRenderer in targetSprites) { spriteRenderer.sortingOrder = orderInLayer; } @@ -36,7 +36,7 @@ namespace Fungus public override string GetSummary() { string summary = ""; - foreach (SpriteRenderer spriteRenderer in targetSprites) + foreach (var spriteRenderer in targetSprites) { if (spriteRenderer == null) { diff --git a/Assets/Fungus/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Scripts/Commands/ShowSprite.cs index ed5bc62e..1ce8fbde 100644 --- a/Assets/Fungus/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Scripts/Commands/ShowSprite.cs @@ -40,8 +40,8 @@ namespace Fungus { if (affectChildren) { - SpriteRenderer[] children = spriteRenderer.gameObject.GetComponentsInChildren(); - foreach (SpriteRenderer sr in children) + var spriteRenderers = spriteRenderer.gameObject.GetComponentsInChildren(); + foreach (var sr in spriteRenderers) { SetSpriteAlpha(sr, _visible.Value); } diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs index 8803d455..e65d32be 100644 --- a/Assets/Fungus/Scripts/Commands/TweenUI.cs +++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs @@ -26,7 +26,7 @@ namespace Fungus protected virtual void ApplyTween() { - foreach (GameObject targetObject in targetObjects) + foreach (var targetObject in targetObjects) { if (targetObject == null) { @@ -97,7 +97,7 @@ namespace Fungus } string objectList = ""; - foreach (GameObject gameObject in targetObjects) + foreach (var gameObject in targetObjects) { if (gameObject == null) { diff --git a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs index f5b12832..ceb96904 100644 --- a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs +++ b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs @@ -73,8 +73,9 @@ namespace Fungus if (stopPreviousTweens) { // Force any existing iTweens on this target object to complete immediately - iTween[] tweens = _targetObject.Value.GetComponents(); - foreach (iTween tween in tweens) { + var tweens = _targetObject.Value.GetComponents(); + foreach (var tween in tweens) + { tween.time = 0; tween.SendMessage("Update"); } diff --git a/Assets/Fungus/Scripts/Components/Clickable2D.cs b/Assets/Fungus/Scripts/Components/Clickable2D.cs index 854836e2..06f04a74 100644 --- a/Assets/Fungus/Scripts/Components/Clickable2D.cs +++ b/Assets/Fungus/Scripts/Components/Clickable2D.cs @@ -40,8 +40,8 @@ namespace Fungus } // TODO: Cache these objects for faster lookup - ObjectClicked[] handlers = GameObject.FindObjectsOfType(); - foreach (ObjectClicked handler in handlers) + var handlers = GameObject.FindObjectsOfType(); + foreach (var handler in handlers) { handler.OnObjectClicked(this); } diff --git a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs index 7019a874..ad68d6f2 100644 --- a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs +++ b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs @@ -62,7 +62,8 @@ namespace Fungus public virtual void Clear() { - foreach (Command command in GetCommands()) + var commands = GetCommands(); + foreach (var command in commands) { DestroyImmediate(command); } diff --git a/Assets/Fungus/Scripts/Components/DialogInput.cs b/Assets/Fungus/Scripts/Components/DialogInput.cs index 063aebb8..54b7232a 100644 --- a/Assets/Fungus/Scripts/Components/DialogInput.cs +++ b/Assets/Fungus/Scripts/Components/DialogInput.cs @@ -114,8 +114,8 @@ namespace Fungus // Tell any listeners to move to the next line if (nextLineInputFlag) { - IDialogInputListener[] inputListeners = gameObject.GetComponentsInChildren(); - foreach (IDialogInputListener inputListener in inputListeners) + var inputListeners = gameObject.GetComponentsInChildren(); + foreach (var inputListener in inputListeners) { inputListener.OnNextLineEvent(); } diff --git a/Assets/Fungus/Scripts/Components/Draggable2D.cs b/Assets/Fungus/Scripts/Components/Draggable2D.cs index aff5bf3b..20464ed4 100644 --- a/Assets/Fungus/Scripts/Components/Draggable2D.cs +++ b/Assets/Fungus/Scripts/Components/Draggable2D.cs @@ -58,12 +58,14 @@ namespace Fungus return; } - foreach (DragEntered handler in GetHandlers()) + var dragEnteredHandlers = GetHandlers(); + foreach (var handler in dragEnteredHandlers) { handler.OnDragEntered(this, other); } - foreach (DragCompleted handler in GetHandlers()) + var dragCompletedHandlers = GetHandlers(); + foreach (var handler in dragCompletedHandlers) { handler.OnDragEntered(this, other); } @@ -76,12 +78,14 @@ namespace Fungus return; } - foreach (DragExited handler in GetHandlers()) + var dragExitedHandlers = GetHandlers(); + foreach (var handler in dragExitedHandlers) { handler.OnDragExited(this, other); } - foreach (DragCompleted handler in GetHandlers()) + var dragCompletedHandlers = GetHandlers(); + foreach (var handler in dragCompletedHandlers) { handler.OnDragExited(this, other); } @@ -103,7 +107,8 @@ namespace Fungus startingPosition = transform.position; - foreach (DragStarted handler in GetHandlers()) + var dragStartedHandlers = GetHandlers(); + foreach (var handler in dragStartedHandlers) { handler.OnDragStarted(this); } @@ -134,8 +139,8 @@ namespace Fungus bool dragCompleted = false; - DragCompleted[] handlers = GetHandlers(); - foreach (DragCompleted handler in handlers) + var handlers = GetHandlers(); + foreach (var handler in handlers) { if (handler.DraggableObject == this) { @@ -154,7 +159,8 @@ namespace Fungus if (!dragCompleted) { - foreach (DragCancelled handler in GetHandlers()) + var dragCancelledHandlers = GetHandlers(); + foreach (var handler in dragCancelledHandlers) { handler.OnDragCancelled(this); } diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs index 8c51eb4b..da096357 100644 --- a/Assets/Fungus/Scripts/Components/Flowchart.cs +++ b/Assets/Fungus/Scripts/Components/Flowchart.cs @@ -158,7 +158,8 @@ namespace Fungus } // Tell all components that implement IUpdateable to update to the new version - foreach (Component component in GetComponents()) + var components = GetComponents(); + foreach (var component in components) { IUpdateable u = component as IUpdateable; if (u != null) @@ -213,7 +214,8 @@ namespace Fungus // It shouldn't happen but it seemed to occur for a user on the forum variables.RemoveAll(item => item == null); - foreach (Variable variable in GetComponents()) + var allVariables = GetComponents(); + foreach (var variable in allVariables) { if (!variables.Contains(variable)) { @@ -222,8 +224,8 @@ namespace Fungus } var blocks = GetComponents(); - - foreach (var command in GetComponents()) + var commands = GetComponents(); + foreach (var command in commands) { bool found = false; foreach (var block in blocks) @@ -241,7 +243,8 @@ namespace Fungus } } - foreach (EventHandler eventHandler in GetComponents()) + var eventHandlers = GetComponents(); + foreach (var eventHandler in eventHandlers) { bool found = false; foreach (var block in blocks) @@ -279,8 +282,8 @@ namespace Fungus /// public static void BroadcastFungusMessage(string messageName) { - MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType(); - foreach (MessageReceived eventHandler in eventHandlers) + var eventHandlers = UnityEngine.Object.FindObjectsOfType(); + foreach (var eventHandler in eventHandlers) { eventHandler.OnSendFungusMessage(messageName); } @@ -506,7 +509,7 @@ namespace Fungus public virtual void StopAllBlocks() { var blocks = GetComponents(); - foreach (Block block in blocks) + foreach (var block in blocks) { if (block.IsExecuting()) { @@ -521,8 +524,8 @@ namespace Fungus /// public virtual void SendFungusMessage(string messageName) { - MessageReceived[] eventHandlers = GetComponents(); - foreach (MessageReceived eventHandler in eventHandlers) + var eventHandlers = GetComponents(); + foreach (var eventHandler in eventHandlers) { eventHandler.OnSendFungusMessage(messageName); } @@ -553,7 +556,7 @@ namespace Fungus while (true) { bool collision = false; - foreach(Variable variable in variables) + foreach(var variable in variables) { if (variable == null || variable == ignoreVariable || @@ -640,7 +643,8 @@ namespace Fungus while (true) { bool collision = false; - foreach (var command in block.CommandList) + var commandList = block.CommandList; + foreach (var command in commandList) { Label label = command as Label; if (label == null || @@ -673,7 +677,7 @@ namespace Fungus /// public Variable GetVariable(string key) { - foreach (Variable variable in variables) + foreach (var variable in variables) { if (variable != null && variable.Key == key) { @@ -692,7 +696,7 @@ namespace Fungus /// public T GetVariable(string key) where T : Variable { - foreach (Variable variable in variables) + foreach (var variable in variables) { if (variable != null && variable.Key == key) { @@ -710,7 +714,7 @@ namespace Fungus /// public void SetVariable(string key, T newvariable) where T : Variable { - foreach (Variable v in variables) + foreach (var v in variables) { if (v != null && v.Key == key) { @@ -732,7 +736,7 @@ namespace Fungus public virtual List GetPublicVariables() { List publicVariables = new List(); - foreach (Variable v in variables) + foreach (var v in variables) { if (v != null && v.Scope == VariableScope.Public) { @@ -874,8 +878,8 @@ namespace Fungus { if (hideComponents) { - Block[] blocks = GetComponents(); - foreach (Block block in blocks) + var blocks = GetComponents(); + foreach (var block in blocks) { block.hideFlags = HideFlags.HideInInspector; if (block.gameObject != gameObject) @@ -884,13 +888,13 @@ namespace Fungus } } - Command[] commands = GetComponents(); + var commands = GetComponents(); foreach (var command in commands) { command.hideFlags = HideFlags.HideInInspector; } - EventHandler[] eventHandlers = GetComponents(); + var eventHandlers = GetComponents(); foreach (var eventHandler in eventHandlers) { eventHandler.hideFlags = HideFlags.HideInInspector; @@ -898,8 +902,8 @@ namespace Fungus } else { - MonoBehaviour[] monoBehaviours = GetComponents(); - foreach (MonoBehaviour monoBehaviour in monoBehaviours) + var monoBehaviours = GetComponents(); + foreach (var monoBehaviour in monoBehaviours) { if (monoBehaviour == null) { @@ -947,7 +951,7 @@ namespace Fungus if (resetVariables) { - foreach (Variable variable in variables) + foreach (var variable in variables) { variable.OnReset(); } @@ -959,7 +963,7 @@ namespace Fungus /// public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) { - foreach (string key in hideCommands) + foreach (var key in hideCommands) { // Match on category or command name (case insensitive) if (String.Compare(commandInfo.Category, key, StringComparison.OrdinalIgnoreCase) == 0 || @@ -1037,7 +1041,7 @@ namespace Fungus string key = match.Value.Substring(2, match.Value.Length - 3); // Look for any matching private variables in this Flowchart first - foreach (Variable variable in variables) + foreach (var variable in variables) { if (variable == null) continue; @@ -1089,7 +1093,7 @@ namespace Fungus string key = match.Value.Substring(2, match.Value.Length - 3); // Look for any matching public variables in this Flowchart - foreach (Variable variable in variables) + foreach (var variable in variables) { if (variable == null) continue; diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs index b437fe20..daad4ad6 100644 --- a/Assets/Fungus/Scripts/Components/Localization.cs +++ b/Assets/Fungus/Scripts/Components/Localization.cs @@ -96,7 +96,7 @@ namespace Fungus protected virtual void CacheLocalizeableObjects() { UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component)); - foreach (UnityEngine.Object o in objects) + foreach (var o in objects) { ILocalizable localizable = o as ILocalizable; if (localizable != null) @@ -121,7 +121,8 @@ namespace Fungus var blocks = flowchart.GetComponents(); foreach (var block in blocks) { - foreach (var command in block.CommandList) + var commandList = block.CommandList; + foreach (var command in commandList) { ILocalizable localizable = command as ILocalizable; if (localizable != null) @@ -137,7 +138,7 @@ namespace Fungus // Add everything else that's localizable (including inactive objects) UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component)); - foreach (UnityEngine.Object o in objects) + foreach (var o in objects) { ILocalizable localizable = o as ILocalizable; if (localizable != null) @@ -289,7 +290,8 @@ namespace Fungus // Build CSV header row and a list of the language codes currently in use string csvHeader = "Key,Description,Standard"; List languageCodes = new List(); - foreach (TextItem textItem in textItems.Values) + var values = textItems.Values; + foreach (var textItem in values) { foreach (string languageCode in textItem.localizedStrings.Keys) { @@ -304,7 +306,8 @@ namespace Fungus // Build the CSV file using collected text items int rowCount = 0; string csvData = csvHeader + "\n"; - foreach (string stringId in textItems.Keys) + var keys = textItems.Keys; + foreach (var stringId in keys) { TextItem textItem = textItems[stringId]; @@ -312,7 +315,7 @@ namespace Fungus row += "," + CSVSupport.Escape(textItem.description); row += "," + CSVSupport.Escape(textItem.standardText); - foreach (string languageCode in languageCodes) + foreach (var languageCode in languageCodes) { if (textItem.localizedStrings.ContainsKey(languageCode)) { @@ -462,7 +465,8 @@ namespace Fungus string textData = ""; int rowCount = 0; - foreach (string stringId in textItems.Keys) + var keys = textItems.Keys; + foreach (var stringId in keys) { TextItem languageItem = textItems[stringId]; @@ -487,7 +491,7 @@ namespace Fungus string stringId = ""; string buffer = ""; - foreach (string line in lines) + foreach (var line in lines) { // Check for string id line if (line.StartsWith("#")) diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs index 844868c7..4c1cac2e 100644 --- a/Assets/Fungus/Scripts/Components/MenuDialog.cs +++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs @@ -155,12 +155,12 @@ namespace Fungus StopAllCoroutines(); Button[] optionButtons = GetComponentsInChildren