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

Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unityMessageHandler' #920

Open iamtobgay opened 5 months ago

iamtobgay commented 5 months ago

Describe the bug Tried to build and run the following example code :

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

void main() {
  runApp(
    const MaterialApp(
      home: UnityDemoScreen(),
    ),
  );
}

class UnityDemoScreen extends StatefulWidget {
  const UnityDemoScreen({Key? key}) : super(key: key);

  @override
  State<UnityDemoScreen> createState() => _UnityDemoScreenState();
}

class _UnityDemoScreenState extends State<UnityDemoScreen> {
  static final GlobalKey<ScaffoldState> _scaffoldKey =
      GlobalKey<ScaffoldState>();
  UnityWidgetController? _unityWidgetController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      body: SafeArea(
        bottom: false,
        child: WillPopScope(
          onWillPop: () async {
            // Pop the category page if Android back button is pressed.
            return true;
          },
          child: Container(
            color: Colors.yellow,
            child: UnityWidget(
              onUnityCreated: onUnityCreated,
            ),
          ),
        ),
      ),
    );
  }

  // Callback that connects the created controller to the unity controller
  void onUnityCreated(controller) {
    _unityWidgetController = controller;
  }
}

got the following errors :

Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unityMessageHandler' Swift Compiler Error (Xcode): Value of type 'UnityAppController' has no member 'unitySceneLoadedHandler'

Unity (please complete the following information):

Smartphone (please complete the following information):

timbotimbo commented 3 months ago

During the Unity export, the plugin's build script will add a few lines to the UnityAppController script generated by Unity.

This error indicates that these additions are missing and weren't generated properly.

iamtobgay commented 3 months ago

Thanks for the information.

On Mon, 11 Mar 2024 at 04:09, timbotimbo @.***> wrote:

During the Unity export, the plugin's build script will add a few lines to the UnityAppController script generated by Unity.

This error indicates that these additions are missing and weren't generated properly.

  • use the latest unitypackage
  • delete any existing ios/unitylibrary folder
  • In unity make sure your buildtarget is set to ios. This error will show up if you click export ios while the unity buildtarget is not ios.
  • Make an ios export using the Flutter menu in Unity.

— Reply to this email directly, view it on GitHub https://github.com/juicycleff/flutter-unity-view-widget/issues/920#issuecomment-1987378797, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2PE54I2OZPMQXKXVV33PULYXTK2TAVCNFSM6AAAAABCMEXIYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXGM3TQNZZG4 . You are receiving this because you authored the thread.Message ID: @.***>

liujunqiang29 commented 2 months ago

Is the problem solved? I have the same problem