Last active
August 16, 2022 04:29
-
-
Save Mylab6/58ec0239cfb3184cfcef349794368ac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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