#sure

1 messages · Page 1 of 1 (latest)

torpid quest
#

Action debugging

twin steppe
#

okay soo

#

back to the beggining xD

#

you are subscribing to the event

torpid quest
#

i think, if the function isnt getting ran, then the action isnt getting fired?

#

Invoke

twin steppe
#

the event is getting called no matter of the listeners

torpid quest
#

i know the function containing the invoke is ran

torpid quest
twin steppe
#

so to sum up because im kinda lost right now

#

you are subscribing to the event in OnAwake

#

which you call in Awake

torpid quest
#

SaveDataLoaded?.Invoke(saveData);

#

its ? internal null check

#

let me remove that and see if i get an error

twin steppe
#

yea was about to suggest that

torpid quest
#

yep, i get an NRE on that line

twin steppe
#

okay then

#

it looks like there are none subscribers

torpid quest
#

I spawn my player at runtime, and the subscribers are on the player

twin steppe
#

log the listeners amount

#

after subscribing

torpid quest
#

How do i do that?

twin steppe
#

let me think

torpid quest
#

we've narrowed it down to a race condition though for sure

#

im 99% confident

#

perhaps i should turn

    public void LoadSaveData(ref PlayerSaveData saveData)
    {
        if (File.Exists(gameSavePath))
        {
            if (EnableEncryption)
            {
                string plainJsonText = EncrptionSerializer.DecryptTextFromFile(gameSavePath);
                saveData = JsonUtility.FromJson<PlayerSaveData>(plainJsonText);
            }
            else
            {
                saveData = JsonUtility.FromJson<PlayerSaveData>(File.ReadAllText(gameSavePath));
            }

            // invoke delegate to notify subscribers that saveData has changed
            SaveDataLoaded.Invoke(saveData);
            Debug.Log("Load Save is ran.");
        }
    }``` this isnt a coroutine and `WaitUntil` there is a subscriber?
#

if thats possible

twin steppe
#

i mean that might work

#

but idk how to check if there is any subscriber

#

idk if you can??

torpid quest
#

google suggests i just check if its null or not

twin steppe
#

aight try it then

#

wait until it is not null

torpid quest
#

ok i cant do it

#

typical bullshit

twin steppe
#

gosh

#

do you need the ref tho?

torpid quest
#

I'll have to make a seperate coroutine

#

i do

twin steppe
#

arent classes reference type

#

its not value type

#

the workaround could be

torpid quest
#

i cant even seperate it out i just thought, since i'd still need to pass ref to it

twin steppe
#

make a coroutine that waits untill the subscrber then calkl the LoadSaveData

#

ping me if you solved it

torpid quest
#

@twin steppe Looks like its working, I have many more issues now though so need to fix those before verifying