how to enable and disable gameobject for another scéne
hey guys i want enable and disable gameobject for another scene ex : if the player buy a new character disable the current character and enable the new character
Well that depends highly on your game. You could save it in a singleton object, a static variable, you could load character and level from independed scenes -> loading them additive to the current scene, ....
Answer by Jessespike · Dec 17, 2015 at 06:35 PM
As Soraphis pointed out, this can be done many ways. Here is how you could do it with static variable:
public class PersistantData
{
public static bool SwitchingCharacter = false;
}
Then in the scene, you'll need a script to check the variable and behave as you like:
void Start ()
{
if (PersistantData.SwitchingCharacter)
{
// TODO: enable and disable gameobjects
PersistantData.SwitchingCharacter = false; // reset condition
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612052922im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make a Particle System play when Player gets destroyed 0 Answers
cannot convert UnityEngine.GameObject to PlayerController 0 Answers
how to move a gameobject based on a dice roll 1 Answer
How do I find a player for AI to target when spawning a player in? 0 Answers
Need help with GameObject placement 2 Answers