36 lines
855 B
C#
36 lines
855 B
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.PlayerLoop;
|
|
|
|
//Q(ueue)able Object used by the ObjectQ handler.
|
|
public class QableObject : MonoBehaviour
|
|
{
|
|
public float _dissolveTime = 0.5f;
|
|
public Renderer renderer;
|
|
|
|
private void Awake()
|
|
{
|
|
renderer = gameObject.GetComponent<Renderer>();
|
|
}
|
|
|
|
public IEnumerator Dissolve(bool reverse = false)
|
|
{
|
|
float timer = 0;
|
|
float from = reverse ? 1 : 0;
|
|
float to = reverse ? 0 : 1;
|
|
|
|
while (timer < _dissolveTime)
|
|
{
|
|
var val = Mathf.SmoothStep(from, to, timer/_dissolveTime);
|
|
val = Mathf.Clamp01(val);
|
|
renderer.material.SetFloat("Vector1_9fb2dc688df04073ae34e838656f2a2e", val);
|
|
timer += Time.deltaTime;
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
|
|
|
|
yield return timer;
|
|
}
|
|
}
|