Question by
ttham · Oct 04, 2016 at 11:05 PM ·
c#scripting beginnerscript errorlights
Can't change light colour.
using UnityEngine;
using System.Collections;
public class switchlight : MonoBehaviour {
public GameObject mySwich;
public Light mylight;
public GameObject EmSourse;
public Color LightColour;
private float EmStregh;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
EmStregh = 30.0F;
EmSourse.GetComponent<Renderer> ().material.color = LightColour;
EmSourse.GetComponent<Renderer> ().material.SetColor("_EmissionColor", LightColour * EmStregh);
mylight.light.color = new Color(LightColour);
mySwich.transform.Rotate (new Vector3(0,2,0));
}
}
Problem with this part mylight.light.color = new Color(LightColour); "color" word is red and i get an error "dose not contain constructor that takes '1' arguments"
mylight.light.color = new Color(LightColour);
What am i dooing wrong here? Thank You!
Comment
Answer by JedBeryll · Oct 05, 2016 at 06:05 AM
You have to assign it the same way as you did here:
EmSourse.GetComponent<Renderer> ().material.color = LightColour;
Your answer
Follow this Question
Related Questions
Having trouble deleting objects from a list after they reach a certain scale. 0 Answers
Help with Script 0 Answers
Beginner needs Help! 1 Answer
How do you make your player jump in the Roll-a-Ball tutorial series? 0 Answers
How would I use other.gameobject like I've seen in collider scripts? to work in my camera script 0 Answers