Hi
Assumption: All action list access to a global variable that links to a custom script results in the variable beining synced prior to use. (IE gated by a OnDownload event). If this isnt the case skip to the bottom
Bug: When the Set Parameter action copies a global variable into a parameter, it will not always sync the global variable first.
Approx test case:
1. Create an integer global variable that links to a custom script and script sets initial value is checked.
2. Add a component to sync the global variable much like VariableLinkingExample.cs (confirming your GVar ID is correct, listen/respond to the OnDownload event, etc)
3. Create a Action List Asset
4. Add a Integer Parameter to the action list
5. Add Set Parameter action inside the action list asset, where
Expected: The BP is hit (ie the variable is synced and the OnDownload event is fired by AC))
Result: The BP is not hit (ie the variable is not synced; the last value is was synced to will be copied)
Suggested Fix: On ~line 218 of ActionParamSet.cs::GlobalVariables.GetVariable() pass true to synchronize
else if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
{
ActionParameter parameter = GetParameterWithID (parameters, globalVariableParameterID);
if (parameter != null && parameter.parameterType == ParameterType.GlobalVariable)
{
runtimeVariable = parameter.GetVariable ();
}
else
{
runtimeVariable = GlobalVariables.GetVariable (globalVariableID, true); // Dont use default parameter, explicitly set
}
}
This works in my simple test case, but no idea if its correct/safe.
Note:
Finally:
If this assumption isnt correct and AC dosent guarantee syncing og global variables before use, then I can make sure the GVar variable is manually set in code, but this is both a pain and (IMO) bug prone (but not complaining, this is still a very powerful system)
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You're correct on all fronts: OnDownload should be called, and that is the correct fix.
I'll apply this change to the next update, thanks for the breakdown.