Reputation: 19260
I have a library made for Unity that needs to run some codes at Application's onCreate (Its callback interface must be added at application creation). The code must be entered by user's who are going to use my library.
My question is: Is it possible to run the user's C# code at the Application's oncreate?
Consider this code:
public class MyApplication extends android.app.Application {
@Override
public void onCreate() {
MyLibrary.setCallBack(new Callback {
@Override
void onSuccess() {
// Here some code must be entered by user
// Since library is for Unity it should be a c# code that user has written
}
});
}
}
How can user add c# code that can be entered there when app starts?
Thanks in advance.
Upvotes: 1
Views: 452
Reputation: 5035
As a short answer, no.
The whole Unity Engine needs to be up and running for any code using UnityEngine namespace (that is pretty much all unity code) to be functional. Unity needs to set up the context, allocate memory, get the Mono running etc, before the first line of code from the user gets executed.
In normal circumstances this is appropriate, maybe you can allow callback exchange at a later point of the application lifetime?
Upvotes: 1