Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-vim authored Jun 12, 2023
1 parent ee85f1d commit d55ff66
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
59 changes: 59 additions & 0 deletions ARwayKit_SDK_Flutter/lib/arwaysdk_unity_screen.dart
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;
}
}
25 changes: 25 additions & 0 deletions ARwayKit_SDK_Flutter/lib/main.dart
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(),
},
);
}
}
67 changes: 67 additions & 0 deletions ARwayKit_SDK_Flutter/lib/menu_screen.dart
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,
),
),
),
),
],
),
),
);
}
}

0 comments on commit d55ff66

Please sign in to comment.