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. Dismiss Notice

Which better approach?

Discussion in 'Prefabs' started by ScottPeal, Feb 9, 2021.

  1. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Goal: To reduce asset storage costs and internet transport costs

    Scenario: We have say 1000 objects that share the exact same mesh (-1,700 triangles), the same uv map, same normal map and texture, same metalness map and texture. The only difference is the diffuse textures are all different. The diffuse textures can be changed by an agency outside the dev team and objects added after publishing game. The scene is procedurally generated using a single prefab with a goal to stream the diffuse textures only to the client. Gamer can see any say 200 separate objects at a time.

    Question: Can we just publish the textures only and apply them to a material of a prefab procedurally at run time to reduce bandwidth in order to stream? Or do we have to stream a different complete object prefab for each object.

    Thanks for the input and help.
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    You can use AssetBundles or Addressables to load dynamic content from a server. In that case you would deploy the player with the prefab and then only load AssetBundles that contain the texture(s) and assign them at runtime. You can also host the prefab only and swap it out if needed. The player will only ever download one copy and cache it.

    Or what kind of streaming do you mean? If it's custom streaming, you have full control and the same applies, you only have to send the prefab once, and can assign textures dynamically.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    If you want this to be fast, you could look into Texture2D.CreateExternalTexture. You could probably just send the bytes for the texture format that matches the target platform, store it in memory, pass a pointer to CreateExternalTexture, and be done with it.
     
  4. ScottPeal

    ScottPeal

    Joined:
    Jan 14, 2013
    Posts:
    61
    Wow, both posts are great feedback. Thanks!