Search Unity

About the GUI and the API

Discussion in 'Addressables' started by laurentlavigne, Jul 10, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,362
    Great system, thanks for making this available so early.
    Is the purpose to replace the current asset system or just to provide more control over asset loading and memory?
    I think that in both cases it could be made less intrusive for those who are casual about asset management.
    For example, are user defined addresses better than some kind of internal address and overriding the existing reference system that's already in place?
    I mean a reference to an addressable would be done like this:
    Code (CSharp):
    1. [Addressable] public GameObject ifWhatsDroppedInTheInspectorIsAnAddressableThenItWontBeIncludedInTheBuild;
    Ideally I'd prefer not to change a̶n̶y̶ much code to use that magic and if I ever want tighter control over loading or releasing then I use the addressable only API.
    For example:
    Instantiate (Gameobject) would load the Addressable on the spot ... well... I know that over the internet on the spot would take a few seconds, so it's ok, make Insitantiate Yieldable (someone will tell me it's bad C# but ... if it works, is concise, clear and easier to use, isn't it better?)
    Code (CSharp):
    1. yield return Instantiate(object source, Vector3 position ... out object destination)
    Needs to be in a coroutine... oh well, that's just an idea to make all this more streamlined, I'm sure there is better ways.
    Likewise, Release(Texture2D) would release the memory if that texture is an addressable, do nothing otherwise (with an info message for debugging). So most of the work is done for us.

    And since addressables' address is internal and automatic, referencing one in the inspector is like referencing an asset.
    And no drag and drop on a menu please :D
     
    Last edited: Jul 11, 2018
  2. PaulBurslem

    PaulBurslem

    Unity Technologies

    Joined:
    Oct 7, 2016
    Posts:
    79
    Instantiate does return an IAsyncOperation, which is yieldable.
    Using an attribute to mark actual GameObject references as a weak ref would theoretically be possible with some mono back end magic and changes to the engine, but would break the asynchronous nature of Addressables.
     
    M_R likes this.