So… I can’t figure out why this fails.
On EventConstruct in my MainMenu, I Load Game from slot ->cast to my saved game → promote to variable. (this seems to work fine, however ***)
Next sequence, I cast to GI → Promote to variable to have it as a reference.
Inside the MainMenu widget I have a text box which I bound to a ref of the GI → target a string variable from GI and update the text box value. See images below:
As soon as the MainMenu loads I get the following error:
Blueprint Runtime Error: “Accessed None trying to read property GI_Ref”. Node: Return Node Graph: Get_userInput_Text Function: Get User Input Text Blueprint: UMG-MainMenu
Why is the GI_Ref empty???
I tried using the same variable from the SavedGame with the SavedConfig_Ref and it fails as well.
Funny thing is… that I have another bind that is using the SavedConfig_Ref for updating a text field… and that works without a problem.
What is going on here???
This works: (in the same MainMenu widget - another bind for updating a text field)
The other weird part is that the cast to MySavedConfig → Set SavedConfig works fine in 1 function bind, but if I try to reference it again in a 2nd bind it fails as well. (Only reason why I had to cast to GI and try to get the variables from there for the 2nd bind)
I believe with UMG bind functions, they are executing more or less on Tick, so perhaps there are a few frames after construction and before you are setting your variables where the bind function is attempting to reference it. If you just simply put an IsValid check before attempting to read from these object variables inside the Bind functions, do these errors appear and does your logic not work?
I fixed it by setting a local variable right after referencing it and then in the bind I read the values from the local variables. This seems to work.
Your explanation was exactly what I was thinking on, but it’s funny that a bind function inside the umg kicks in before the EventConstruct. I would’ve expected nothing to load until the event construct is finished. But alas, I guess some things kick in faster than other things finish loading.
That is indeed a mistery why that is not failing. Oh well, I got it to work by using local variables set on EventConstruct. But that’s why I was so dumbfounded. Why did the first bind work with 0 errors, and when I use the exact same ref on the 2nd bind it errors out?
Believe me, I tried it several times, switched my logic from the savedgame to gi. and in both cases, the 1st reference would work and the 2nd would fail. I tried using the first ref to savedgame and the 2nd to gi… thinking I’ll trick it and not use 2 refs of the same object in 2 binds. Still the 2nd one failed… drove me nuts.
Removed and recreated both binds like 5 times. same outcome
In the end, by setting up local vars on event construct works without an issue.
Would love if someone has an insight into this and explain it why