Loading levels at runtime

I want to create the core game then load levels over the internet as needed once the player chooses to play a particular level from a list of available levels.

The most important thing is that the player be able to use new items introduced into the game at later levels for in future game play (including replaying old levels as well as playing new levels). For example, in level 10 of a first person shooter the player gets a new weapon (that was first introduced into the game at level 10 and was not previously available before level 10) then being able to go back and replay level 3 using the new weapon gained in level 10.

How would I go about doing this?

Is there anything in the asset store that would help do this?


Hi Jason!

I don’t think you would need something from the asset store but I’m sure something would be available that would have a lot of build in options.

Check out PlayerPrefs

You can use PlayerPrefs to persistently save data on your user’s machine so when they close down and start up the game their progress will be saved, and then this could be used with your needs for your items.

So let’s say your player beats level 10 and gets the ‘stargun’. You could use this piece of code:

PlayerPrefs.SetInt("Has Gun", 10);

At this point the gun should be in your players hands and going back to level 3 shouldn’t be a problem right?

Also with this, when you start up your game you could use the HasKey function of PlayerPrefs to check to see what the value is and fill your inventory accordingly. Or on a level by level basis, when you start up level 3 you could check for the key and add the item to your inventory there.