2

I am working on UnityPlayerActivity in which camera is rendering on complete screen on top of which, having my Toolbar and Navigation drawer. So I am facing following issues as

Case A : Used android:fitsSystemWindows="false" Shows navigation drawer but not as expected as height of drawer is not showing fullscreen. But android navigation bar is transparent, camera is taking complete screen as expected.

Case B : Used android:fitsSystemWindows="true" Shows navigation drawer as expected and drawer height is showing fullscreen. But android navigation bar is not transparent, so camera is not taking complete screen as expected.

CASE A CASE B This is my layout file

1 Answer 1

0

It is not necessary that you have to be bound with Unityplayer activity or mainActivity.

You can make any activity static and call the function or UI present in those activities from c# unity.

The correct methodology is to create a static Activity in your main Android project and call it currentActivity. After this in your oncreate method you set the currentActivity to this the following code demonstrated that:

public class MainActivity extends UnityPlayerActivity { public static MainActivity currentActivity; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentActivity=this; 

In addition : From your Unity code you can use C# to call an Android method from the MainActivity by using the following code:

AndroidJavaClass jc = new AndroidJavaClass("yourpackagename.youractivity"); AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); jo.Call("toggleMenu"); 

OR

You can convert UnityPlayerActivity to Fragment,link mentioned below will help you on same

How can I open an Android Fragment in a new process?

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.