soundvision/UnityProject/Assets/Scenes/Examples/Texture/TextureMapper.cs
2019-10-05 20:15:26 +02:00

37 lines
No EOL
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace cylvester
{
public class TextureMapper : MonoBehaviour
{
[SerializeField] private Waveform waveform;
[SerializeField] private Spectrogram spectrogram;
[SerializeField] private GameObject waveformPanel;
[SerializeField] private GameObject spectrogramPanel;
[SerializeField] private GameObject chikashiPanel;
private Renderer waveFormRenderer_;
private Renderer spectroGramRenderer_;
private Renderer chikashiRenderer_;
private static readonly int baseColorMap_ = Shader.PropertyToID("_BaseColorMap");
private static readonly int myTexture_ = Shader.PropertyToID("_MyTexture");
void Start()
{
waveFormRenderer_ = waveformPanel.GetComponent<Renderer>();
spectroGramRenderer_ = spectrogramPanel.GetComponent<Renderer>();
chikashiRenderer_ = chikashiPanel.GetComponent<Renderer>();
}
void Update()
{
waveFormRenderer_.material.SetTexture(baseColorMap_, waveform.Texture);
spectroGramRenderer_.material.SetTexture(baseColorMap_, spectrogram.Texture);
chikashiRenderer_.material.SetTexture(myTexture_, waveform.Texture);
}
}
}