- Home /
Question by
NovaDrox · Apr 20, 2017 at 01:39 AM ·
prefabprefabsreplaceprefab changing at runtime
How to update a prefab from a copy in the hierarchy
So, I have this basic cube with 2 buttons that change the color of the cube. I also have a prefab of the cube, but I don't know how to update the prefab with the cube in the hierarchy.
{ private GameObject Player;
private void Start()
{
Player = GameObject.Find("Player");
}
private void Update()
{
Player.transform.Rotate(0, 10 * Time.deltaTime, 0);
PlayerPrefs.Save();
}
public void ColorRed()
{
Player.GetComponent<Renderer>().material.color = Color.red;
}
public void ColorBlue()
{
Player.GetComponent<Renderer>().material.color = Color.blue;
}
public void BackToLoad()
{
SceneManager.LoadScene(1);
}
Comment
Your answer
Follow this Question
Related Questions
Prefabs won't change? 1 Answer
Reinitialize prefab 0 Answers
Unity Programmatically Link Prefab 2 Answers
Apply Changes to Prefab - Unity 2018 0 Answers
Prefabs spawn with wrong values 0 Answers