hello.
before i start;
-using visual studio to write code
-
writing codes in c#
-
using unity to develope games/apps
so i was working on a project. using unity 4.++
then i decided to upgrade to 2019 version.(am using free version)
in the previous version … my games are able to run without any issue;
after upgrading… when i tried to run my game(in editor) i got some error. after checking i found out that
some codes are being executed rather slow. i will explain what i mean.
code example;
public class AAA : scriptableobject
public string name;
public string d;
public string f;
public string j;
public string g;
etc..
prefab
public class BBB : monobehaviours // this is attached to prefab
public string name;
private string b;
private string c;
private string d;
public void setup( AAA aaa)
{
name = aaa.name;
b = aaa.d;
etc etc
/// just assigning value to the variables above from AAA
}
public class CCC : monobehaviour
list<AAA> object = new list<AAA>() { about 100 items in here };
void start()
{
foreach (AAA aaa in object)
{
var newobject = (instantiate prefab , here i use resourcesload)
newobject.GetComponent<BBB>().setup(aaa);
// im using debuglog to show the error just as example
Debug.log(newobject.getcomponent<BBB>().name);
*****where error null reference exception occur
}
}
so, i have come to conclusion that the error are caused by lags in code execution because the error
are not constant. sometimes after 10 loops, sometimes 11, sometimes 7 etc and also
tried the exact code (if i may, the whole game scripts) on both version of unity, only the 2019 gives the error
my questions now are;
-
is there some kind of settings in 2019 versions that might have caused this? or
-
if its a bug, is there anyway to fix
thank you:)