From f0213e083530b5b2d0e38877e145c1477423e1d5 Mon Sep 17 00:00:00 2001 From: desktop-maesty/steve Date: Tue, 15 Jan 2019 20:20:49 +1000 Subject: [PATCH] HasReference added to many commands that lacked them or had only partially checked vars --- Assets/Fungus/Scripts/Commands/Call.cs | 5 + .../Fungus/Scripts/Commands/ControlAudio.cs | 5 + .../Fungus/Scripts/Commands/Conversation.cs | 7 + Assets/Fungus/Scripts/Commands/DebugLog.cs | 5 + Assets/Fungus/Scripts/Commands/ExecuteLua.cs | 5 + Assets/Fungus/Scripts/Commands/FadeSprite.cs | 6 + Assets/Fungus/Scripts/Commands/FadeUI.cs | 6 + Assets/Fungus/Scripts/Commands/GetText.cs | 6 + .../Fungus/Scripts/Commands/GetToggleState.cs | 6 + Assets/Fungus/Scripts/Commands/InvokeEvent.cs | 7 + Assets/Fungus/Scripts/Commands/Jump.cs | 6 + .../LeanTween/BaseLeanTweenCommand.cs | 5 + .../Scripts/Commands/LeanTween/MoveLean.cs | 6 +- .../Scripts/Commands/LeanTween/RotateLean.cs | 5 + .../Scripts/Commands/LeanTween/ScaleLean.cs | 5 + .../Commands/LeanTween/StopTweensLean.cs | 5 + Assets/Fungus/Scripts/Commands/LoadScene.cs | 6 + .../Fungus/Scripts/Commands/LoadVariable.cs | 6 + Assets/Fungus/Scripts/Commands/LookFrom.cs | 6 + Assets/Fungus/Scripts/Commands/LookTo.cs | 6 + Assets/Fungus/Scripts/Commands/Menu.cs | 6 + Assets/Fungus/Scripts/Commands/MenuTimer.cs | 6 + Assets/Fungus/Scripts/Commands/MoveAdd.cs | 6 + Assets/Fungus/Scripts/Commands/MoveFrom.cs | 6 + Assets/Fungus/Scripts/Commands/MoveTo.cs | 6 + Assets/Fungus/Scripts/Commands/OpenURL.cs | 5 + .../Fungus/Scripts/Commands/PlayAnimState.cs | 7 + .../Fungus/Scripts/Commands/PlayUsfxrSound.cs | 5 + .../Commands/Priority/FungusPriorityCount.cs | 5 + .../Fungus/Scripts/Commands/PunchPosition.cs | 5 + .../Fungus/Scripts/Commands/PunchRotation.cs | 5 + Assets/Fungus/Scripts/Commands/PunchScale.cs | 5 + Assets/Fungus/Scripts/Commands/RandomFloat.cs | 2 +- .../Fungus/Scripts/Commands/RandomInteger.cs | 2 +- .../Scripts/Commands/ResetAnimTrigger.cs | 6 + Assets/Fungus/Scripts/Commands/RotateAdd.cs | 6 + Assets/Fungus/Scripts/Commands/RotateFrom.cs | 6 + Assets/Fungus/Scripts/Commands/RotateTo.cs | 6 + .../Fungus/Scripts/Commands/SaveVariable.cs | 5 + Assets/Fungus/Scripts/Commands/ScaleAdd.cs | 6 + Assets/Fungus/Scripts/Commands/ScaleFrom.cs | 6 + Assets/Fungus/Scripts/Commands/ScaleTo.cs | 6 + Assets/Fungus/Scripts/Commands/SendMessage.cs | 5 + Assets/Fungus/Scripts/Commands/SetActive.cs | 6 + Assets/Fungus/Scripts/Commands/SetAnimBool.cs | 6 + .../Fungus/Scripts/Commands/SetAnimFloat.cs | 6 + .../Fungus/Scripts/Commands/SetAnimInteger.cs | 6 + .../Fungus/Scripts/Commands/SetAnimTrigger.cs | 5 + .../Fungus/Scripts/Commands/SetClickable2D.cs | 7 +- Assets/Fungus/Scripts/Commands/SetCollider.cs | 5 + .../Fungus/Scripts/Commands/SetDraggable2D.cs | 5 + .../Scripts/Commands/SetInteractable.cs | 5 + Assets/Fungus/Scripts/Commands/SetLanguage.cs | 5 + .../Fungus/Scripts/Commands/SetSliderValue.cs | 5 + .../Fungus/Scripts/Commands/SetSpriteOrder.cs | 5 + Assets/Fungus/Scripts/Commands/SetText.cs | 5 + .../Fungus/Scripts/Commands/SetToggleState.cs | 5 + Assets/Fungus/Scripts/Commands/SetVariable.cs | 141 ++++++++++++++---- .../Fungus/Scripts/Commands/ShakePosition.cs | 5 + .../Fungus/Scripts/Commands/ShakeRotation.cs | 5 + Assets/Fungus/Scripts/Commands/ShakeScale.cs | 5 + Assets/Fungus/Scripts/Commands/ShowSprite.cs | 5 + Assets/Fungus/Scripts/Commands/StopBlock.cs | 5 + Assets/Fungus/Scripts/Commands/StopTween.cs | 5 + Assets/Fungus/Scripts/Commands/TweenUI.cs | 5 + .../Scripts/Commands/VariableCondition.cs | 140 +++++++++++++---- Assets/Fungus/Scripts/Commands/Wait.cs | 5 + Assets/Fungus/Scripts/Commands/WaitFrames.cs | 5 + Assets/Fungus/Scripts/Commands/Write.cs | 5 + .../Fungus/Scripts/Commands/iTweenCommand.cs | 6 + 70 files changed, 580 insertions(+), 70 deletions(-) diff --git a/Assets/Fungus/Scripts/Commands/Call.cs b/Assets/Fungus/Scripts/Commands/Call.cs index 93246a1d..d7076715 100644 --- a/Assets/Fungus/Scripts/Commands/Call.cs +++ b/Assets/Fungus/Scripts/Commands/Call.cs @@ -161,6 +161,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return startLabel.stringRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Scripts/Commands/ControlAudio.cs index 8a5ad5fe..d4100ead 100644 --- a/Assets/Fungus/Scripts/Commands/ControlAudio.cs +++ b/Assets/Fungus/Scripts/Commands/ControlAudio.cs @@ -284,6 +284,11 @@ namespace Fungus return new Color32(242, 209, 176, 255); } + public override bool HasReference(Variable variable) + { + return _audioSource.audioSourceRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/Conversation.cs b/Assets/Fungus/Scripts/Commands/Conversation.cs index 34410fba..e7cdbd0c 100644 --- a/Assets/Fungus/Scripts/Commands/Conversation.cs +++ b/Assets/Fungus/Scripts/Commands/Conversation.cs @@ -63,6 +63,13 @@ namespace Fungus return new Color32(184, 210, 235, 255); } + public override bool HasReference(Variable variable) + { + return clearPrevious.booleanRef == variable || waitForInput.booleanRef == variable || + waitForSeconds.floatRef == variable || fadeWhenDone.booleanRef == variable || + base.HasReference(variable); + } + #endregion diff --git a/Assets/Fungus/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Scripts/Commands/DebugLog.cs index 35285992..6c39772b 100644 --- a/Assets/Fungus/Scripts/Commands/DebugLog.cs +++ b/Assets/Fungus/Scripts/Commands/DebugLog.cs @@ -66,6 +66,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return logMessage.stringRef == variable || base.HasReference(variable); + } + #endregion #region Editor caches diff --git a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs index 501c45c4..cf538c75 100644 --- a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs +++ b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs @@ -203,6 +203,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return returnVariable == variable || base.HasReference(variable); + } + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Scripts/Commands/FadeSprite.cs index 0d41b643..af68b7b5 100644 --- a/Assets/Fungus/Scripts/Commands/FadeSprite.cs +++ b/Assets/Fungus/Scripts/Commands/FadeSprite.cs @@ -66,6 +66,12 @@ namespace Fungus return new Color32(221, 184, 169, 255); } + public override bool HasReference(Variable variable) + { + return _duration.floatRef == variable || _targetColor.colorRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs index d344c79d..7263e9df 100644 --- a/Assets/Fungus/Scripts/Commands/FadeUI.cs +++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs @@ -163,6 +163,12 @@ namespace Fungus return true; } + public override bool HasReference(Variable variable) + { + return targetColor.colorRef == variable || targetAlpha.floatRef == variable || + base.HasReference(variable); + } + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/GetText.cs b/Assets/Fungus/Scripts/Commands/GetText.cs index adc01e7d..b9c2b057 100644 --- a/Assets/Fungus/Scripts/Commands/GetText.cs +++ b/Assets/Fungus/Scripts/Commands/GetText.cs @@ -82,6 +82,12 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return stringVariable == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/GetToggleState.cs b/Assets/Fungus/Scripts/Commands/GetToggleState.cs index 5dfe9972..17ad1242 100644 --- a/Assets/Fungus/Scripts/Commands/GetToggleState.cs +++ b/Assets/Fungus/Scripts/Commands/GetToggleState.cs @@ -54,6 +54,12 @@ namespace Fungus return toggle.name; } + public override bool HasReference(Variable variable) + { + return toggleState == variable || + base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs index 55c3e402..6cdc5bee 100644 --- a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs +++ b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs @@ -153,6 +153,13 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return booleanParameter.booleanRef == variable || integerParameter.integerRef == variable || + floatParameter.floatRef == variable || stringParameter.stringRef == variable || + base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Jump.cs b/Assets/Fungus/Scripts/Commands/Jump.cs index ebaa4b4d..340841ce 100644 --- a/Assets/Fungus/Scripts/Commands/Jump.cs +++ b/Assets/Fungus/Scripts/Commands/Jump.cs @@ -61,6 +61,12 @@ namespace Fungus return new Color32(253, 253, 150, 255); } + public override bool HasReference(Variable variable) + { + return _targetLabel.stringRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs index e617d284..9607eb0f 100644 --- a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs +++ b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs @@ -110,6 +110,11 @@ namespace Fungus return new Color32(233, 163, 180, 255); } + public override bool HasReference(Variable variable) + { + return variable == _targetObject.gameObjectRef || variable == _duration.floatRef; + } + #endregion } diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs index 319bb21a..1ab79b07 100644 --- a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs +++ b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs @@ -50,6 +50,10 @@ namespace Fungus else return LeanTween.move(_targetObject.Value, loc, _duration); } - + + public override bool HasReference(Variable variable) + { + return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable || base.HasReference(variable); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs index eaa26761..ed8c7975 100644 --- a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs +++ b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs @@ -70,5 +70,10 @@ namespace Fungus else return LeanTween.rotate(_targetObject.Value, rot, _duration); } + + public override bool HasReference(Variable variable) + { + return variable == _toTransform.transformRef || _toRotation.vector3Ref == variable || base.HasReference(variable); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs index cc26391f..603869e7 100644 --- a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs +++ b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs @@ -42,5 +42,10 @@ namespace Fungus return LeanTween.scale(_targetObject.Value, sc, _duration); } + + public override bool HasReference(Variable variable) + { + return variable == _toTransform.transformRef || _toScale.vector3Ref == variable || base.HasReference(variable); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs index 19bf64d7..24957c7d 100644 --- a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs +++ b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs @@ -43,5 +43,10 @@ namespace Fungus { return new Color32(233, 163, 180, 255); } + + public override bool HasReference(Variable variable) + { + return _targetObject.gameObjectRef == variable; + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Scripts/Commands/LoadScene.cs index 36208348..e99660b5 100644 --- a/Assets/Fungus/Scripts/Commands/LoadScene.cs +++ b/Assets/Fungus/Scripts/Commands/LoadScene.cs @@ -50,6 +50,12 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return _sceneName.stringRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs index 5c074ea3..8e4f45ea 100644 --- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs +++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs @@ -99,6 +99,12 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable in_variable) + { + return this.variable == in_variable || + base.HasReference(in_variable); + } + #endregion #region Editor caches #if UNITY_EDITOR diff --git a/Assets/Fungus/Scripts/Commands/LookFrom.cs b/Assets/Fungus/Scripts/Commands/LookFrom.cs index d3af3c15..875f7d35 100644 --- a/Assets/Fungus/Scripts/Commands/LookFrom.cs +++ b/Assets/Fungus/Scripts/Commands/LookFrom.cs @@ -61,6 +61,12 @@ namespace Fungus iTween.LookFrom(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _fromTransform.transformRef == variable || _fromPosition.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/LookTo.cs b/Assets/Fungus/Scripts/Commands/LookTo.cs index c785bcce..f5a7ca59 100644 --- a/Assets/Fungus/Scripts/Commands/LookTo.cs +++ b/Assets/Fungus/Scripts/Commands/LookTo.cs @@ -61,6 +61,12 @@ namespace Fungus iTween.LookTo(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs index 6babd89c..2af4c1fd 100644 --- a/Assets/Fungus/Scripts/Commands/Menu.cs +++ b/Assets/Fungus/Scripts/Commands/Menu.cs @@ -95,6 +95,12 @@ namespace Fungus return new Color32(184, 210, 235, 255); } + public override bool HasReference(Variable variable) + { + return interactable.booleanRef == variable || hideThisOption.booleanRef == variable || + base.HasReference(variable); + } + #endregion #region ILocalizable implementation diff --git a/Assets/Fungus/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Scripts/Commands/MenuTimer.cs index bec4cffb..cb012224 100644 --- a/Assets/Fungus/Scripts/Commands/MenuTimer.cs +++ b/Assets/Fungus/Scripts/Commands/MenuTimer.cs @@ -62,6 +62,12 @@ namespace Fungus return new Color32(184, 210, 235, 255); } + public override bool HasReference(Variable variable) + { + return _duration.floatRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/Scripts/Commands/MoveAdd.cs index 0d518740..0d7f2352 100644 --- a/Assets/Fungus/Scripts/Commands/MoveAdd.cs +++ b/Assets/Fungus/Scripts/Commands/MoveAdd.cs @@ -40,6 +40,12 @@ namespace Fungus iTween.MoveAdd(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _offset.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/Scripts/Commands/MoveFrom.cs index 8cc0613b..f6912477 100644 --- a/Assets/Fungus/Scripts/Commands/MoveFrom.cs +++ b/Assets/Fungus/Scripts/Commands/MoveFrom.cs @@ -50,6 +50,12 @@ namespace Fungus iTween.MoveFrom(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _fromTransform.transformRef == variable || _fromPosition.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/MoveTo.cs b/Assets/Fungus/Scripts/Commands/MoveTo.cs index aac0e7bc..33ba70cc 100644 --- a/Assets/Fungus/Scripts/Commands/MoveTo.cs +++ b/Assets/Fungus/Scripts/Commands/MoveTo.cs @@ -50,6 +50,12 @@ namespace Fungus iTween.MoveTo(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _toTransform.transformRef == variable || _toPosition.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Scripts/Commands/OpenURL.cs index a13714fc..f9d67987 100644 --- a/Assets/Fungus/Scripts/Commands/OpenURL.cs +++ b/Assets/Fungus/Scripts/Commands/OpenURL.cs @@ -36,6 +36,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return url.stringRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs index 86983b6f..4738a515 100644 --- a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs +++ b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs @@ -53,6 +53,13 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return animator.animatorRef == variable || stateName.stringRef == variable || + layer.integerRef == variable || time.floatRef == variable || + base.HasReference(variable); + } + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs index b61e005c..c1eacfdd 100644 --- a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs +++ b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs @@ -83,6 +83,11 @@ using UnityEngine.Serialization; return new Color32(128, 200, 200, 255); } + public override bool HasReference(Variable variable) + { + return variable == _SettingsString.stringRef; + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs index a1aa957a..69df8bd8 100644 --- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs +++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs @@ -30,5 +30,10 @@ namespace Fungus } return outVar.Key; } + + public override bool HasReference(Variable variable) + { + return outVar == variable; + } } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/Scripts/Commands/PunchPosition.cs index 4f02620c..ff7b0b0a 100644 --- a/Assets/Fungus/Scripts/Commands/PunchPosition.cs +++ b/Assets/Fungus/Scripts/Commands/PunchPosition.cs @@ -40,6 +40,11 @@ namespace Fungus iTween.PunchPosition(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return variable == _amount.vector3Ref; + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/Scripts/Commands/PunchRotation.cs index 4fab9d73..71fec5b9 100644 --- a/Assets/Fungus/Scripts/Commands/PunchRotation.cs +++ b/Assets/Fungus/Scripts/Commands/PunchRotation.cs @@ -40,6 +40,11 @@ namespace Fungus iTween.PunchRotation(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return variable == _amount.vector3Ref; + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/PunchScale.cs b/Assets/Fungus/Scripts/Commands/PunchScale.cs index 2775eec2..7523520e 100644 --- a/Assets/Fungus/Scripts/Commands/PunchScale.cs +++ b/Assets/Fungus/Scripts/Commands/PunchScale.cs @@ -36,6 +36,11 @@ namespace Fungus iTween.PunchScale(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return variable == _amount.vector3Ref; + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Scripts/Commands/RandomFloat.cs index 8ebcbcbc..1cfd5527 100644 --- a/Assets/Fungus/Scripts/Commands/RandomFloat.cs +++ b/Assets/Fungus/Scripts/Commands/RandomFloat.cs @@ -48,7 +48,7 @@ namespace Fungus public override bool HasReference(Variable variable) { - return (variable == this.variable); + return (variable == this.variable) || minValue.floatRef == variable || maxValue.floatRef == variable; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Scripts/Commands/RandomInteger.cs index 7e238a90..aa201df5 100644 --- a/Assets/Fungus/Scripts/Commands/RandomInteger.cs +++ b/Assets/Fungus/Scripts/Commands/RandomInteger.cs @@ -48,7 +48,7 @@ namespace Fungus public override bool HasReference(Variable variable) { - return (variable == this.variable); + return (variable == this.variable) || minValue.integerRef == variable || maxValue.integerRef == variable; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs index f43c4774..baf3b277 100644 --- a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs +++ b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs @@ -49,6 +49,12 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return _animator.animatorRef == variable || _parameterName.stringRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/Scripts/Commands/RotateAdd.cs index f4dcd663..cf35b0dd 100644 --- a/Assets/Fungus/Scripts/Commands/RotateAdd.cs +++ b/Assets/Fungus/Scripts/Commands/RotateAdd.cs @@ -40,6 +40,12 @@ namespace Fungus iTween.RotateAdd(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _offset.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/Scripts/Commands/RotateFrom.cs index f3797fde..46224268 100644 --- a/Assets/Fungus/Scripts/Commands/RotateFrom.cs +++ b/Assets/Fungus/Scripts/Commands/RotateFrom.cs @@ -50,6 +50,12 @@ namespace Fungus iTween.RotateFrom(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _fromTransform.transformRef == variable || _fromRotation.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/RotateTo.cs b/Assets/Fungus/Scripts/Commands/RotateTo.cs index 1a6a1b33..7f5bcf74 100644 --- a/Assets/Fungus/Scripts/Commands/RotateTo.cs +++ b/Assets/Fungus/Scripts/Commands/RotateTo.cs @@ -50,6 +50,12 @@ namespace Fungus iTween.RotateTo(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _toTransform.transformRef == variable || _toRotation.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Scripts/Commands/SaveVariable.cs index 5b9f9e5e..4a5522d9 100644 --- a/Assets/Fungus/Scripts/Commands/SaveVariable.cs +++ b/Assets/Fungus/Scripts/Commands/SaveVariable.cs @@ -103,6 +103,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable in_variable) + { + return this.variable == in_variable || base.HasReference(in_variable); + } + #endregion #region Editor caches #if UNITY_EDITOR diff --git a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs index 6dd633f2..be4e56f2 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs @@ -36,6 +36,12 @@ namespace Fungus iTween.ScaleAdd(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _offset.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs index 1376c2ab..7c317f2a 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs @@ -46,6 +46,12 @@ namespace Fungus iTween.ScaleFrom(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _fromTransform.transformRef == variable || _fromScale.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/Scripts/Commands/ScaleTo.cs index 4baeb3e5..3a80d57a 100644 --- a/Assets/Fungus/Scripts/Commands/ScaleTo.cs +++ b/Assets/Fungus/Scripts/Commands/ScaleTo.cs @@ -46,6 +46,12 @@ namespace Fungus iTween.ScaleTo(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _toTransform.transformRef == variable || _toScale.vector3Ref == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Scripts/Commands/SendMessage.cs index fd87b76d..995fc09c 100644 --- a/Assets/Fungus/Scripts/Commands/SendMessage.cs +++ b/Assets/Fungus/Scripts/Commands/SendMessage.cs @@ -84,6 +84,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return _message.stringRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetActive.cs b/Assets/Fungus/Scripts/Commands/SetActive.cs index 4a6f11bc..bafc947e 100644 --- a/Assets/Fungus/Scripts/Commands/SetActive.cs +++ b/Assets/Fungus/Scripts/Commands/SetActive.cs @@ -49,6 +49,12 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return _targetGameObject.gameObjectRef == variable || activeState.booleanRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs index a4b9290d..26a7a778 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs @@ -52,6 +52,12 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.booleanRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs index 9494e542..5aa66f55 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs @@ -52,6 +52,12 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.floatRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs index 8f07d4fd..cb4e8076 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs @@ -52,6 +52,12 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return _animator.animatorRef == variable || _parameterName.stringRef == variable || value.integerRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs index d7843e7a..a3d190cc 100644 --- a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs +++ b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs @@ -49,6 +49,11 @@ namespace Fungus return new Color32(170, 204, 169, 255); } + public override bool HasReference(Variable variable) + { + return _animator.animatorRef == variable || _parameterName.stringRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs index 80138ed7..29a59de9 100644 --- a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs +++ b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs @@ -44,7 +44,12 @@ namespace Fungus public override Color GetButtonColor() { - return new Color32(235, 191, 217, 255); + return new Color32(235, 191, 217, 255); + } + + public override bool HasReference(Variable variable) + { + return activeState.booleanRef == variable || base.HasReference(variable); } #endregion diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs index ef623040..2cca14f8 100644 --- a/Assets/Fungus/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs @@ -102,6 +102,11 @@ namespace Fungus return propertyName == "targetObjects"; } + public override bool HasReference(Variable variable) + { + return activeState.booleanRef == variable || base.HasReference(variable); + } + #endregion } diff --git a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs index c5e0ff6a..3b8ac1ef 100644 --- a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs +++ b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs @@ -47,6 +47,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return activeState.booleanRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs index e258883c..ea2d0912 100644 --- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs +++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs @@ -101,6 +101,11 @@ namespace Fungus return false; } + public override bool HasReference(Variable variable) + { + return interactableState.booleanRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetLanguage.cs b/Assets/Fungus/Scripts/Commands/SetLanguage.cs index 2c6aae9f..9efc8867 100644 --- a/Assets/Fungus/Scripts/Commands/SetLanguage.cs +++ b/Assets/Fungus/Scripts/Commands/SetLanguage.cs @@ -48,6 +48,11 @@ namespace Fungus return new Color32(184, 210, 235, 255); } + public override bool HasReference(Variable variable) + { + return _languageCode.stringRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs index cfde6251..f80b06c9 100644 --- a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs +++ b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs @@ -47,6 +47,11 @@ namespace Fungus return slider.name + " = " + value.GetDescription(); } + public override bool HasReference(Variable variable) + { + return value.floatRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs index e284941d..fb811b6b 100644 --- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs @@ -80,6 +80,11 @@ namespace Fungus targetSprites.Add(null); } + public override bool HasReference(Variable variable) + { + return orderInLayer.integerRef == variable || base.HasReference(variable); + } + #endregion } } diff --git a/Assets/Fungus/Scripts/Commands/SetText.cs b/Assets/Fungus/Scripts/Commands/SetText.cs index 6fdb0fe5..a3204549 100644 --- a/Assets/Fungus/Scripts/Commands/SetText.cs +++ b/Assets/Fungus/Scripts/Commands/SetText.cs @@ -80,6 +80,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return text.stringRef == variable || base.HasReference(variable); + } + #endregion diff --git a/Assets/Fungus/Scripts/Commands/SetToggleState.cs b/Assets/Fungus/Scripts/Commands/SetToggleState.cs index 79d9f376..d93a0262 100644 --- a/Assets/Fungus/Scripts/Commands/SetToggleState.cs +++ b/Assets/Fungus/Scripts/Commands/SetToggleState.cs @@ -47,6 +47,11 @@ namespace Fungus return toggle.name + " = " + value.GetDescription(); } + public override bool HasReference(Variable variable) + { + return value.booleanRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Scripts/Commands/SetVariable.cs index a696a3ee..50ca8588 100644 --- a/Assets/Fungus/Scripts/Commands/SetVariable.cs +++ b/Assets/Fungus/Scripts/Commands/SetVariable.cs @@ -92,83 +92,86 @@ namespace Fungus return; } - if (variable.GetType() == typeof(BooleanVariable)) + + var t = variable.GetType(); + + if (t == typeof(BooleanVariable)) { BooleanVariable booleanVariable = (variable as BooleanVariable); booleanVariable.Apply(setOperator, booleanData.Value); } - else if (variable.GetType() == typeof(IntegerVariable)) + else if (t == typeof(IntegerVariable)) { IntegerVariable integerVariable = (variable as IntegerVariable); integerVariable.Apply(setOperator, integerData.Value); } - else if (variable.GetType() == typeof(FloatVariable)) + else if (t == typeof(FloatVariable)) { FloatVariable floatVariable = (variable as FloatVariable); floatVariable.Apply(setOperator, floatData.Value); } - else if (variable.GetType() == typeof(StringVariable)) + else if (t == typeof(StringVariable)) { StringVariable stringVariable = (variable as StringVariable); var flowchart = GetFlowchart(); stringVariable.Apply(setOperator, flowchart.SubstituteVariables(stringData.Value)); } - else if (variable.GetType() == typeof(AnimatorVariable)) + else if (t == typeof(AnimatorVariable)) { AnimatorVariable animatorVariable = (variable as AnimatorVariable); animatorVariable.Apply(setOperator, animatorData.Value); } - else if (variable.GetType() == typeof(AudioSourceVariable)) + else if (t == typeof(AudioSourceVariable)) { AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable); audioSourceVariable.Apply(setOperator, audioSourceData.Value); } - else if (variable.GetType() == typeof(ColorVariable)) + else if (t == typeof(ColorVariable)) { ColorVariable colorVariable = (variable as ColorVariable); colorVariable.Apply(setOperator, colorData.Value); } - else if (variable.GetType() == typeof(GameObjectVariable)) + else if (t == typeof(GameObjectVariable)) { GameObjectVariable gameObjectVariable = (variable as GameObjectVariable); gameObjectVariable.Apply(setOperator, gameObjectData.Value); } - else if (variable.GetType() == typeof(MaterialVariable)) + else if (t == typeof(MaterialVariable)) { MaterialVariable materialVariable = (variable as MaterialVariable); materialVariable.Apply(setOperator, materialData.Value); } - else if (variable.GetType() == typeof(ObjectVariable)) + else if (t == typeof(ObjectVariable)) { ObjectVariable objectVariable = (variable as ObjectVariable); objectVariable.Apply(setOperator, objectData.Value); } - else if (variable.GetType() == typeof(Rigidbody2DVariable)) + else if (t == typeof(Rigidbody2DVariable)) { Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable); rigidbody2DVariable.Apply(setOperator, rigidbody2DData.Value); } - else if (variable.GetType() == typeof(SpriteVariable)) + else if (t == typeof(SpriteVariable)) { SpriteVariable spriteVariable = (variable as SpriteVariable); spriteVariable.Apply(setOperator, spriteData.Value); } - else if (variable.GetType() == typeof(TextureVariable)) + else if (t == typeof(TextureVariable)) { TextureVariable textureVariable = (variable as TextureVariable); textureVariable.Apply(setOperator, textureData.Value); } - else if (variable.GetType() == typeof(TransformVariable)) + else if (t == typeof(TransformVariable)) { TransformVariable transformVariable = (variable as TransformVariable); transformVariable.Apply(setOperator, transformData.Value); } - else if (variable.GetType() == typeof(Vector2Variable)) + else if (t == typeof(Vector2Variable)) { Vector2Variable vector2Variable = (variable as Vector2Variable); vector2Variable.Apply(setOperator, vector2Data.Value); } - else if (variable.GetType() == typeof(Vector3Variable)) + else if (t == typeof(Vector3Variable)) { Vector3Variable vector3Variable = (variable as Vector3Variable); vector3Variable.Apply(setOperator, vector3Data.Value); @@ -240,67 +243,69 @@ namespace Fungus break; } - if (variable.GetType() == typeof(BooleanVariable)) + var t = variable.GetType(); + + if (t == typeof(BooleanVariable)) { description += booleanData.GetDescription(); } - else if (variable.GetType() == typeof(IntegerVariable)) + else if (t == typeof(IntegerVariable)) { description += integerData.GetDescription(); } - else if (variable.GetType() == typeof(FloatVariable)) + else if (t == typeof(FloatVariable)) { description += floatData.GetDescription(); } - else if (variable.GetType() == typeof(StringVariable)) + else if (t == typeof(StringVariable)) { description += stringData.GetDescription(); } - else if (variable.GetType() == typeof(AnimatorVariable)) + else if (t == typeof(AnimatorVariable)) { description += animatorData.GetDescription(); } - else if (variable.GetType() == typeof(AudioSourceVariable)) + else if (t == typeof(AudioSourceVariable)) { description += audioSourceData.GetDescription(); } - else if (variable.GetType() == typeof(ColorVariable)) + else if (t == typeof(ColorVariable)) { description += colorData.GetDescription(); } - else if (variable.GetType() == typeof(GameObjectVariable)) + else if (t == typeof(GameObjectVariable)) { description += gameObjectData.GetDescription(); } - else if (variable.GetType() == typeof(MaterialVariable)) + else if (t == typeof(MaterialVariable)) { description += materialData.GetDescription(); } - else if (variable.GetType() == typeof(ObjectVariable)) + else if (t == typeof(ObjectVariable)) { description += objectData.GetDescription(); } - else if (variable.GetType() == typeof(Rigidbody2DVariable)) + else if (t == typeof(Rigidbody2DVariable)) { description += rigidbody2DData.GetDescription(); } - else if (variable.GetType() == typeof(SpriteVariable)) + else if (t == typeof(SpriteVariable)) { description += spriteData.GetDescription(); } - else if (variable.GetType() == typeof(TextureVariable)) + else if (t == typeof(TextureVariable)) { description += textureData.GetDescription(); } - else if (variable.GetType() == typeof(TransformVariable)) + else if (t == typeof(TransformVariable)) { description += transformData.GetDescription(); } - else if (variable.GetType() == typeof(Vector2Variable)) + else if (t == typeof(Vector2Variable)) { description += vector2Data.GetDescription(); } - else if (variable.GetType() == typeof(Vector3Variable)) + else if (t == typeof(Vector3Variable)) { description += vector3Data.GetDescription(); } @@ -310,7 +315,77 @@ namespace Fungus public override bool HasReference(Variable variable) { - return (variable == this.variable); + bool retval = (variable == this.variable) || base.HasReference(variable); + + var t = variable.GetType(); + + //this is a nightmare + if (t == typeof(BooleanVariable)) + { + retval |= booleanData.booleanRef == variable; + } + else if (t == typeof(IntegerVariable)) + { + retval |= integerData.integerRef == variable; + } + else if (t == typeof(FloatVariable)) + { + retval |= floatData.floatRef == variable; + } + else if (t == typeof(StringVariable)) + { + retval |= stringData.stringRef == variable; + } + else if (t == typeof(AnimatorVariable)) + { + retval |= animatorData.animatorRef == variable; + } + else if (t == typeof(AudioSourceVariable)) + { + retval |= audioSourceData.audioSourceRef == variable; + } + else if (t == typeof(ColorVariable)) + { + retval |= colorData.colorRef == variable; + } + else if (t == typeof(GameObjectVariable)) + { + retval |= gameObjectData.gameObjectRef == variable; + } + else if (t == typeof(MaterialVariable)) + { + retval |= materialData.materialRef == variable; + } + else if (t == typeof(ObjectVariable)) + { + retval |= objectData.objectRef == variable; + } + else if (t == typeof(Rigidbody2DVariable)) + { + retval |= rigidbody2DData.rigidbody2DRef == variable; + } + else if (t == typeof(SpriteVariable)) + { + retval |= spriteData.spriteRef == variable; + } + else if (t == typeof(TextureVariable)) + { + retval |= textureData.textureRef == variable; + } + else if (t == typeof(TransformVariable)) + { + retval |= transformData.transformRef == variable; + } + else if (t == typeof(Vector2Variable)) + { + retval |= vector2Data.vector2Ref == variable; + } + else if (t == typeof(Vector3Variable)) + { + retval |= vector3Data.vector3Ref == variable; + } + + return retval; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/Scripts/Commands/ShakePosition.cs index 4432d068..2388a0b2 100644 --- a/Assets/Fungus/Scripts/Commands/ShakePosition.cs +++ b/Assets/Fungus/Scripts/Commands/ShakePosition.cs @@ -55,6 +55,11 @@ namespace Fungus iTween.ShakePosition(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _amount.vector3Ref == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs index a4838efd..ab30c1d8 100644 --- a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs +++ b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs @@ -40,6 +40,11 @@ namespace Fungus iTween.ShakeRotation(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _amount.vector3Ref == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/Scripts/Commands/ShakeScale.cs index 6a3434d4..c2c0ffca 100644 --- a/Assets/Fungus/Scripts/Commands/ShakeScale.cs +++ b/Assets/Fungus/Scripts/Commands/ShakeScale.cs @@ -36,6 +36,11 @@ namespace Fungus iTween.ShakeScale(_targetObject.Value, tweenParams); } + public override bool HasReference(Variable variable) + { + return _amount.vector3Ref == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Scripts/Commands/ShowSprite.cs index 110b6517..ea454a50 100644 --- a/Assets/Fungus/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Scripts/Commands/ShowSprite.cs @@ -71,6 +71,11 @@ namespace Fungus return new Color32(221, 184, 169, 255); } + public override bool HasReference(Variable variable) + { + return _visible.booleanRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs index 125045d4..4f390591 100644 --- a/Assets/Fungus/Scripts/Commands/StopBlock.cs +++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs @@ -55,6 +55,11 @@ namespace Fungus return new Color32(253, 253, 150, 255); } + public override bool HasReference(Variable variable) + { + return blockName.stringRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/StopTween.cs b/Assets/Fungus/Scripts/Commands/StopTween.cs index 059bf75e..f1cd8d11 100644 --- a/Assets/Fungus/Scripts/Commands/StopTween.cs +++ b/Assets/Fungus/Scripts/Commands/StopTween.cs @@ -27,6 +27,11 @@ namespace Fungus Continue(); } + public override bool HasReference(Variable variable) + { + return _tweenName.stringRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs index 2563c796..1a7e62f0 100644 --- a/Assets/Fungus/Scripts/Commands/TweenUI.cs +++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs @@ -132,6 +132,11 @@ namespace Fungus return false; } + public override bool HasReference(Variable variable) + { + return waitUntilFinished.booleanRef == variable || duration.floatRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/VariableCondition.cs b/Assets/Fungus/Scripts/Commands/VariableCondition.cs index f69db54f..a1ab567a 100644 --- a/Assets/Fungus/Scripts/Commands/VariableCondition.cs +++ b/Assets/Fungus/Scripts/Commands/VariableCondition.cs @@ -87,82 +87,84 @@ namespace Fungus bool condition = false; - if (variable.GetType() == typeof(BooleanVariable)) + var t = variable.GetType(); + + if (t == typeof(BooleanVariable)) { BooleanVariable booleanVariable = (variable as BooleanVariable); condition = booleanVariable.Evaluate(compareOperator, booleanData.Value); } - else if (variable.GetType() == typeof(IntegerVariable)) + else if (t == typeof(IntegerVariable)) { IntegerVariable integerVariable = (variable as IntegerVariable); condition = integerVariable.Evaluate(compareOperator, integerData.Value); } - else if (variable.GetType() == typeof(FloatVariable)) + else if (t == typeof(FloatVariable)) { FloatVariable floatVariable = (variable as FloatVariable); condition = floatVariable.Evaluate(compareOperator, floatData.Value); } - else if (variable.GetType() == typeof(StringVariable)) + else if (t == typeof(StringVariable)) { StringVariable stringVariable = (variable as StringVariable); condition = stringVariable.Evaluate(compareOperator, stringData.Value); } - else if (variable.GetType() == typeof(AnimatorVariable)) + else if (t == typeof(AnimatorVariable)) { AnimatorVariable animatorVariable = (variable as AnimatorVariable); condition = animatorVariable.Evaluate(compareOperator, animatorData.Value); } - else if (variable.GetType() == typeof(AudioSourceVariable)) + else if (t == typeof(AudioSourceVariable)) { AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable); condition = audioSourceVariable.Evaluate(compareOperator, audioSourceData.Value); } - else if (variable.GetType() == typeof(ColorVariable)) + else if (t == typeof(ColorVariable)) { ColorVariable colorVariable = (variable as ColorVariable); condition = colorVariable.Evaluate(compareOperator, colorData.Value); } - else if (variable.GetType() == typeof(GameObjectVariable)) + else if (t == typeof(GameObjectVariable)) { GameObjectVariable gameObjectVariable = (variable as GameObjectVariable); condition = gameObjectVariable.Evaluate(compareOperator, gameObjectData.Value); } - else if (variable.GetType() == typeof(MaterialVariable)) + else if (t == typeof(MaterialVariable)) { MaterialVariable materialVariable = (variable as MaterialVariable); condition = materialVariable.Evaluate(compareOperator, materialData.Value); } - else if (variable.GetType() == typeof(ObjectVariable)) + else if (t == typeof(ObjectVariable)) { ObjectVariable objectVariable = (variable as ObjectVariable); condition = objectVariable.Evaluate(compareOperator, objectData.Value); } - else if (variable.GetType() == typeof(Rigidbody2DVariable)) + else if (t == typeof(Rigidbody2DVariable)) { Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable); condition = rigidbody2DVariable.Evaluate(compareOperator, rigidbody2DData.Value); } - else if (variable.GetType() == typeof(SpriteVariable)) + else if (t == typeof(SpriteVariable)) { SpriteVariable spriteVariable = (variable as SpriteVariable); condition = spriteVariable.Evaluate(compareOperator, spriteData.Value); } - else if (variable.GetType() == typeof(TextureVariable)) + else if (t == typeof(TextureVariable)) { TextureVariable textureVariable = (variable as TextureVariable); condition = textureVariable.Evaluate(compareOperator, textureData.Value); } - else if (variable.GetType() == typeof(TransformVariable)) + else if (t == typeof(TransformVariable)) { TransformVariable transformVariable = (variable as TransformVariable); condition = transformVariable.Evaluate(compareOperator, transformData.Value); } - else if (variable.GetType() == typeof(Vector2Variable)) + else if (t == typeof(Vector2Variable)) { Vector2Variable vector2Variable = (variable as Vector2Variable); condition = vector2Variable.Evaluate(compareOperator, vector2Data.Value); } - else if (variable.GetType() == typeof(Vector3Variable)) + else if (t == typeof(Vector3Variable)) { Vector3Variable vector3Variable = (variable as Vector3Variable); condition = vector3Variable.Evaluate(compareOperator, vector3Data.Value); @@ -209,70 +211,72 @@ namespace Fungus return "Error: No variable selected"; } + var t = variable.GetType(); + string summary = variable.Key + " "; summary += Condition.GetOperatorDescription(compareOperator) + " "; - if (variable.GetType() == typeof(BooleanVariable)) + if (t == typeof(BooleanVariable)) { summary += booleanData.GetDescription(); } - else if (variable.GetType() == typeof(IntegerVariable)) + else if (t == typeof(IntegerVariable)) { summary += integerData.GetDescription(); } - else if (variable.GetType() == typeof(FloatVariable)) + else if (t == typeof(FloatVariable)) { summary += floatData.GetDescription(); } - else if (variable.GetType() == typeof(StringVariable)) + else if (t == typeof(StringVariable)) { summary += stringData.GetDescription(); } - else if (variable.GetType() == typeof(AnimatorVariable)) + else if (t == typeof(AnimatorVariable)) { summary += animatorData.GetDescription(); } - else if (variable.GetType() == typeof(AudioSourceVariable)) + else if (t == typeof(AudioSourceVariable)) { summary += audioSourceData.GetDescription(); } - else if (variable.GetType() == typeof(ColorVariable)) + else if (t == typeof(ColorVariable)) { summary += colorData.GetDescription(); } - else if (variable.GetType() == typeof(GameObjectVariable)) + else if (t == typeof(GameObjectVariable)) { summary += gameObjectData.GetDescription(); } - else if (variable.GetType() == typeof(MaterialVariable)) + else if (t == typeof(MaterialVariable)) { summary += materialData.GetDescription(); } - else if (variable.GetType() == typeof(ObjectVariable)) + else if (t == typeof(ObjectVariable)) { summary += objectData.GetDescription(); } - else if (variable.GetType() == typeof(Rigidbody2DVariable)) + else if (t == typeof(Rigidbody2DVariable)) { summary += rigidbody2DData.GetDescription(); } - else if (variable.GetType() == typeof(SpriteVariable)) + else if (t == typeof(SpriteVariable)) { summary += spriteData.GetDescription(); } - else if (variable.GetType() == typeof(TextureVariable)) + else if (t == typeof(TextureVariable)) { summary += textureData.GetDescription(); } - else if (variable.GetType() == typeof(TransformVariable)) + else if (t == typeof(TransformVariable)) { summary += transformData.GetDescription(); } - else if (variable.GetType() == typeof(Vector2Variable)) + else if (t == typeof(Vector2Variable)) { summary += vector2Data.GetDescription(); } - else if (variable.GetType() == typeof(Vector3Variable)) + else if (t == typeof(Vector3Variable)) { summary += vector3Data.GetDescription(); } @@ -282,7 +286,77 @@ namespace Fungus public override bool HasReference(Variable variable) { - return (variable == this.variable); + bool retval = (variable == this.variable) || base.HasReference(variable); + + var t = variable.GetType(); + + //this is a nightmare + if (t == typeof(BooleanVariable)) + { + retval |= booleanData.booleanRef == variable; + } + else if (t == typeof(IntegerVariable)) + { + retval |= integerData.integerRef == variable; + } + else if (t == typeof(FloatVariable)) + { + retval |= floatData.floatRef == variable; + } + else if (t == typeof(StringVariable)) + { + retval |= stringData.stringRef == variable; + } + else if (t == typeof(AnimatorVariable)) + { + retval |= animatorData.animatorRef == variable; + } + else if (t == typeof(AudioSourceVariable)) + { + retval |= audioSourceData.audioSourceRef == variable; + } + else if (t == typeof(ColorVariable)) + { + retval |= colorData.colorRef == variable; + } + else if (t == typeof(GameObjectVariable)) + { + retval |= gameObjectData.gameObjectRef == variable; + } + else if (t == typeof(MaterialVariable)) + { + retval |= materialData.materialRef == variable; + } + else if (t == typeof(ObjectVariable)) + { + retval |= objectData.objectRef == variable; + } + else if (t == typeof(Rigidbody2DVariable)) + { + retval |= rigidbody2DData.rigidbody2DRef == variable; + } + else if (t == typeof(SpriteVariable)) + { + retval |= spriteData.spriteRef == variable; + } + else if (t == typeof(TextureVariable)) + { + retval |= textureData.textureRef == variable; + } + else if (t == typeof(TransformVariable)) + { + retval |= transformData.transformRef == variable; + } + else if (t == typeof(Vector2Variable)) + { + retval |= vector2Data.vector2Ref == variable; + } + else if (t == typeof(Vector3Variable)) + { + retval |= vector3Data.vector3Ref == variable; + } + + return retval; } public override Color GetButtonColor() diff --git a/Assets/Fungus/Scripts/Commands/Wait.cs b/Assets/Fungus/Scripts/Commands/Wait.cs index 6299217c..5c506688 100644 --- a/Assets/Fungus/Scripts/Commands/Wait.cs +++ b/Assets/Fungus/Scripts/Commands/Wait.cs @@ -41,6 +41,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return _duration.floatRef == variable || base.HasReference(variable); + } + #endregion #region Backwards compatibility diff --git a/Assets/Fungus/Scripts/Commands/WaitFrames.cs b/Assets/Fungus/Scripts/Commands/WaitFrames.cs index a099b0eb..5d041945 100644 --- a/Assets/Fungus/Scripts/Commands/WaitFrames.cs +++ b/Assets/Fungus/Scripts/Commands/WaitFrames.cs @@ -49,6 +49,11 @@ namespace Fungus return new Color32(235, 191, 217, 255); } + public override bool HasReference(Variable variable) + { + return frameCount.integerRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/Write.cs b/Assets/Fungus/Scripts/Commands/Write.cs index 297df887..34ff445e 100644 --- a/Assets/Fungus/Scripts/Commands/Write.cs +++ b/Assets/Fungus/Scripts/Commands/Write.cs @@ -155,6 +155,11 @@ namespace Fungus return "WRITE." + GetFlowchartLocalizationId() + "." + itemId; } + public override bool HasReference(Variable variable) + { + return text.stringRef == variable || setAlpha.floatRef == variable || setColor.colorRef == variable || base.HasReference(variable); + } + #endregion } } \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs index 2bc8b0ac..b118b303 100644 --- a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs +++ b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs @@ -108,6 +108,12 @@ namespace Fungus return new Color32(233, 163, 180, 255); } + public override bool HasReference(Variable variable) + { + return _targetObject.gameObjectRef == variable || _tweenName.stringRef == variable || + base.HasReference(variable); + } + #endregion #region Backwards compatibility