Skip to content

Commit 7c43836

Browse files
committed
chore: Update version numbers and improve code formatting
This commit updates the version numbers for the `gameframework` and `gameframework_stream` packages to 0.0.1, reflecting the initial release of the new architecture. Additionally, it includes various code formatting improvements across multiple files, enhancing readability and consistency. Changes include adjustments to method signatures, comments, and spacing in Dart files, as well as the addition of unit tests for the `CacheManager` and `DownloadProgress` classes to ensure functionality and reliability.
1 parent 1795454 commit 7c43836

28 files changed

+1172
-208
lines changed

engines/unity/dart/lib/src/unity_controller.dart

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,23 @@ class UnityController implements GameEngineController {
3030

3131
/// Set up event stream with explicit native confirmation
3232
/// This eliminates race conditions by using method channel handshake
33-
///
33+
///
3434
/// Uses polling with exponential backoff to wait for platform view creation
35-
Future<void> _setupEventStream({int attempt = 0, int maxAttempts = 10}) async {
35+
Future<void> _setupEventStream(
36+
{int attempt = 0, int maxAttempts = 10}) async {
3637
if (_disposed || _eventStreamSetup) return;
37-
38+
3839
try {
3940
// Step 1: Request native side to register event handler
4041
// This will fail with MissingPluginException if platform view not created yet
4142
final setupResult = await _channel.invokeMethod<bool>('events#setup');
42-
43+
4344
if (setupResult != true) {
4445
throw Exception('Native event setup returned false or null');
4546
}
46-
47+
4748
_eventStreamSetup = true;
48-
49+
4950
// Step 2: Native handler is now guaranteed to be registered
5051
// We can safely subscribe to the event stream
5152
_eventSubscription = _eventChannel.receiveBroadcastStream().listen(
@@ -149,26 +150,29 @@ class UnityController implements GameEngineController {
149150
if (attempt == 0) {
150151
// First attempt is expected to fail, don't log
151152
} else if (attempt < 3) {
152-
print('Platform view not ready, retrying in ${delayMs}ms (attempt ${attempt + 1}/$maxAttempts)');
153+
print(
154+
'Platform view not ready, retrying in ${delayMs}ms (attempt ${attempt + 1}/$maxAttempts)');
153155
} else {
154-
print('Warning: Platform view still not ready after ${attempt} attempts, retrying in ${delayMs}ms');
156+
print(
157+
'Warning: Platform view still not ready after ${attempt} attempts, retrying in ${delayMs}ms');
155158
}
156-
159+
157160
await Future.delayed(Duration(milliseconds: delayMs));
158-
return _setupEventStream(attempt: attempt + 1, maxAttempts: maxAttempts);
161+
return _setupEventStream(
162+
attempt: attempt + 1, maxAttempts: maxAttempts);
159163
}
160-
164+
161165
// Fatal error or max retries exceeded
162166
final message = attempt >= maxAttempts
163167
? 'Platform view creation timeout after $maxAttempts attempts'
164168
: 'Failed to setup event stream: $e';
165-
169+
166170
_eventController.add(GameEngineEvent(
167171
type: GameEngineEventType.error,
168172
timestamp: DateTime.now(),
169173
message: message,
170174
));
171-
175+
172176
if (attempt >= maxAttempts) {
173177
throw TimeoutException(
174178
'Platform view not created after $maxAttempts attempts',
@@ -267,15 +271,17 @@ class UnityController implements GameEngineController {
267271
if (attempt == 0) {
268272
// First attempt failure is expected, don't log
269273
} else if (attempt < 3) {
270-
print('Platform view not ready for create(), retrying in ${delayMs}ms (attempt ${attempt + 1}/$maxAttempts)');
274+
print(
275+
'Platform view not ready for create(), retrying in ${delayMs}ms (attempt ${attempt + 1}/$maxAttempts)');
271276
} else {
272-
print('Warning: Platform view still not ready for create() after ${attempt} attempts, retrying in ${delayMs}ms');
277+
print(
278+
'Warning: Platform view still not ready for create() after ${attempt} attempts, retrying in ${delayMs}ms');
273279
}
274-
280+
275281
await Future.delayed(Duration(milliseconds: delayMs));
276282
return create(attempt: attempt + 1, maxAttempts: maxAttempts);
277283
}
278-
284+
279285
// Fatal error or max retries exceeded
280286
throw EngineCommunicationException(
281287
attempt >= maxAttempts
@@ -410,6 +416,7 @@ class UnityController implements GameEngineController {
410416
}
411417

412418
/// Platform-specific controller creation for mobile/desktop
413-
GameEngineController createUnityController(int viewId, GameEngineConfig config) {
419+
GameEngineController createUnityController(
420+
int viewId, GameEngineConfig config) {
414421
return UnityController(viewId);
415422
}

engines/unity/dart/lib/src/unity_controller_web.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class UnityControllerWeb implements GameEngineController {
138138
'frameworkUrl': frameworkUrl ?? '$buildUrl/Build.framework.js',
139139
'codeUrl': codeUrl ?? '$buildUrl/Build.wasm',
140140
'streamingAssetsUrl': '$buildUrl/StreamingAssets',
141-
'companyName': _getConfigValue<String>('companyName') ?? 'DefaultCompany',
141+
'companyName':
142+
_getConfigValue<String>('companyName') ?? 'DefaultCompany',
142143
'productName': _getConfigValue<String>('productName') ?? 'Unity Game',
143144
'productVersion': _getConfigValue<String>('productVersion') ?? '1.0',
144145
});
@@ -207,8 +208,8 @@ class UnityControllerWeb implements GameEngineController {
207208
String method,
208209
Map<String, dynamic> data,
209210
) async {
210-
final jsonString = js.context['JSON']
211-
.callMethod('stringify', [js.JsObject.jsify(data)]);
211+
final jsonString =
212+
js.context['JSON'].callMethod('stringify', [js.JsObject.jsify(data)]);
212213
await sendMessage(target, method, jsonString.toString());
213214
}
214215

@@ -373,6 +374,7 @@ class UnityControllerWeb implements GameEngineController {
373374
}
374375

375376
/// Platform-specific controller creation for web
376-
GameEngineController createUnityController(int viewId, GameEngineConfig config) {
377+
GameEngineController createUnityController(
378+
int viewId, GameEngineConfig config) {
377379
return UnityControllerWeb(viewId, config);
378380
}

engines/unity/dart/lib/src/unity_engine_plugin.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:gameframework/gameframework.dart';
22
import 'unity_controller.dart';
3-
import 'unity_controller_web.dart'
4-
if (dart.library.io) 'unity_controller.dart' as platform;
3+
import 'unity_controller_web.dart' if (dart.library.io) 'unity_controller.dart'
4+
as platform;
55

66
/// Unity Engine Plugin for Flutter Game Framework
77
///

engines/unity/dart/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: gameframework_unity
22
description: Unity Engine plugin for Flutter Game Framework. Provides Unity integration with bidirectional communication, AR Foundation support, and WebGL capabilities.
3-
version: 1.0.0
3+
version: 0.0.1
44
homepage: https://github.com/xraph/gameframework
55
repository: https://github.com/xraph/gameframework
66
issue_tracker: https://github.com/xraph/gameframework/issues
@@ -24,7 +24,7 @@ dependencies:
2424
sdk: flutter
2525
# For pub.dev release, use: gameframework: ^1.0.0
2626
# For development, use path:
27-
gameframework: 1.0.0
27+
gameframework: 0.0.1
2828

2929
flutter:
3030
plugin:

0 commit comments

Comments
 (0)