Quantcast
Channel: Questions in topic: "renderer.enabled"
Viewing all articles
Browse latest Browse all 99

The best methods for changing objects within a scene?

$
0
0
Hello, I've been looking into how to replace a GameObject with another GameObject. Allow me to explain: I have a SpringTree GameObject and a WinterTree GameObject. I already have a script that changes the season by using a String Variable currentSeason. Basically, I want my objects to change their appearance based on what season it is. If it is Spring, use spring objects, etc. I have tried several different methods, such as using the SetActive method, but it has not worked. Is there any other way to accomplish what I am looking for? Here was my last attempt that was based off another post I found. The script references another script that holds the value of the currentSeason. Any help is greatly appreciated! public GameObject sceneController; private SeasonController seasonControllerScript; public GameObject springObject; public GameObject winterObject; // Use this for initialization void Start () { seasonControllerScript = sceneController.GetComponent(); if (seasonControllerScript.currentSeason == "Spring") { springObject.SetActive(true); } else if (seasonControllerScript.currentSeason == "Winter") { winterObject.SetActive(true); } } // Update is called once per frame void Update () { if (seasonControllerScript.currentSeason == "Spring") { springObject.SetActive(true); winterObject.SetActive(false); } else if (seasonControllerScript.currentSeason == "Winter") { winterObject.SetActive(true); springObject.SetActive(false); } }

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>