juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.09k stars 504 forks source link

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

Open Farvind opened 1 month ago

Farvind commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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}');
  }
}