Search code examples
c#unity-game-enginegameobjectunity-networking

How to load a Gameobject in Unity from a server maintaining its components and properties?


I'm working on a GameObject in Unity, what i want is that the GameObject should download from a server link maintaining all its references and components so that it should perform the way it is performing offline. The purpose of doing is that i want to reduce the application size hence giving user an option to whether download the gameobject or not.


Solution

  • You are probably looking for Prefabs, which will allow you to safe a gameobject with all references.

    Unity has a Prefab asset type that allows you to store a GameObject object complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. Any edits made to a prefab asset are immediately reflected in all instances produced from it but you can also override components and settings for each instance individually.

    These prefabs can be provided in AssetBundles from your server to easily re-integrate into your game

    AssetBundles have been designed to simplify downloading content to your application. They can contain any kind of Asset type recognized by Unity, as determined by the filename extension. If you want to include files with custom binary data, they should have the extension “.bytes”. Unity will import these files as TextAssets.