- Home /
Save color prefab
I have code to change color:
using UnityEngine;
using System.Collections;
public class ChangeColor : MonoBehaviour {
public Color myColor;
public Material BallMaterial;
void OnGUI ()
{
myColor = RGBSlider (new Rect (10, 425, 200, 20), myColor);
}
Color RGBSlider(Rect screenRect, Color rgb)
{
rgb.r = SliderTest.LabelSlider (screenRect, rgb.r, 1.0f, "Red");
screenRect.y += 20;
rgb.g = SliderTest.LabelSlider (screenRect, rgb.g, 1.0f, "Green");
screenRect.y += 20;
rgb.b = SliderTest.LabelSlider (screenRect, rgb.b, 1.0f, "Blue");
return rgb;
}
void Update() {
BallMaterial.color = myColor;
}
}
And how save color to prefab and next load in game ?
Comment
Do you want to change the prefab's color during runtime? You need to use SetDirty after making a change during runtime that should persist.
Your answer
Follow this Question
Related Questions
UI Text.color not assigning? 2 Answers
Renderer.material.color not changing color of prefab 3 Answers
Prefab Color Question 1 Answer
How to save prefab's color/texture ? 1 Answer