unity3d - unity C# run method from another class -


i want run metod in class class , both of them atached different obj

two classes. first is:

public class newscore: monobehaviour { public void updatescoreby( int intr) {     debug.log("intr+4"+intr+4); } } 

and second is:

public class newplus: monobehaviour {     public newscore newscore; public void ontriggerenter2d(collider2d obj) {     newscore.updatescoreby(+1); } } 

when run code recive arror "nullreferenceexception: object reference not set instance of object" , points on newscore.updatescoreby(+1); how can fix it?

depending on want make function static like:

public static void updatescoreby(int intr) {     debug.log("intr+4"+intr+4); } 

and call with:

newscore.updatescoreby(1); 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -