Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

one among my gamers all the time, constantly get a NullReferenceException in a “shall be destroyed” behaviour. No different report have been despatched (they’re computerized). Solely from that system and I could not reproduce it.

My idea is that it is concerning some misterious behaviour of the rubbish gollector and Unity’s Destroy mechanism. (by the way in which I take advantage of IL2CPP)

Here is the setup:

  • All UI_TownLabels (MonoBehaviour desc.) reference a TownHallBehaviour. (MonoBehaviour desc.)

  • All TownHallBehaviour reference Tile (pure C#) object.

  • A Tile object holds references with something concerning that Tile, together with MonoBehaviour descendants, like TileBehaviour.

Here is the case:

  • When the person clicks on a button to finish the sport, a tween impact is began.

  • When it is completed, I destroy all TileBehaviours‘ gameObject, and all UI_TownLabels‘ gameObject.

  • Earlier than being destroyed, UI_TownLabel’s LateUpdate remains to be known as accurately, as a result of Destroy is efficient after the tip of the present body.

  • Nonetheless right here when it tries to get its TownHallBehaviour’s Tile’s TileBehaviour’s Rework’s Place, there’s a NullReferenceException.

Surprisingly evidently the TownHallBehaviour, the Tile, and the TileBehaviour are all NOT null. Solely the rework of the TileBehaviour. At the very least that is what suspect as a result of the exception comes from Tile.get_Position()

Here is what’s within the Label’s LateUpdate: var targetPosition = TownHallBehaviour.Tile.Place;

Here is a snippet from Tile:

public class Tile : TileBase
{
        personal readonly TileBehaviour tileBehaviour;

        public Tile(TileBehaviour tileBehaviour)
        {
            this.tileBehaviour = tileBehaviour;
        }

        public Vector3 Place
        {
            get { return Rework.place; }
        }

        public Rework Rework
        {
            get { return tileBehaviour.rework; }
        }
}

(I assumed for a time that possibly this LateUpdate is within the subsequent body… and there’s a Label within the scene which is not within the Label assortment thus would not get destroyed…

… however the code for that’s easy, it seems to be good. And even when it might be the case, there should could be different gamers affected, or at the least it should not happen all the time for this person. Proper?)

Thanks upfront for all the assistance!

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *