#Order of Execution Issue in Editor Mode

1 messages · Page 1 of 1 (latest)

fickle arrow
#

kay I need some help in terms of why Unity is Updating so oddly

 public class LoadAllQs : ScriptableObject
    {
        public static Action OnLoadAllQuestions;

        private void LoadAllQuestions()
        => questionSOs = Resources.LoadAll<QuestionSO>(folder).ToList();
        private void OnEnable()
        => OnLoadAllQuestions += LoadAllQuestions;
    }

I've this static Action, that gets called whenever a
new QuestionSO gets created:`

public class QuestionSO : ScriptableObject
{
    private void OnEnable()
    => LoadAllQs.OnLoadAllQuestions();

    private void OnDestroy()
    => LoadAllQs.OnLoadAllQuestions();
}

But it updates in a weird way. When I create the first SO, it doesn't update, but when I create the 2nd or 3rd, it does

faint remnant
#

Can AssetPostprocessor do what you want? 🤔

fickle arrow
#

Uhm

errant field
#

read the docs for it

fickle arrow
#

Damnit

#

I'll

faint remnant
fickle arrow
faint remnant
#

Yeah in editor folder/asmdef

fickle arrow
#

Do any of the C# timer things work in edit mode?

#

If it does, that'll probably be easier?

faint remnant
#

Hmm I wouldn't want to rely on timer but you can try

fickle arrow
#

Hmmmmmmmmmmmmm

#

Still doesn't work

#

Tried doing it on didDomainReload

#

But probably doesn’t get called at the right time

faint remnant
#

Is it getting called?

#

I'm thinking maybe your delegate is not getting registered 😄

fickle arrow
faint remnant
#

Hmmmm that's weird

#

So Resources.LoadAll gives you empty list?

fickle arrow
#

No, it's just the wrong order of execution

#

So if I add one, it doesn't add one

#

But if I add another one, it adds the previous one

#

I think the domain reloading only happens when scripts change

#

When it has to recompile

#

Which isn't exactly what I'm looking for

faint remnant
#

Domain reloading? Yeah domain reloading will reset your event, that'd be another problem

#

Hmm you might eventually have to use AssetDatabase.LoadAssetAtPath etc...

fickle arrow
#

hmmm it seems to load now actually

#

I did this

faint remnant
#

ah you checked the flag

#

I didn't see code that closely 😂

#

Well yes that works, if you want it to run only when specific asset imported you'd need to check type 😌 , but whatever works for you

fickle arrow
#

I'm happy that it works kek

#

This works nicely :)

faint remnant
#

It will be called when you change any asset just to be clear 😄

fickle arrow
#

Yeah I am aware and that's really inefficient but I don't care XD

#

Been at this for waaay to long I'm just happy it works XD

faint remnant
#

Nice 😄 Glad it works. Good luck with your project!