- Home /
Problem getting prefab color
I want to get the color of a prefab.
So I wrote this:
using UnityEngine; using System.Collections;
public class Test : MonoBehaviour {
public GameObject prefab;
void Update () {
Color color = prefab.renderer.material.color;
print(color);
}
}
I attached this script to a gameObject in the scene and draged and droped a prefab with material on it on the "prefab" member variable in inspector.
Then I hit run i works, nice.
Then I hit stop. And my prefab material is gone, I must attach my material again everytime, I dont want that.
What am i doing wrong here? Is this a bug in Unity?
Thanks...
Comment