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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

the dif between LoadSceneMode.Additive and LoadSceneMode.Single

Discussion in 'Scripting' started by raidest45, Apr 13, 2020.

  1. raidest45

    raidest45

    Joined:
    Apr 12, 2020
    Posts:
    8
    Code (CSharp):
    1. LoadSceneMode.Additive
    2. LoadSceneMode.Single
    can someone explain to me what's the difference between them ?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi and welcome @raidest45,

    Single replaces the current level you have loaded, but if you use additive, it loads the new scene and leaves your current scene loaded too.
     
  3. raidest45

    raidest45

    Joined:
    Apr 12, 2020
    Posts:
    8
    thnxx sooo much one more thing please ,
    look at my code and when i die the sceen didn't want start again
    Code (CSharp):
    1. public class OnPlayerDie : MonoBehaviour
    2. {
    3.  
    4.     void Start()
    5.     {
    6.        
    7.     }
    8.  
    9.  
    10.     void Update()
    11.     {
    12.        
    13.     }
    14.     void OnTriggerEnter2D(Collider2D other)
    15.     {
    16.          if (other.gameObject.tag == "playerKiller")
    17.         {
    18.             Destroy(gameObject);
    19.             GameObject go = new GameObject("nextLVL");
    20.             nextLVL script = go.AddComponent<nextLVL>();
    21.             script.LVLname = Application.loadedLevelName;
    22.         }
    23.        
    24.     }
    25.  
    26. }
    27.  
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    c_koenig likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    This ^^

    Single is pretty easy to understand, but additive is very useful to avoid duplicating work between scenes. Lets say you have a game with 5 levels with different terrain and enemy placements but overall the same gameplay. You can create a different scene for each level and load as Single, but you will be duplicating your UI objects and anything else common in your game across all these scenes. Then it becomes a nightmare to make a change to one of those objects, because you then have to duplicate that change to all the other levels.

    Instead you create your objects common to all your levels in its own scene, separate from the what changes between levels. You load that common scene, then additive load the individual level scene.
     
    c_koenig and fjc like this.