Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How can I disable GameObjects in other scene?

Discussion in '2D' started by gladiuscloud, Feb 24, 2015.

  1. gladiuscloud

    gladiuscloud

    Joined:
    Jan 11, 2015
    Posts:
    44
    Code (CSharp):
    1. //Say example, I'm working in mainMenu scene
    2. //and would like to disable gameObject in other scene. Code example below.
    3. public class SoundControls : MonoBehaviour {
    4. void Start () {
    5. //find the gameObject in other scene
    6. gameSoundEffectsObj = GameObject.Find("soundEffects");
    7. //disable it
    8. gameSoundEffectsObj.SetActive(false);
    9.   }
    10. }  
     
  2. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    You cannot, since you can only have one scene open/active at the same time. If you are using LoadLevelAdditive, Unity still sees everything as one scene.
    What are you trying to accomplish? Setting things up before you load a scene, or?
     
  3. abdullah786

    abdullah786

    Joined:
    Feb 24, 2015
    Posts:
    2
    You cannot, since you can only have one scene open/active at the same time. If you are using LoadLevelAdditive, Unity still sees everything as one scene.
     
  4. gladiuscloud

    gladiuscloud

    Joined:
    Jan 11, 2015
    Posts:
    44
    Yes, I'm trying to have enable and disable option sound under my mainMenu scene. The bgSounds and sound effects are located in gamePlay scene.
     
  5. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    548
    Put all these options and bg music under one single Object and use dontdestroyonload to keep it active through out your scenes. That way all the options stay :)