Search Unity

Scene in "Build Settings" or not

Discussion in 'Getting Started' started by romanpinkel, Sep 4, 2019.

  1. romanpinkel

    romanpinkel

    Joined:
    Sep 4, 2019
    Posts:
    20
    hey,
    I'm new to Unity (just saw some tutorials and made beginners stuff) and now I have my important Question:
    If I load a scene which isnt included in the build settings, I can create visible meshs via C#-code.
    If I add those scenes to the Build Settings (which alsways complains if the scene isnt added) and create the visible meshs, they instantly disappear from this scene. (Even no more objects available)
    Also if I create stuff in the Scene from the menu in the scene and the scene isnt in the Build Settings it disapperas on startup.
    Why is that so?
    Is there a way to crossover both sides and when yes, how? Can someone gimme a noob-supporting answer please?
    mfg RP
     
  2. Hm, I'm lost in the third sentence.

    Build Settings' scene list determinates which scenes will be added to your final build. If you do not add your scenes there, they won't be part of your game. It is simple like that. It does not have anything to do with the actual content of your scenes.
    If you have problems with your scenes, those have to be addressed. Do you have any concrete errors? Some code? (Using code tags if you submit some)
     
  3. romanpinkel

    romanpinkel

    Joined:
    Sep 4, 2019
    Posts:
    20
    ok, If I create Objects via the Unity enginge itself, they work properly if I include this scene in the Build settings:
    e.g.:
    Ground created UE.jpg

    If I'm using code tho create a Plane it looks like this, but only if I dont include in the Build settings. As soon as I Include it, the code generates this platform and it vanishes upon starting.
    Ground created Code.png

    Code (CSharp):
    1. SceneManager.LoadScene("NeueBaustelle", LoadSceneMode.Single);
    2.  
    3.             // Assigns a material named "Assets/Resources/Mat_Ground" to the object.
    4.             Material planeMat = Resources.Load("Mat_Ground", typeof(Material)) as Material;    
    5.  
    6. //This calls a function which creates a plane with width, length, collider on/off and a material/texture
    7. Create_Terrain_Helper.CreatePlane(X_length,Y_length,true,planeMat);
     
  4. I believe you're using this wrong. LoadScene does not execute right away. It runs after the end of the current frame.
    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
    Which also means you cannot use the new scene in your code right after the LoadScene.

    Move everything you load/generate for the new scene inside the new scene (Awake or Start as needed).
     
  5. romanpinkel

    romanpinkel

    Joined:
    Sep 4, 2019
    Posts:
    20
    thx, now it works as pretended.
     
  6. zoe31kimkim

    zoe31kimkim

    Joined:
    Jun 13, 2022
    Posts:
    1
    Hi its possible to run a scene even if there is not in the build settings?
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203