Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Are AssetBundles the right thing for my use-case?

Discussion in 'Editor & General Support' started by Fello123, Oct 23, 2016.

  1. Fello123

    Fello123

    Joined:
    Oct 7, 2016
    Posts:
    1
    Hi,

    in my game I plan to let players create their own levels / maps.
    Similar to Warcraft3 / Starcraft.

    There are two scenarios:

    Scenario 1:
    Simple Scenario
    A user wants to make their own level.
    They can re-use existing geometry from a level I already made,
    then populate the level (that is only static geometry initially when creating a new map).
    That way people can take an existing raw level (an existing level from the game that is missing all items, NPCs, ...) and populate it how they like, using all the NPCs, items, and all sorts of dynamic objects (prefabs) the game contains already.
    People can create modifications of existing levels ingame and let the game save those changes as a custom map.

    I handle all the serialization and saving,
    Obviously this is the most simple case.
    There is no need for crazy things like AssetBundles or anything similar so far.​

    Scenario 2: Advanced Scenario
    I want people to be able to add their own assets to the maps they create.
    Example:
    Someone wants to make their own map completely from scratch.
    Now they have to use unity to create their own AssetBundle (or multiple?).
    I'm fine with that since I don't want to manage loading complex things like textures, sounds or even models myself.
    I'd rather let unity handle all the conversion, texture compression, ...
    I will provide them with some scripts and tools to make this part as simple as possible for them.​


    In order for the game to load a map, it has to load a scene that contains all static geometry (a scene).
    This part will be done by loading the AssetBundle(s) the user has created.

    The game also has to populate the game world with all sorts of dynamic objects: enemies, NPCs, items, ...

    Users can only place predefined prefabs that I make available to them into the scene, for example EnemySpawner, Item, TriggerZone, ...
    That is to make sure the map is compatible with the game.

    Map Creation:
    Here is how I imagine the workflow will be for users who wish to create their own map:
    1.) They create a new unity project and import my custom extensions (a free download from the unity AssetStore). They can then create their own level geometry and place the prefabs I make available for them.​

    2.) Once they are happy with the map they made, they can click some button in an EditorWindow I created to export the level.
    That happens in two parts:
    a) First only static GameObjects are saved into a scene that will be built into an AssetBundle - that will be the static level geometry.
    b) Then my editor extensions scan their scene for all the game-related prefabs and serialize them into a custom map format.​

    Post Processing:
    When all that is done the user is left with two new files. The assetbundle that contains all the assets they added to the game as well as the map they made, and the additional file that contains all information about things like npc placement, items, triggers, ...

    Those two files are then packed into one single big file that represents the whole map.
    This map can be shared with other players who can then play it.

    The game just opens the assetbundle inside to load the level, and then populates it with all the things that have been placed by the user who made the level.


    My questions:
    1. Will this work without any major problems?
    2. Can people just create AssetBundles and share them with each other? Or are there some pitfalls like AssetBundles being incompatible depending on who made them? (I am only aware of the target platform being important).
    3. What about licensing issues? Will my players need anything more than the free version of unity?
    4. Can AssetBundles be loaded from a System.IO.Stream? Or must they be unpacked to a file on disk?
    5. I know that AssetBundles do not support script files (and thats a good thing!), but is there any way that a hacker could maybe include some malicious code in an AssetBundle?
    6. Is this a good idea, or is there some much easier way that I did not think of?

    It would be great if a dev could take a look at this and give some official answers to my questions as well as their opinion about this whole idea.