soundvision/UnityProject/Assets/Scenes/Examples/Texture/TextureMapper.cs

39 lines
1.5 KiB
C#
Raw Normal View History

2019-10-05 14:49:30 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace cylvester
{
public class TextureMapper : MonoBehaviour
{
2019-10-05 16:09:24 +00:00
[SerializeField] private Waveform waveform;
2019-10-05 14:49:30 +00:00
[SerializeField] private Spectrogram spectrogram;
2019-10-05 16:09:24 +00:00
[SerializeField] private GameObject waveformPanel;
[SerializeField] private GameObject spectrogramPanel;
2019-10-05 18:15:26 +00:00
[SerializeField] private GameObject chikashiPanel;
2019-10-05 16:09:24 +00:00
private Renderer waveFormRenderer_;
private Renderer spectroGramRenderer_;
2019-10-05 18:15:26 +00:00
private Renderer chikashiRenderer_;
2019-10-05 14:49:30 +00:00
private static readonly int baseColorMap_ = Shader.PropertyToID("_BaseColorMap");
private static readonly int spectrogramIndex_ = Shader.PropertyToID("_Index");
2019-10-05 18:15:26 +00:00
private static readonly int myTexture_ = Shader.PropertyToID("_MyTexture");
2019-10-05 14:49:30 +00:00
void Start()
{
2019-10-05 16:09:24 +00:00
waveFormRenderer_ = waveformPanel.GetComponent<Renderer>();
spectroGramRenderer_ = spectrogramPanel.GetComponent<Renderer>();
2019-10-05 18:15:26 +00:00
chikashiRenderer_ = chikashiPanel.GetComponent<Renderer>();
2019-10-05 14:49:30 +00:00
}
void Update()
{
2019-10-05 16:09:24 +00:00
waveFormRenderer_.material.SetTexture(baseColorMap_, waveform.Texture);
spectroGramRenderer_.material.SetTexture(baseColorMap_, spectrogram.Texture);
spectroGramRenderer_.material.SetInt(spectrogramIndex_, spectrogram.Index);
2019-10-05 18:15:26 +00:00
chikashiRenderer_.material.SetTexture(myTexture_, waveform.Texture);
2019-10-05 14:49:30 +00:00
}
}
}