Skip to content

Commit bb32b27

Browse files
committed
Updated native ios integration
1 parent 1d30666 commit bb32b27

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

ios/Classes/FlutterUnityViewController.m

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ - (void)initView {
9595
}];
9696
[GetAppController() setUnityMessageHandler: ^(const char* message)
9797
{
98-
[_channel invokeMethod:@"onUnityMessage" arguments:[NSString stringWithUTF8String:message]];
98+
[_channel invokeMethod:@"event#onUnityMessage" arguments:[NSString stringWithUTF8String:message]];
9999
}];
100100
[GetAppController() setUnitySceneLoadedHandler:^(const char *name, const int *buildIndex, const bool *isLoaded, const bool *IsValid)
101101
{
@@ -106,43 +106,45 @@ - (void)initView {
106106
@"FourthKey" : [NSNumber numberWithBool:IsValid]
107107
};
108108

109-
[_channel invokeMethod:@"onUnitySceneLoaded" arguments:addObject];
109+
[_channel invokeMethod:@"event#onUnitySceneLoaded" arguments:addObject];
110110
}];
111111
}
112112
}
113113

114114
- (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
115-
if ([call.method isEqualToString:@"isReady"]) {
115+
if ([call.method isEqualToString:@"unity#isReady"]) {
116116
NSNumber* res = @([UnityUtils isUnityReady]);
117117
result(res);
118-
} else if ([call.method isEqualToString:@"isLoaded"]) {
118+
} else if ([call.method isEqualToString:@"unity#isLoaded"]) {
119119
NSNumber* res = @(IsUnityLoaded());
120120
result(res);
121-
} else if ([call.method isEqualToString:@"createUnity"]) {
121+
} else if ([call.method isEqualToString:@"unity#createUnityPlayer"]) {
122122
[self initView];
123123
result(nil);
124-
} else if ([call.method isEqualToString:@"isPaused"]) {
124+
} else if ([call.method isEqualToString:@"unity#isPaused"]) {
125125
NSNumber* res = @(IsUnityPaused());
126126
result(res);
127-
} else if ([call.method isEqualToString:@"isInBackground"]) {
127+
} else if ([call.method isEqualToString:@"unity#nBackground"]) {
128128
NSNumber* res = @(IsUnityInBackground());
129129
result(res);
130-
} else if ([call.method isEqualToString:@"pause"]) {
130+
} else if ([call.method isEqualToString:@"unity#pausePlayer"]) {
131131
[self pausePlayer:call result:result];
132-
} else if ([call.method isEqualToString:@"dispose"]) {
132+
} else if ([call.method isEqualToString:@"unity#dispose"]) {
133133
// [self openNative)];
134134
result(nil);
135-
} else if ([call.method isEqualToString:@"resume"]) {
135+
} else if ([call.method isEqualToString:@"unity#resumePlayer"]) {
136136
[self resumePlayer:call result:result];
137-
} else if ([call.method isEqualToString:@"unload"]) {
137+
} else if ([call.method isEqualToString:@"unity#unloadPlayer"]) {
138138
[self unloadPlayer:call result:result];
139-
} else if ([call.method isEqualToString:@"silentQuitPlayer"]) {
139+
} else if ([call.method isEqualToString:@"unity#silentQuitPlayer"]) {
140140
UnityShowWindowCommand();
141141
result(nil);
142-
} else if ([call.method isEqualToString:@"quitPlayer"]) {
142+
} else if ([call.method isEqualToString:@"unity#quitPlayer"]) {
143143
[self quitPlayer:call result:result];
144-
} else if ([[call method] isEqualToString:@"postMessage"]) {
144+
} else if ([[call method] isEqualToString:@"unity#postMessage"]) {
145145
[self postMessage:call result:result];
146+
} else if ([call.method isEqualToString:@"unity#waitForUnity"]) {
147+
result(nil);
146148
} else {
147149
result(FlutterMethodNotImplemented);
148150
}

ios/Classes/FlutterUnityWidgetPlugin.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
2222
}
2323

2424
- (FLTUnityViewController*)mapFromCall:(FlutterMethodCall*)call error:(FlutterError**)error {
25-
id mapId = call.arguments[@"map"];
26-
FLTUnityViewController* controller = _mapControllers[mapId];
25+
id unityId = call.arguments[@"unity"];
26+
FLTUnityViewController* controller = _mapControllers[unityId];
2727
if (!controller && error) {
28-
*error = [FlutterError errorWithCode:@"unknown_map" message:nil details:mapId];
28+
*error = [FlutterError errorWithCode:@"unknown_map" message:nil details:unityId];
2929
}
3030
return controller;
3131
}

0 commit comments

Comments
 (0)