Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Problems adding scenes into lists or arrays

Discussion in 'Scripting' started by Nostradamuzzz, Sep 25, 2022.

  1. Nostradamuzzz


    Jan 19, 2022
    Hi everyone.

    Ive been trying to create a game where the player has a list of scenes to go through before ending a run and later starting a new one.
    Imagine them as Scene1, Scene2, etc. Which are all part of the build.

    The problem I've been having is how to:

    1. Create Lists with specific scenes (example: DesertScenesList) that Ive previously selected (all desert scenes (Desert1Scene, Desert2Scene, etc ) an example) to organize gameplay.

    2. Add Scenes to a new list (NewRunList), during RunTime, that pulls from the Scenemanager using its methods and adds a specific (or radom) scene to it from those previosuly created lists (DesertScenesList).

    3. Loading a scene from the new list (NewRunList)

    Any Idea how to do something like this? I understand the Load methods I have to use later but Ive been going back and forth with this for weeks and havent had any breakthoughs.

    I'd appreciate any insights you may give me

    Thank you
  2. Brathnann


    Aug 12, 2014
    I'm not really sure what you are trying to accomplish, but scenes can be loaded by their name, so you could just have a string list that holds the names of the scenes.
  3. Nostradamuzzz


    Jan 19, 2022
    Thank you for the quick reply. Could you provide an example on how to implement it?

    What I am trying to accomplish is a game where the player has to go through a list of very short levels (for example) and the way the player solves those levels adds other levels of that same type to the list.

    For example:
    • A List of 10 levels to accomplish in one run (a game loop that the player will repeat). The NewRunList includes (DesertLevel 1, WaterLevel1, GrassLevel1, etc..)
    • The player starts the run (of 10 levels) and one is drawn randomly from NewRunList. The player completes that level and then passes to the next one that is also randomly selected from the levels that have not yet been completed of the NewRunList.
    • Everytime a player completes a level (DesertLevel1 for example) based on how many coins (for example) he has collected a new level is added to the NewRunList (DesertLevel2 for example) from a previously created list that includes all of the DesertTypeLevels.
    Strings might be an approach but Im still unsure how to implement it.
  4. Kurt-Dekker


    Mar 16, 2013
    Which part of:

    - string collections
    - choosing randomly from a collection
    - scene loading

    Are you struggling with?? There are literally thousands of tutorials and examples out there for all of these things.

    EDIT: is this still the same question from here?!

    Just put your game gently aside and get familiar with collections... that's less than an afternoon of learning, not months and months.

    Additive scene loading is another possible solution:

    A multi-scene loader thingy:

    My typical Scene Loader:

    Other notes on additive scene loading:

    Timing of scene loading:

    Also, if something exists only in one scene, DO NOT MAKE A PREFAB out of it. It's a waste of time and needlessly splits your work between two files, the prefab and the scene, leading to many possible errors and edge cases.

    Two similar examples of checking if everything is ready to go:
  5. Nostradamuzzz


    Jan 19, 2022
    I have changed how I approached the problem that I posted in the other thread, that is why I decided to open a new one.
    I am also learning as I go and thought it best to ask here.
    I will check the links you have provided.