Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Enter Playmode Options Null Game Objects

Discussion in '2019.3 Beta' started by learc83, Nov 2, 2019.

  1. learc83

    learc83

    Joined:
    Feb 28, 2018
    Posts:
    41
    I have a Monobehavior that instantiates 10 children from prefabs on Start and stores them in a private variable called _buttons. It initializes a new array on start as well. Everything works fine when I reload the domain and scene. But when I enter playmode without reloading the domain and scene, I get an error about accessing already destroyed game objects.

    When I set a breakpoint at the end of the Start method, the array is being created and populated with correctly. However when I set a breakpoint in the method that uses the array, the array is full of null game objects. So it looks like somewhere between Start and Update something is happening to the array.
     
  2. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    Thanks for the feedback!
    Is this an Editor script (marked with ExecuteInEditMode/ExecuteAlways)?
    Does the issue persist when you enable scene reload?
    Are those objects by a chance use hideflags?
    Do you see the Start call in Playmode?