flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
Can not return back to flutter from unity Android
Can not return back to flutter from unity and unload unity not working.
overrideActivity is null
var jc = new AndroidJavaClass("com.xraph.plugin.flutter_unity_widget.OverrideUnityActivity");
var overrideActivity = jc.GetStatic<AndroidJavaObject>("instance");
overrideActivity.Call("showMainActivity");
I/Unity (19112): Object reference not set to an instance of an object.
I/Unity (19112): UnityEngine.Events.UnityAction:Invoke()
I/Unity (19112): UnityEngine.Events.UnityEvent:Invoke()
I/Unity (19112): UnityEngine.EventSystems.EventFunction1:Invoke(T1, BaseEventData) I/Unity (19112): UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction
1)
I/Unity (19112): UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
I/Unity (19112): UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
I/Unity (19112): UnityEngine.EventSystems.StandaloneInputModule:Process()
I/Unity (19112):
I/Unity (19112): (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 39)
Same issue here on android, did you get it to work in the end?
I also get this error when running the example project. Easy to reproduce: just run the example, tap on LOAD NATIVE SCENE, then tap UNLOAD or GO BACK.
I/Unity (21011): Object reference not set to an instance of an object. I/Unity (21011): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) I/Unity (21011): UnityEngine.Logger:Log(LogType, Object) I/Unity (21011): UnityEngine.Debug:Log(Object) I/Unity (21011): FlutterUnityIntegration.NativeAPI:UnloadMainWindow() (at C:\Users\james\GithubRepos\flutter-unity-view-widget\example\unity\DemoApp\Assets\FlutterUnityIntegration\NativeAPI.cs:93) I/Unity (21011): FlutterUnityIntegration.UnityMessageManager:UnloadMainWindow() (at C:\Users\james\GithubRepos\flutter-unity-view-widget\example\unity\DemoApp\Assets\FlutterUnityIntegration\UnityMessageManager.cs:100) I/Unity (21011): SceneLoader:UnloadNative() (at C:\Users\james\GithubRepos\flutter-unity-view-widget\example\unity\DemoApp\Assets\FlutterUnityIntegration\Demo\SceneLoader.cs:40)
So the problem is a null reference exception in NativeAPI.cs
here:
try
{
var jc = new AndroidJavaClass("com.xraph.plugin.flutter_unity_widget.OverrideUnityActivity");
var overrideActivity = jc.GetStatic<AndroidJavaObject>("instance");
overrideActivity.Call("showMainActivity");
}
catch (Exception e)
{
Debug.Log(e.Message);
}
I'm not sure why this happens. Also not sure what 'Native Scene' even means. @juicycleff can you explain what the Native Scene in the demo is? How is it different to the normal scene / what makes it 'native'? Looking at the code I can't figure out why it exists or what it's demoing. Also, any idea why navigating back from the native scene causes this null exception?
This is also a duplicate of #635