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

Communication Error: OnUnityMessage,OnunityUnitySceneCreated No Logs On the flutter console #951

Open
Farvind opened this issue May 24, 2024 · 2 comments

Comments

@Farvind
Copy link

Farvind commented May 24, 2024

Tried Communicating from flutter using OnUnityMessageandOnunityUnitySceneCreated no logs are shown on flutter side not even working with degug export too.How to fix it.

Note: It is a simple android Project not an XR Project.

Unity Version:2022.3.16f1

Tried everything

@Ahmadre
Copy link
Collaborator

Ahmadre commented May 24, 2024

Try using 2022.3.10f1 and let us know if you get some logs.

Can you also please share your Flutter Code related to this? Just the UnityWidget part with your callbacks implemented.

@Farvind
Copy link
Author

Farvind commented May 24, 2024

I did tried with 2022.3.16f1.Is there list of stable unity version for the widget??

Here is the flutter Script:

import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';

void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Unity Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home:  UnityDemoScreen(),
    );
  }
}

class UnityDemoScreen extends StatefulWidget {
  @override
  _UnityDemoScreenState createState() => _UnityDemoScreenState();
}

class _UnityDemoScreenState extends State<UnityDemoScreen> {
  late UnityWidgetController _unityWidgetController;

  void onUnityCreated(UnityWidgetController controller) {
    _unityWidgetController = controller;
  }

  @override
  Widget build(BuildContext context) {
    return UnityWidget(
      onUnityCreated: onUnityCreated,
      onUnityMessage: onUnityMessage,
      onUnitySceneLoaded: onUnitySceneLoaded,
    );

    }
void onUnityMessage(message) {
    print('unity message recieved ');  
  }
  void onUnitySceneLoaded(SceneLoaded? sceneInfo) {
    print('Received scene loaded from unity: ${sceneInfo?.name}');
    print('Received scene loaded from unity buildIndex: ${sceneInfo?.buildIndex}');
  }
}

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

2 participants