Created
June 12, 2020 19:36
-
-
Save lordlycastle/9ed26aac7770835ae9c73e547497d09d to your computer and use it in GitHub Desktop.
Tween any float material property with help of DOTween! π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using DG.Tweening; | |
using Sirenix.OdinInspector; | |
using UnityEngine; | |
public class MaterialsFloatTweener : MonoBehaviour | |
{ | |
[InlineEditor()] | |
public Material material; | |
public string name; | |
public float duration; | |
public float from; | |
public float to; | |
public bool autoPlay; | |
public Ease tweenEase = Ease.Linear; | |
[InfoBox("-1 means forever")] public int loops = -1; | |
public LoopType loopType = LoopType.Yoyo; | |
public Tween tween; | |
private void Start() | |
{ | |
tween = DOTween.To(value => material.SetFloat(name, value), @from, to, duration) | |
.SetLoops(loops, loopType) | |
.SetEase(tweenEase); | |
if (autoPlay) | |
tween.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment