- Home /
Sprite Color.Lerp
I don't know why this code is making my sprite disappear?
using UnityEngine;
using System.Collections;
public class ObetacleColor : MonoBehaviour {
private SpriteRenderer spriterenderer;
private float ltime = 0;
public float ltimespeed;
int count = 1;
public Color one;
public Color two;
public Color three;
// Use this for initialization
void Start () {
spriterenderer = GetComponent<SpriteRenderer>();
//Invoke("One", 1f);
}
void One(){
spriterenderer.color = Color.Lerp(one, two, ltime);
}
void Two (){
spriterenderer.color = Color.Lerp(two, three, ltime);
}
void Three (){
spriterenderer.color = Color.Lerp(three, one, ltime);
}
// Update is called once per frame
void Update () {
if (ltime < 1){
ltime += .01f / ltimespeed;
}
//spriterenderer.color = Color.Lerp(one, two, Mathf.PingPong( Time.time, 5));
if (ltime >= 1){
count++;
if (count == 1){
Invoke("One", 1f);
}
if (count == 2){
Invoke("Two", 1f);
}
if (count == 3){
Invoke("Three", 1f);
}
ltime = 0;
}
if (count == 4){
count = 1;
}
}
}
Comment