- Home /
Setting color information and passing it in scenes
I need to implement a setting page where the player can select the color of his choice and then use this on the gameobject.
public GameObject object1;
public GameObject object2;
public GameObject object3;
public GameObject object4;
public GameObject object5;
public GameObject object6;
public GameObject object7;
public GameObject object8;
public GameObject object9;
// Use this for initialization
void Start () {
object1.renderer.material.color = new Color (0.5f,0.5f,0.5f);
// object1.renderer.material.color.r = 100;
// object1.renderer.material.color.r = 100;
}
// Update is called once per frame
void Update () {
}
How can i generate the variables for color red ? i dont see any method which accepts three values for RGB from 0 to 255 ?
moreover what is the best or suitable way to pass the color information of color from one scene to another like saving the information from playerprefs and using it retrieving it from scene ?
atleast if i am able to get the numeric values of color then i can write some code to use it and change the color in next scene because the Playerprefs(setint) will do it for me.
Answer by Eric5h5 · Dec 07, 2014 at 06:16 AM
Color uses values from 0.0 - 1.0. Color32 uses values from 0 - 255. Use DontDestroyOnLoad with a script to store variables that survive scene changes. Also, instead of using many separate GameObject variables, use a GameObject[] array.
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Is it possiable to change the Emissive Color on VertexLit Blended Material with a script? 3 Answers
Why are there color differences between photoshop and Unity? 5 Answers
Change Color in C# with RGB Values? 4 Answers