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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

blobassetstore native collection disposal

Discussion in 'Entity Component System' started by andynayrb, Jan 20, 2020.

  1. andynayrb

    andynayrb

    Joined:
    Feb 28, 2019
    Posts:
    25
    So I have a class where I instanciate some prefabs in a class at startup. This line is causing errors, it is in the start function of the class.


    var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore());



    I know I need to dispose of the blobassetstore/native collection, but I am not sure how or where to do it. I tried several different places but none seemed to take care of it. Do I need to declare it differently?

    I think this issue is causing another issue. I later during run-time try to instanciate a bullet prefab but all it does it instansiate another floor tile from the above class. And I get an index out of range error. I hope that makes sense..
     
    BigRookGames likes this.
  2. andynayrb

    andynayrb

    Joined:
    Feb 28, 2019
    Posts:
    25
    Fixed it. I moved the declaration outside of the start() function of the class
    private GameObjectConversionSettings settings;


    Then I was able to add the following:


    void OnDestroy()
    {
    settings.BlobAssetStore.Dispose();
    }


    Problem solved.
     
  3. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    207
    Thanks! :)