You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using UnityEngine;
|
|
using MalbersAnimations.Scriptables;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MalbersAnimations.Utilities
|
|
{
|
|
[AddComponentMenu("Malbers/Utilities/Mesh/Material Lerp")]
|
|
|
|
public class MaterialLerp : MonoBehaviour
|
|
{
|
|
public bool LerpOnEnable = true;
|
|
public List<InternalMaterialLerp> materials;
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (LerpOnEnable) Lerp();
|
|
}
|
|
|
|
public virtual void Lerp() => StartCoroutine(Lerper());
|
|
|
|
|
|
|
|
IEnumerator Lerper()
|
|
{
|
|
//float elapsedTime = 0;
|
|
|
|
//var rendererMaterials = new List<Material>();
|
|
|
|
//foreach (var item in materials)
|
|
//{
|
|
// rendererMaterials.Add(item.sharedMaterials[materialIndex]); //get the Material from the renderer)
|
|
//}
|
|
|
|
|
|
|
|
//while (elapsedTime <= time.Value)
|
|
//{
|
|
// float value = curve.Evaluate(elapsedTime / time);
|
|
|
|
// mesh.material.Lerp(rendererMaterial, ToMaterial, value);
|
|
// elapsedTime += Time.deltaTime;
|
|
|
|
// // Debug.Log("value = " + value.ToString("F2"));
|
|
// yield return null;
|
|
//}
|
|
|
|
//mesh.material.Lerp(rendererMaterial, ToMaterial, curve.Evaluate(1f));
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class InternalMaterialLerp
|
|
{
|
|
public Renderer renderer;
|
|
[CreateScriptableAsset(false)] public MaterialLerpSO materials;
|
|
}
|
|
}
|
|
|