Skip to content

Commit

Permalink
Support for Tweens on Background AssetBundles
Browse files Browse the repository at this point in the history
  • Loading branch information
NyxTheShield committed Oct 3, 2022
1 parent ad6c68f commit 667d989
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
54 changes: 43 additions & 11 deletions Data/LeanTweenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,65 @@

namespace TrombLoader.Data;

[Serializable]
public class LeanTweenHelper:MonoBehaviour
{
public LeanTweenHelperType tweenType;
public Vector3 targetValue;
public Vector3 vector3Value;
public float floatValue;
public float time;
public LeanTweenType easeType = LeanTweenType.linear;
public LeanTweenType loopType = LeanTweenType.clamp;
public int loopCount = 0;
public bool runOnStart = false;
public LeanTweenHelper invokeOnComplete;


private Action tweenAction;
public void Start()
public Action tweenAction;


public void SetTweenType()
{
switch (tweenType)
{
case LeanTweenHelperType.MOVELOCAL:
tweenAction = () => LeanTween.moveLocal(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween());
tweenAction = () => LeanTween.moveLocal(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVEGLOBAL:
tweenAction = () => LeanTween.move(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween());
tweenAction = () => LeanTween.move(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.ROTATELOCAL:
tweenAction = () => LeanTween.rotateLocal(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween());
tweenAction = () => LeanTween.rotateLocal(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.ROTATEGLOBAL:
tweenAction = () => LeanTween.rotate(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween());
tweenAction = () => LeanTween.rotate(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.SCALE:
tweenAction = () => LeanTween.scale(this.gameObject, targetValue, time).setEase(easeType).setLoopType(loopType).setOnComplete(() => invokeOnComplete.DoTween());
tweenAction = () => LeanTween.scale(this.gameObject, vector3Value, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVEX:
tweenAction = () => LeanTween.moveX(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVEY:
tweenAction = () => LeanTween.moveY(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVEZ:
tweenAction = () => LeanTween.moveZ(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVELOCALX:
tweenAction = () => LeanTween.moveLocalX(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVELOCALY:
tweenAction = () => LeanTween.moveLocalY(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
case LeanTweenHelperType.MOVELOCALZ:
tweenAction = () => LeanTween.moveLocalZ(this.gameObject, floatValue, time).setEase(easeType).setLoopCount(loopCount).setLoopType(loopType).setOnComplete(() => invokeOnComplete?.DoTween());
break;
}
}

public void Start()
{
SetTweenType();
if (runOnStart) DoTween();
}

Expand All @@ -45,13 +70,20 @@ public void DoTween()
tweenAction.Invoke();
}


public enum LeanTweenHelperType
{
MOVELOCAL=0,
MOVEGLOBAL=1,
ROTATELOCAL=2,
ROTATEGLOBAL=3,
SCALE =4
MOVEX=4,
MOVEY=5,
MOVEZ=6,
MOVELOCALX=7,
MOVELOCALY=8,
MOVELOCALZ=9,
SCALE=10
}
}

1 change: 1 addition & 0 deletions Data/TromboneEventManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEngine.Events;
Expand Down

0 comments on commit 667d989

Please sign in to comment.