soundvision/UnityProject/Assets/LookupTextureSGBinder.cs

31 lines
1,009 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2020-01-13 15:20:47 +00:00
public class LookupTextureSGBinder : MonoBehaviour
{
[SerializeField] private LookupTexture lookupTexture;
[SerializeField] private GameObject TextureOutput;
private Renderer lookupTextureRenderer_;
private static readonly int lookupTexture_ = Shader.PropertyToID("_BaseColorMap");
private static readonly int lookupTextureIndex_ = Shader.PropertyToID("_LookupTextureIndex");
2020-01-03 15:17:07 +00:00
private static readonly int lookupTextureLength_ = Shader.PropertyToID("_LookupTextureLength");
private void Start()
{
lookupTextureRenderer_ = TextureOutput.GetComponent<Renderer>();
}
private void Update()
{
lookupTextureRenderer_.material.SetTexture(lookupTexture_, lookupTexture.Texture);
lookupTextureRenderer_.material.SetInt(lookupTextureIndex_, lookupTexture.Index);
2020-01-03 15:17:07 +00:00
lookupTextureRenderer_.material.SetInt(lookupTextureLength_, lookupTexture.Length);
}
}