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

Feedback Instantiating Object keeps resetting the attributes

Discussion in 'Addressables' started by faolad, Jun 19, 2019.

  1. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    This only happens with objects I'm instantiating. I don't have any issues with the ones already in the scene. It happens in multiple scripts and in different objects/different scenes. No issue when hitting play(on Unity) only happens in Build.

    How can I solve this, is this a normal thing that might happen using addressables?
     
    Last edited: Jun 26, 2019
  2. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    So any clue on this? With this crucial issue, I can't see why this system is viable.
     
  3. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    I got new info, after experimenting a bit. If I put them in Resources the issue goes away. But well that's not the place we want the prefabs.
     
  4. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    Okay so finally I solve it. Apparently having references to prefabs in a scene with or without using them cause some issues with addressables resulting in some attributes to reset to default type value.
     
  5. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Can you elaborate? Is your scene addressable? What's in the scene at build time (the prefab?) when does the data get reset? On the first instantiate? Only not on the first instantiate?
    those sorts of details (and any others you can think of) would help us track this down.
     
  6. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    In a very simplistic way of describing it, I have this Enemy Spawner object on the scene. How it works is that you put some game objects in a list and it makes a pool with them. And every x time it will enable some random object.

    When I was migrating the project to use addressables. I didn't delete the public List<GameObject> instead I didn't use it at all but kept it, just in case I want to return to the old system without spending time populating manually those list on each level.

    I create another variable to put a string reference to the same addressable objects (to instantiate them the proper way). Apparently just by having those prefabs therein (the list of gameobjects) the system brokes and starts resetting the variables to default type (on the new objects I instantiate using the string reference), no matter what script it was happening in all of them.

    The scene is addressable. The prefab is not in the scene at build time. But is on a public List<GameObject> variable.
    The data get reset when you instantiate the GameObject, not only the first time but every time you do it.
     
  7. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Got it. We've seen some other issues like this. Scenes that have direct references to prefabs that are also addressable. Something is going weird with that. We're looking into it.
     
    faolad and stefankohl like this.