Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back Button on App Bar is not working in Iphone Real Device #965

Open
asbn223 opened this issue Jun 27, 2024 · 0 comments
Open

Back Button on App Bar is not working in Iphone Real Device #965

asbn223 opened this issue Jun 27, 2024 · 0 comments

Comments

@asbn223
Copy link

asbn223 commented Jun 27, 2024

Describe the bug
Back Button on App Bar is not working in Iphones. I tried everything but it didn't work

My Code

class CustomUnityArScreen extends StatefulWidget {
  const CustomUnityArScreen({
    super.key,
  });

  @override
  State<CustomUnityArScreen> createState() => _CustomUnityArScreenState();
}

class _CustomUnityArScreenState extends State<CustomUnityArScreen> {
  late UnityWidgetController _unityWidgetController;

  void _sendMessageToUnity() async {
    await _unityWidgetController.postMessage(
      'MainOrigin',
      'OnMessage',
      'Hello From Flutter with token',
    );
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          // leading: IconButton(
          //   icon: const Icon(Icons.arrow_back),
          //   onPressed: () async {
          //     if (await _unityWidgetController.isReady() ?? false) {
          //       _unityWidgetController.unload();
          //       _unityWidgetController.dispose();
          //     }
          //     Get.back();
          //   },
          // ),
          ),
      body: UnityWidget(
        onUnityCreated: _onUnityCreated,
        onUnityMessage: onUnityMessage,
        onUnitySceneLoaded: onUnitySceneLoaded,
        useAndroidViewSurface: true,
        fullscreen: false,
        hideStatus: false,
        uiLevel: 0,
        gestureRecognizers: {},
        borderRadius: const BorderRadius.all(Radius.circular(70)),
      ),
    );
  }

  void onUnityMessage(message) {
    print('Received message from unity: ${message.toString()}');
  }

  void onUnitySceneLoaded(SceneLoaded? scene) {
    if (scene != null) {
      print('Received scene loaded from unity: ${scene.name}');
      print('Received scene loaded from unity buildIndex: ${scene.buildIndex}');
    } else {
      print('Received scene loaded from unity: null');
    }
  }

  // Callback that connects the created controller to the unity controller
  void _onUnityCreated(UnityWidgetController controller) async {
    _unityWidgetController = controller;
    await Future.delayed(const Duration(milliseconds: 2000));
    await _unityWidgetController.resume();
  }

// void _onUnityCreated(controller) async {
//   controller.resume();
//   _unityWidgetController = await controller;
//
//   if (widget.isInit) {
//     Future.delayed(
//       const Duration(milliseconds: 300),
//       () async {
//         await _unityWidgetController.unload();
//         Get.back();
//         Future.delayed(
//           const Duration(milliseconds: 500),
//         ).then(
//           (value) => widget.initCallback(),
//         );
//       },
//     );
//   }
// }
}

Screenshots
If applicable, add screenshots to help explain your problem.

Unity (please complete the following information):

  • OS: IOS
  • Version 2022.3.23f1

Smartphone (please complete the following information):

  • Device: Iphone 13 and Iphone 15 Pro Max
  • OS: IOS
  • Version: 17.5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant