1

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.

2
  • You won't be able to type c# code in a java file. But there are other solutions to this problem. You can check out this URL: stackoverflow.com/questions/33779069/… Hope it helps Commented Mar 6, 2019 at 13:40
  • No. I guess there is a misunderstanding. By C# I mean the user's logic. Looks like it's not gonna happen. Commented Mar 6, 2019 at 14:08

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.