no message
This commit is contained in:
parent
d7699c93cd
commit
40409fd882
@ -106,7 +106,6 @@
|
||||
181E7CAB9BFA90CDBBC625FE /* Pods-RunnerTests.release.xcconfig */,
|
||||
26E556676FA54FF74E61CC9C /* Pods-RunnerTests.profile.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@ -198,7 +197,7 @@
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
C22789791D91DA87B0800321 /* [CP] Embed Pods Frameworks */,
|
||||
129AC22480F1A498B12D0823 /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -270,6 +269,23 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
129AC22480F1A498B12D0823 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
@ -345,23 +361,6 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
C22789791D91DA87B0800321 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@ -457,6 +456,7 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_LIBTOOLFLAGS = "$(inherited)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@ -471,12 +471,14 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = U4K6R29373;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterCocosViewExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@ -587,6 +589,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LIBTOOLFLAGS = "$(inherited)";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@ -637,6 +640,7 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_LIBTOOLFLAGS = "$(inherited)";
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
@ -653,12 +657,15 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = U4K6R29373;
|
||||
ENABLE_BITCODE = NO;
|
||||
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterCocosViewExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@ -675,12 +682,16 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = U4K6R29373;
|
||||
ENABLE_BITCODE = NO;
|
||||
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterCocosViewExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
@ -7,7 +7,28 @@ import UIKit
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
|
||||
///InitCocosIntegrationWithOptions(argc: CommandLine.argc, argv: CommandLine.unsafeArgv, launchOptions)
|
||||
|
||||
|
||||
let flutterEngine = FlutterEngine(name: "io.flutter", project: nil)
|
||||
flutterEngine.run()
|
||||
let controller = FlutterViewControllerWithTransition(engine: flutterEngine, nibName: nil, bundle: nil)
|
||||
self.window = UIWindow(frame: UIScreen.main.bounds)
|
||||
self.window?.rootViewController = controller
|
||||
self.window?.makeKeyAndVisible()
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class FlutterViewControllerWithTransition: FlutterViewController {
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
|
||||
NotificationCenter.default.post(name: NSNotification.Name("ViewWillTransition"), object: nil, userInfo: ["size": size, "coordinator": coordinator])
|
||||
|
||||
}
|
||||
}
|
@ -106,6 +106,7 @@ class _SimpleScreenState extends State<SimpleScreen> {
|
||||
|
||||
// Callback that connects the created controller to the cocos controller
|
||||
void _onCocosCreated(controller) {
|
||||
print('Received _onCocosCreated: null');
|
||||
controller.resume();
|
||||
_cocosWidgetController = controller;
|
||||
}
|
||||
|
@ -57,14 +57,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -77,11 +69,6 @@ packages:
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
flutter_driver:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -95,16 +82,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
integration_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -169,14 +146,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.5"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -193,14 +162,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+7"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -246,14 +207,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
sync_http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sync_http
|
||||
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -286,14 +239,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.5"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webdriver
|
||||
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
sdks:
|
||||
dart: ">=3.4.4 <4.0.0"
|
||||
flutter: ">=3.18.0-18.0.pre.54"
|
||||
|
@ -30,8 +30,6 @@ dependencies:
|
||||
cupertino_icons: ^1.0.8
|
||||
pointer_interceptor: ^0.9.3+2
|
||||
dev_dependencies:
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import cocos_view_pod
|
||||
|
||||
|
||||
private var cocos_warmed_up = false
|
||||
@ -37,7 +36,7 @@ public func InitCocosIntegrationWithOptions(
|
||||
/***********************************PLUGIN_ENTRY END**************************************/
|
||||
|
||||
// Load cocos framework for fisrt run
|
||||
func CocosFrameworkLoad() -> CocosFramework? {
|
||||
func CocosFrameworkLoad() -> dcocos_bridge? {
|
||||
|
||||
|
||||
return dcocos_bridge.instance()
|
||||
@ -58,7 +57,7 @@ func GetCocosPlayerUtils() -> CocosPlayerUtils {
|
||||
|
||||
/*********************************** GLOBAL FUNCS & VARS END****************************************/
|
||||
|
||||
var controller: CocosAppController?
|
||||
//var controller: CocosAppController?
|
||||
var sharedApplication: UIApplication?
|
||||
|
||||
@objc protocol CocosEventListener: AnyObject {
|
||||
@ -67,31 +66,74 @@ var sharedApplication: UIApplication?
|
||||
|
||||
}
|
||||
|
||||
@objc public class CocosPlayerUtils: UIResponder, UIApplicationDelegate, CocosFrameworkListener {
|
||||
var ufw: CocosFramework!
|
||||
@objc public class CocosPlayerUtils: UIResponder, UIApplicationDelegate {
|
||||
var ufw: dcocos_bridge!
|
||||
private var _isCocosPaused = false
|
||||
private var _isCocosReady = false
|
||||
private var _isCocosLoaded = false
|
||||
|
||||
func initCocos() {
|
||||
if (self.cocosIsInitiallized()) {
|
||||
self.ufw?.showCocosWindow()
|
||||
override init() {
|
||||
super.init()
|
||||
// 监听通知
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleViewWillTransition), name: NSNotification.Name("ViewWillTransition"), object: nil)
|
||||
}
|
||||
|
||||
deinit {
|
||||
// 移除通知监听
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
@objc func handleViewWillTransition(notification: Notification) {
|
||||
guard let size = notification.userInfo?["size"] as? CGSize,
|
||||
let coordinator = notification.userInfo?["coordinator"] as? UIViewControllerTransitionCoordinator else {
|
||||
return
|
||||
}
|
||||
// 处理视图大小变化的逻辑
|
||||
print("CocosPlayerUtils will transition to size: \(size)")
|
||||
//改正错误
|
||||
let selector = NSSelectorFromString("viewWillTransitionToSize:withTransitionCoordinator:")
|
||||
if self.ufw.responds(to: selector) {
|
||||
self.ufw.perform(selector, with: size, with: coordinator)
|
||||
}
|
||||
}
|
||||
|
||||
func initCocos() {
|
||||
if (self.cocosIsInitiallized()) {
|
||||
//todo
|
||||
//self.ufw?.showCocosWindow()
|
||||
return
|
||||
}
|
||||
// 开始生成设备旋转通知
|
||||
//UIDevice.current.beginGeneratingDeviceOrientationNotifications()
|
||||
|
||||
self.ufw = CocosFrameworkLoad()
|
||||
|
||||
// 获取当前Pod库的Bundle
|
||||
let bundle = Bundle(for: dcocos_bridge.self)
|
||||
|
||||
// 获取 `YourPodResources.bundle` 的路径
|
||||
if let bundleURL = bundle.url(forResource: "cocos_main_bundle", withExtension: "bundle") {
|
||||
let bundlePath = bundleURL.path
|
||||
print("Bundle absolute path: \(bundlePath)")
|
||||
self.ufw.configureCocos2dSearchPaths(bundlePath)
|
||||
} else {
|
||||
print("Could not find the bundle.")
|
||||
}
|
||||
|
||||
//self.ufw?.setDataBundleId("com.cocos3d.framework")
|
||||
self.ufw.initPlatform()
|
||||
let application = UIApplication.shared
|
||||
self.ufw.application(application, didFinishLaunchingWithOptions: appLaunchOpts )
|
||||
|
||||
registerCocosListener()
|
||||
// self.ufw?.runEmbedded(withArgc: gArgc, argv: gArgv, appLaunchOpts: appLaunchOpts)
|
||||
|
||||
if self.ufw?.appController() != nil {
|
||||
controller = self.ufw?.appController()
|
||||
controller?.cocosMessageHandler = self.cocosMessageHandlers
|
||||
controller?.cocosSceneLoadedHandler = self.cocosSceneLoadedHandlers
|
||||
self.ufw?.appController()?.window?.windowLevel = UIWindow.Level(UIWindow.Level.normal.rawValue - 1)
|
||||
}
|
||||
// if self.ufw?.appController() != nil {
|
||||
// controller = self.ufw?.appController()
|
||||
// controller?.cocosMessageHandler = self.cocosMessageHandlers
|
||||
// controller?.cocosSceneLoadedHandler = self.cocosSceneLoadedHandlers
|
||||
// self.ufw?.appController()?.window?.windowLevel = UIWindow.Level(UIWindow.Level.normal.rawValue - 1)
|
||||
// }
|
||||
_isCocosLoaded = true
|
||||
}
|
||||
|
||||
@ -107,13 +149,18 @@ var sharedApplication: UIApplication?
|
||||
// Create new cocos player
|
||||
func createPlayer(completed: @escaping (_ view: UIView?) -> Void) {
|
||||
if self.cocosIsInitiallized() && self._isCocosReady {
|
||||
completed(controller?.rootView)
|
||||
//todo
|
||||
//completed(controller?.rootView)
|
||||
completed(nil)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name("CocosReady"), object: nil, queue: OperationQueue.main, using: { note in
|
||||
self._isCocosReady = true
|
||||
completed(controller?.rootView)
|
||||
//todo
|
||||
//completed(controller?.rootView)
|
||||
completed(nil)
|
||||
})
|
||||
|
||||
DispatchQueue.main.async {
|
||||
@ -134,7 +181,9 @@ var sharedApplication: UIApplication?
|
||||
|
||||
self.listenAppState()
|
||||
|
||||
completed(controller?.rootView)
|
||||
//todo
|
||||
//completed(controller?.rootView)
|
||||
completed(nil)
|
||||
}
|
||||
|
||||
}
|
||||
@ -163,22 +212,22 @@ var sharedApplication: UIApplication?
|
||||
if !self._isCocosReady {
|
||||
return
|
||||
}
|
||||
|
||||
let cocosAppController = self.ufw?.appController() as? CocosAppController
|
||||
//todo
|
||||
//let cocosAppController = self.ufw?.appController() as? CocosAppController
|
||||
// let cocosAppController = nil
|
||||
let application = UIApplication.shared
|
||||
|
||||
if notification?.name == UIApplication.willResignActiveNotification {
|
||||
cocosAppController?.applicationWillResignActive(application)
|
||||
self.ufw?.applicationWillResignActive(application)
|
||||
} else if notification?.name == UIApplication.didEnterBackgroundNotification {
|
||||
cocosAppController?.applicationDidEnterBackground(application)
|
||||
// self.ufw?.applicationDidEnterBackground(application)
|
||||
} else if notification?.name == UIApplication.willEnterForegroundNotification {
|
||||
cocosAppController?.applicationWillEnterForeground(application)
|
||||
// self.ufw?.applicationWillEnterForeground(application)
|
||||
} else if notification?.name == UIApplication.didBecomeActiveNotification {
|
||||
cocosAppController?.applicationDidBecomeActive(application)
|
||||
self.ufw?.applicationDidBecomeActive(application)
|
||||
} else if notification?.name == UIApplication.willTerminateNotification {
|
||||
cocosAppController?.applicationWillTerminate(application)
|
||||
self.ufw?.applicationWillTerminate(application)
|
||||
} else if notification?.name == UIApplication.didReceiveMemoryWarningNotification {
|
||||
cocosAppController?.applicationDidReceiveMemoryWarning(application)
|
||||
// self.ufw?.applicationDidReceiveMemoryWarning(application)
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +235,7 @@ var sharedApplication: UIApplication?
|
||||
// Listener for app lifecycle eventa
|
||||
func listenAppState() {
|
||||
for name in [
|
||||
|
||||
UIApplication.didBecomeActiveNotification,
|
||||
UIApplication.didEnterBackgroundNotification,
|
||||
UIApplication.willTerminateNotification,
|
||||
@ -202,19 +252,22 @@ var sharedApplication: UIApplication?
|
||||
}
|
||||
// Pause cocos player
|
||||
func pause() {
|
||||
self.ufw?.pause(true)
|
||||
//todo
|
||||
// self.ufw?.pause(true)
|
||||
self._isCocosPaused = true
|
||||
}
|
||||
|
||||
// Resume cocos player
|
||||
func resume() {
|
||||
self.ufw?.pause(false)
|
||||
//todo
|
||||
//self.ufw?.pause(false)
|
||||
self._isCocosPaused = false
|
||||
}
|
||||
|
||||
// Unoad cocos player
|
||||
func unload() {
|
||||
self.ufw?.unloadApplication()
|
||||
//todo
|
||||
//self.ufw?.unloadApplication()
|
||||
}
|
||||
|
||||
func isCocosLoaded() -> Bool {
|
||||
@ -227,14 +280,16 @@ var sharedApplication: UIApplication?
|
||||
|
||||
// Quit cocos player application
|
||||
func quit() {
|
||||
self.ufw?.quitApplication(0)
|
||||
//todo
|
||||
//self.ufw?.quitApplication(0)
|
||||
self._isCocosLoaded = false
|
||||
}
|
||||
|
||||
// Post message to cocos
|
||||
func postMessageToCocos(gameObject: String?, cocosMethodName: String?, cocosMessage: String?) {
|
||||
if self.cocosIsInitiallized() {
|
||||
self.ufw?.sendMessageToGO(withName: gameObject, functionName: cocosMethodName, message: cocosMessage)
|
||||
//todo
|
||||
//self.ufw?.sendMessageToGO(withName: gameObject, functionName: cocosMethodName, message: cocosMessage)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,8 @@ class FLTCocosView: UIView {
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
if (!self.bounds.isEmpty) {
|
||||
GetCocosPlayerUtils().ufw?.appController()?.rootView.frame = self.bounds
|
||||
//todo
|
||||
GetCocosPlayerUtils().ufw?.getCocosView()?.frame = self.bounds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ public class FLTCocosWidgetController: NSObject, FLTCocosOptionsSink, FlutterPla
|
||||
arguments args: Any?,
|
||||
registrar: NSObjectProtocol & FlutterPluginRegistrar
|
||||
) {
|
||||
|
||||
//CGRect(x: 0, y: 0, width: 700, height: 700)
|
||||
self._rootView = FLTCocosView(frame: frame)
|
||||
super.init()
|
||||
|
||||
@ -38,6 +40,8 @@ public class FLTCocosWidgetController: NSObject, FLTCocosOptionsSink, FlutterPla
|
||||
}
|
||||
|
||||
func methodHandler(_ call: FlutterMethodCall, result: FlutterResult) {
|
||||
|
||||
NSLog("call : \(call.method)")
|
||||
if call.method == "cocos#dispose" {
|
||||
self.dispose()
|
||||
result(nil)
|
||||
@ -93,8 +97,9 @@ public class FLTCocosWidgetController: NSObject, FLTCocosOptionsSink, FlutterPla
|
||||
|
||||
func attachView() {
|
||||
startCocosIfNeeded()
|
||||
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.appController()?.rootView
|
||||
//GetCocosPlayerUtils().ufw?.setCocosView(_rootView)
|
||||
// self.channel?.invokeMethod("events#onViewReattached", arguments: "")
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.getCocosView()
|
||||
if let superview = cocosView?.superview {
|
||||
cocosView?.removeFromSuperview()
|
||||
superview.layoutIfNeeded()
|
||||
@ -109,7 +114,8 @@ public class FLTCocosWidgetController: NSObject, FLTCocosOptionsSink, FlutterPla
|
||||
}
|
||||
|
||||
func reattachView() {
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.appController()?.rootView
|
||||
//todo
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.getCocosView()
|
||||
let superview = cocosView?.superview
|
||||
if superview != _rootView {
|
||||
attachView()
|
||||
@ -123,7 +129,7 @@ public class FLTCocosWidgetController: NSObject, FLTCocosOptionsSink, FlutterPla
|
||||
return
|
||||
}
|
||||
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.appController()?.rootView
|
||||
let cocosView = GetCocosPlayerUtils().ufw?.getCocosView()
|
||||
if _rootView == cocosView?.superview {
|
||||
if globalControllers.isEmpty {
|
||||
cocosView?.removeFromSuperview()
|
||||
|
@ -1,11 +1,10 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
public class FlutterCocosViewPlugin: NSObject, FlutterPlugin {
|
||||
public class SwiftFlutterCocosViewPlugin: NSObject, FlutterPlugin {
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: "flutter_cocos_view", binaryMessenger: registrar.messenger())
|
||||
let instance = FlutterCocosViewPlugin()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
print("FlutterCocosViewPlugin registered~~~~~~~~~~~~~~") // 添加调试日志
|
||||
|
||||
|
||||
let fuwFactory = FLTCocosWidgetFactory(registrar: registrar)
|
||||
registrar.register(fuwFactory, withId: "plugin.gem.com/cocos_view", gestureRecognizersBlockingPolicy: FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded)
|
||||
|
@ -1,12 +1,12 @@
|
||||
#import FlutterCocosWidgetPlugin.h
|
||||
#import "FlutterCocosWidgetPlugin.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#if __has_include(<flutter_cocos_widget/flutter_cocos_widget-Swift.h>)
|
||||
#import <flutter_cocos_widget/flutter_cocos_widget-Swift.h>
|
||||
#if __has_include(<flutter_cocos_view/flutter_cocos_-Swift.h>)
|
||||
#import <flutter_cocos_view/flutter_cocos_view-Swift.h>
|
||||
#else
|
||||
// Support project import fallback if the generated compatibility header
|
||||
// is not copied when this plugin is created as a library.
|
||||
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
|
||||
#import "flutter_cocos_widget-Swift.h"
|
||||
#import <flutter_cocos_view/flutter_cocos_view-Swift.h>
|
||||
#endif
|
||||
|
||||
@implementation FlutterCocosWidgetPlugin {
|
||||
@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
[SwiftFlutterCocosWidgetPlugin registerWithRegistrar:registrar];
|
||||
[SwiftFlutterCocosViewPlugin registerWithRegistrar:registrar];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -15,11 +15,17 @@ A new Flutter plugin project.
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.dependency 'Flutter'
|
||||
s.dependency 'cocos_view_pod','0.1.23'
|
||||
s.platform = :ios, '14.5'
|
||||
|
||||
s.dependency 'cocos_view_pod','0.1.7'
|
||||
#s.public_header_files = 'Classes/**/*.h'
|
||||
#s.vendored_libraries = 'Libs/**/*.a'
|
||||
#s.libraries = 'dcocos'
|
||||
#s.private_header_files = 'Classes/flutter_cocos_view-Bridging-Header.h'
|
||||
s.static_framework = true
|
||||
# Flutter.framework does not contain a i386 slice.
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES'}
|
||||
s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' }
|
||||
s.swift_version = '5.0'
|
||||
|
||||
# If your plugin requires a privacy manifest, for example if it uses any
|
||||
|
@ -40,7 +40,7 @@ class MethodChannelCocosWidget extends CocosWidgetPlatform {
|
||||
MethodChannel ensureChannelInitialized(int cocosId) {
|
||||
MethodChannel? channel = _channels[cocosId];
|
||||
if (channel == null) {
|
||||
channel = MethodChannel('plugin.xraph.com/cocos_view_$cocosId');
|
||||
channel = MethodChannel('plugin.gem.com/cocos_view_$cocosId');
|
||||
|
||||
channel.setMethodCallHandler(
|
||||
(MethodCall call) => _handleMethodCall(call, cocosId));
|
||||
@ -158,7 +158,7 @@ class MethodChannelCocosWidget extends CocosWidgetPlatform {
|
||||
bool? cocosWebSource,
|
||||
String? cocosSrcUrl,
|
||||
}) {
|
||||
final String _viewType = 'plugin.xraph.com/cocos_view';
|
||||
final String _viewType = 'plugin.gem.com/cocos_view';
|
||||
|
||||
if (useAndroidViewSurf != null) useAndroidViewSurface = useAndroidViewSurf;
|
||||
|
||||
|
14
pubspec.yaml
14
pubspec.yaml
@ -1,11 +1,12 @@
|
||||
name: flutter_cocos_view
|
||||
description: "A new Flutter plugin project."
|
||||
version: 0.0.1
|
||||
homepage:
|
||||
homepage: https://www.openim.io
|
||||
|
||||
|
||||
environment:
|
||||
sdk: ^3.4.4
|
||||
flutter: '>=3.3.0'
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
flutter: ">=1.20.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@ -34,14 +35,15 @@ flutter:
|
||||
# All these are used by the tooling to maintain consistency when
|
||||
# adding or updating assets for this project.
|
||||
plugin:
|
||||
platforms:
|
||||
# This plugin project was generated without specifying any
|
||||
# platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and
|
||||
# then add platforms following the instruction here:
|
||||
# https://flutter.dev/to/pubspec-plugin-platforms
|
||||
# -------------------
|
||||
some_platform:
|
||||
pluginClass: somePluginClass
|
||||
platforms:
|
||||
ios:
|
||||
pluginClass: FlutterCocosWidgetPlugin
|
||||
|
||||
# -------------------
|
||||
|
||||
# To add assets to your plugin package, add an assets section, like this:
|
||||
|
Loading…
x
Reference in New Issue
Block a user