- Home /
Change Color of a Emission Texture
Hello, i want to change color of this texture by a script
this is a script i made, but he only change "color emission" of a non-texture material.
using UnityEngine;
using System.Collections;
public class ColorChanger : MonoBehaviour
{
public Color colorStart;
public Color colorEnd;
private float colorDuration = 1.0f;
private Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
}
void Update()
{
float lerp = Mathf.PingPong(Time.time, colorDuration) / colorDuration;
Color c = (Color.Lerp(colorStart, colorEnd, lerp));
rend.material.SetColor("_EmissionColor", c);
}
}
Anyone can help me?
Thanks!
untitled.png
(118.7 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612051504im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
script that allow me to do this 0 Answers
GameObject.Find not finding game objects in the scene? 2 Answers
Script Compile Errors 1 Answer
Spawn A prefab after death 3 Answers
Player Respawn Script 5 Answers