Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause & Resume LeanTween Command #1010

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions Assets/Fungus/Scripts/Commands/LeanTween/PauseResumeLeanTween.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum PauseResume
{
None,
Pause,
Resume,
PauseAll,
ResumeAll
}
namespace Fungus
{
/// <summary>
///
/// </summary>
[CommandInfo("LeanTween",
"Pause Resume",
"Pause or Resume LeanTween on target gameObject")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class PauseResumeLeanTween : Command
{
[Tooltip("Set the state of target gameObject")]
[SerializeField]
protected PauseResume setTweenState;
[Tooltip("Target game object to Pause or Resume LeanTweens on")]
[SerializeField]
protected GameObjectData _targetObject;

public override void OnEnter()
{
if (_targetObject.Value != null)
{
switch(setTweenState)
{
case PauseResume.Pause:
LeanTween.pause(_targetObject.Value);
break;
case PauseResume.Resume:
LeanTween.resume(_targetObject.Value);
break;
case PauseResume.PauseAll:
LeanTween.pauseAll();
break;
case PauseResume.ResumeAll:
LeanTween.resumeAll();
break;
}
}

Continue();
}

public override string GetSummary()
{
if (_targetObject.Value == null)
{
return "Error: No target object selected";
}

return "Pause or Resume LeanTweens on " + _targetObject.Value.name;
}

public override Color GetButtonColor()
{
return new Color32(233, 163, 180, 255);
}

public override bool HasReference(Variable variable)
{
return _targetObject.gameObjectRef == variable;
}
}
}