Quantcast
Viewing all articles
Browse latest Browse all 131

Add a extension method to the class Application

I would like to create a extension method call ReloadLevel() for the class Application. I tried this: public static void ReloadLevel(this Application app){ app.LoadLevel(app.loadedLevel); } It gives me an error(which doesn't suprise me): Static member `UnityEngine.Application.loadedLevel' cannot be accessed with an instance reference, qualify it with a type name instead I tried it with this: public static void ReloadLevel(this Application app){ Application.LoadLevel (Application.loadedLevel); } But when I call the method with Application.ReloadLevel(), it gives me a error again: `UnityEngine.Application' does not contain a definition for 'ReloadLevel'` What am I doing wrong?

Viewing all articles
Browse latest Browse all 131

Trending Articles