suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 11 forks source link

Map switching error #2479

Closed CLAXES closed 1 month ago

CLAXES commented 1 month ago

Hello, I get this error when I switch between maps in version 1.88e

image

Niinra commented 1 month ago

I hope you don't take it the wrong way, but I think you should first find out what the Unity addressable package is for, and you'll realize why it's giving you that error.

In summary, there you are getting the null reference because you need the reference to the area damage entity and the reference thing is now for the package that I mentioned to you

Niinra commented 1 month ago

I don't know if you imported it first but if you have the package you will notice that your prefabs have this checkmark image and this is the reference of the prefab that is taking this is much more detailed that's why I tell you read about addressable

CLAXES commented 1 month ago

It gives an error when the map changes in the section below, should I add null control or do I need to make another setting?

    protected override void OnDestroy()
    {
        base.OnDestroy();
        Identity.onGetInstance.RemoveListener(OnGetInstance);
        _identity = null;
        _receivingDamageHitBoxes?.Clear();
        onDestroy?.RemoveAllListeners();
        onDestroy = null;
    }

When I do as below, it does not give an error, but I am not sure if I am doing it right

Identity?.onGetInstance?.RemoveListener(OnGetInstance);
insthync commented 1 month ago

Yes, you should do it

insthync commented 1 month ago

But better check null like this

if (Identity != null && Identity.onGetInstance != null)
    Identity.onGetInstance.RemoveListener(OnGetInstance);

Because Unity's object reference is suck