Skip to content

Instantly share code, notes, and snippets.

@Mylab6
Last active August 16, 2022 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mylab6/58ec0239cfb3184cfcef349794368ac3 to your computer and use it in GitHub Desktop.
Save Mylab6/58ec0239cfb3184cfcef349794368ac3 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class ColorChange : MonoBehaviour{
public List<Color> colors ;
public int currentColor ;
public Renderer rend;
public bool eyeControl ;
void Awake() {
rend = GetComponent<Renderer> ();
}
void Update() {
if (Input.GetKeyDown(KeyCode.C) )
{
if(!eyeControl ){
nextColor();
}
}
if (Input.GetKeyDown(KeyCode.I) )
{
if( eyeControl ){
nextColor();
}
}
}
void nextColor () {
try{
rend.material.color = colors[currentColor];
currentColor++;
} catch (Exception e){
currentColor = 0 ;
}
//rend. colors[currentColor];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment