-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee85f1d
commit d55ff66
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_unity_widget/flutter_unity_widget.dart'; | ||
|
||
class ARwayKitUnityScreen extends StatefulWidget { | ||
ARwayKitUnityScreen({Key key}) : super(key: key); | ||
|
||
@override | ||
_ARwayKitUnityScreenState createState() => _ARwayKitUnityScreenState(); | ||
} | ||
|
||
class _ARwayKitUnityScreenState extends State<ARwayKitUnityScreen> { | ||
static final GlobalKey<ScaffoldState> _scaffoldKey = | ||
GlobalKey<ScaffoldState>(); | ||
|
||
UnityWidgetController _unityWidgetController; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
key: _scaffoldKey, | ||
appBar: AppBar( | ||
title: Text('Home'), | ||
), | ||
body: Card( | ||
margin: const EdgeInsets.all(0), | ||
clipBehavior: Clip.antiAlias, | ||
child: Stack( | ||
children: [ | ||
UnityWidget( | ||
onUnityCreated: _onUnityCreated, | ||
isARScene: true, | ||
onUnityMessage: onUnityMessage, | ||
onUnitySceneLoaded: onUnitySceneLoaded, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
void onUnityMessage(message) { | ||
print('Received message from unity: ${message.toString()}'); | ||
} | ||
|
||
void onUnitySceneLoaded(SceneLoaded scene) { | ||
print('Received scene loaded from unity: ${scene.name}'); | ||
print('Received scene loaded from unity buildIndex: ${scene.buildIndex}'); | ||
} | ||
|
||
// Callback that connects the created controller to the unity controller | ||
void _onUnityCreated(controller) { | ||
this._unityWidgetController = controller; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'menu_screen.dart'; | ||
import 'arwaysdk_unity_screen.dart'; | ||
|
||
|
||
void main() { | ||
runApp(MyApp()); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
// This widget is the root of your application. | ||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'My Flutter App', | ||
theme: ThemeData.dark(), | ||
initialRoute: '/', | ||
routes: { | ||
'/': (context) => MenuScreen(), | ||
'/unity': (context) => ARwayKitUnityScreen(), | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MenuScreen extends StatefulWidget { | ||
MenuScreen({Key key}) : super(key: key); | ||
|
||
@override | ||
_MenuScreenState createState() => _MenuScreenState(); | ||
} | ||
|
||
class _MenuScreenState extends State<MenuScreen> { | ||
final String title = 'Open ARWAY SDK'; | ||
final String route = '/unity'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('ARwayKit Flutter Demo'), | ||
), | ||
body: Center( | ||
child: Column( | ||
children: [ | ||
SizedBox( | ||
height: 32, | ||
), | ||
Padding( | ||
padding: EdgeInsets.all(30), | ||
child: Text( | ||
'Example scene to show how to link "ARWAY SDK" scenes with ' | ||
'Flutter.', | ||
style: TextStyle( | ||
fontSize: 24, | ||
letterSpacing: 2, | ||
wordSpacing: 5, | ||
fontStyle: FontStyle.italic, | ||
), | ||
), | ||
), | ||
SizedBox( | ||
height: 96, | ||
), | ||
Padding( | ||
padding: EdgeInsets.all(30), | ||
child: ElevatedButton( | ||
onPressed: () { | ||
Navigator.of(context).pushNamed(route); | ||
}, | ||
style: ElevatedButton.styleFrom( | ||
elevation: 10, | ||
primary: Color(0xFF1AB146), | ||
minimumSize: Size(192, 64), | ||
), | ||
child: Text( | ||
title, | ||
style: TextStyle( | ||
fontSize: 20, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |