When NC creating a DynamicVar on running it always be a lag in iOS device and Mac Unity. It seems 0.1s delay.
So I have to avoid using DynamicVars and create many normal vars. So these blackboard will seems too long.
I have no idea about why it happen and how to fix. I think, if the creating lag cant be removed, maybe have some way to move these creating in the scene loading time.
Any idea?
If I am to guess, the lag spike happens only for the first Dynamic Variable added?
I’ve submited a new version to the asset store. Apart from the rest, in this version I’ve made an optimization for when creating dynamic variables. Also, the ‘Script Control’ tasks for the iOS is fixed. Thanks for the patience.
Please check the new version when it goes live and let me know if you still encounter any problems with the dynamic variables lag, or anything else.
If the problem still exists, I will make them created in scene loading time like you suggest.
Yes, it’s not online yet. If you want I can send it to you through email.
Let me know of an email to send it to.
If you don’t want to write your email in public here, send me an email at info@nodecanvas.com and I will reply with the new version.
Use dynamicvar will cause lag while creating. This still happened in latest version. The reason is maybe there is log while creating dynamic var. It prints with full stack. Is there official way to turn off it?
I found the problem in last versions of NodeCanvas. To fix the allocations with Dynamic Variables, please open up BBParameter.cs script and change the property ‘varRef’ at line #130 to this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
publicVariablevarRef{
get{return_varRef;}
set
{
if(_varRef!=value){
#if UNITY_EDITOR //this avoids lots of allocations when using Dynamic Variables
if(!Application.isPlaying){
if(_varRef!=null){
_varRef.onNameChanged-=OnRefNameChanged;//remove old one
}
if(value!=null){
value.onNameChanged+=OnRefNameChanged;//add new one
OnRefNameChanged(value.name);//update name immediately
}
targetVariableID=value!=null?value.ID:null;
}
#endif
_varRef=value;
Bind(value);
}
}
}
Then just a few lines later, please also change property ‘bb’ to this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
///The blackboard to read/write from. Setting this also sets the variable reference if found
publicIBlackboardbb{
get{return_bb;}
set
{
if(_bb!=value){
#if UNITY_EDITOR //avoid when using Dyanmic Variables