36 lines
925 B
Dart
36 lines
925 B
Dart
import 'package:flutter/material.dart';
|
|
import 'unity_widget.dart';
|
|
|
|
class UnityExamplePage extends StatefulWidget {
|
|
const UnityExamplePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<UnityExamplePage> createState() => _UnityExamplePageState();
|
|
}
|
|
|
|
class _UnityExamplePageState extends State<UnityExamplePage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Unity示例'),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
// 使用UnityWidget作为主要内容
|
|
child: UnityWidget(
|
|
defaultScene: 'Main',
|
|
onUnityViewCreated: () {
|
|
print('Unity视图创建完成');
|
|
},
|
|
onUnityMessage: (message) {
|
|
print('收到Unity消息: $message');
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |