Created
August 22, 2019 01:46
-
-
Save edwios/c0e740521aae055461302fd052d175a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
public class changecolor : MonoBehaviour | |
{ | |
public Color[] colors; | |
private Vector3 positionxyz; | |
public Color Rcolor; | |
void OnTriggerEnter(Collider other) | |
{ | |
Rcolor = colors[Random.Range(0, colors.Length)]; | |
gameObject.renderer.material.color = Rcolor; | |
positionxyz = transform.position; | |
GameObject lightC = new GameObject(); | |
lightC.name = "discolight"; | |
lightC.AddComponent<Light>(); | |
lightC.transform.position = positionxyz; | |
lightC.light.color = Rcolor; | |
lightC.light.range = 2.579712f; | |
lightC.light.intensity = 1; | |
lightC.light.renderMode = LightRenderMode.ForcePixel; | |
} | |
void OnTriggerExit(Collider other) | |
{ | |
Destroy(GameObject.Find("discolight")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment