just_game_engine_editor 0.1.0-dev.2
just_game_engine_editor: ^0.1.0-dev.2 copied to clipboard
A level editor that runs inside your just_game_engine game while you develop it: scenes, inspector, 2D and 3D level design, timelines, tilesets, materials, an Asset Store.
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
import 'package:just_game_engine/just_game_engine.dart';
import 'package:just_game_engine_editor/just_game_engine_editor.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final engine = Engine();
// The editor attaches to a ready engine: its world and camera exist.
await engine.initialize();
// kDebugMode is a compile-time constant: a profile or release build drops
// the editor and holds only the game (register returns null there too).
final plugin = kDebugMode
? await JustGameEditorPlugin.register(engine: engine)
: null;
// The game loop drives the editor too: Play, autosave and the 3-D fly
// keys all run on its frames.
engine.start();
runApp(_ExampleApp(engine: engine, plugin: plugin));
}
class _ExampleApp extends StatelessWidget {
const _ExampleApp({required this.engine, required this.plugin});
final Engine engine;
final JustGameEditorPlugin? plugin;
@override
Widget build(BuildContext context) {
// JustGameEngineEditor puts the editor overlay over the GameWidget and
// routes focus between them. When plugin is null (release builds, or a
// platform the editor does not run on) it is a plain GameWidget.
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: JustGameEngineEditor(
engine: engine,
plugin: plugin,
showFPS: true,
showTerminal: true,
),
),
);
}
}