-----------
When a script property is pointed at a reference in the editor, the target reference will be flagged as "permanently persistent". In other words, nothing you do during runtime will unload the object. This means that, if possible, you should not use properties to point at references directly. If you can, pull references in from events or other locations to avoid permanently keeping them around. Even if you reassign a value to your property while the game is running, the original reference will stick around.
So to me, that says, never do this:
ObjectReference Property TempRef AutoBecause it's a temporary reference that I will not need later, I should not do that, because it will retain his reference forever, regardless of what I do.
However, the wording isn't completely clear on what flags the property as "permanently persistent".
Situation A:
ObjectReference Property TempRef Auto ; Ref is initially set to a specific reference through the CK properties menuIn the above code, the script declares a temp property. I set this property in the CK property menu to be a specific objectreference. In this situation, I am aware that the reference will be persistent forever. Even if I replace the original reference.
So what if I do this?
ObjectReference Property TempRef AutoTempRef = NewTempRef1TempRef = NewTempRef2TempRef = NewTempRef1 ; Does the NewTempRef2 ref properly die, or is it now permanently persistent as well?TempRef = None ; Are both references still permanent? Or is only the first one (TempRef1) permanent? Once I clear the second ref, is it still permanent, or is it properly cleared?
Situation B:
ObjectReference Property TempRef Auto ; Ref is NOT initially set to a specific reference through the CK properties menu
In the above code, the script declares a temp property. I do NOT set this property in the CK property menu to be a specific objectreference. That is to say, TempRef initializes to None. In this situation, I am not sure what happens.
What happens if I do this?
ObjectReference Property TempRef AutoTempRef = NewTempRef1TempRef = NewTempRef2TempRef = None ; Are both references cleared? Or are they both permanent? Or, is the first one permanent simply because it was the first thing plugged into it?
Situation C:
What if, instead, I do this?
ReferenceAlias Property TempRefAlias AutoTempRefAlias.ForceRefTo(TempRef)DoStuffToAlias()TempRefAlias.Clear() ; Is TempRef persistent? Will any future Refs placed into TempRefAlias become permanently persistent?
In the above situation, I set the "ReferenceAlias" in my target quest to initialize with a specific reference loaded into it. Is that alias permanent forever, even if I dispose of it? And what about the refs that replace the original alias?
Situation D:
What if, instead, I do this?
ReferenceAlias Property TempRefAlias AutoTempRefAlias.ForceRefTo(TempRef)DoStuffToAlias()TempRefAlias.Clear() ; Is TempRef persistent? Will any future Refs placed into TempRefAlias become permanently persistent?
In the above situation, I do NOT set the ReferenceAlias to initialize with an objectreference.
When using referencealiases, the alias should always be persistent within the script, however, because that variable points to a "container" rather than a specific reference, I feel as though the property persistence rule does not really affect anything major when using this technique. As long as you ensure you clear the alias when you are done with it, there shouldn't be any issues...
Honestly, My main concern is Situation D, but If possible, I'd prefer answers to the other situations as well to better help me understand properties.
I have a quest that controls most of my scripted functions. This quest will never stop running once started, and contains a good 5 or 6 aliases as properties within the quest. The aliases start empty, and I fill them (and clear them) as needed. I am constantly swapping out the refs held within the aliases with seemingly random object references, and I want to ensure that this isn't going to cause any issues.
Is anyone able to confirm this for me?