diff --git a/Classes_cocos/JcWallet.cpp b/Classes_cocos/JcWallet.cpp index a184932..b771cb4 100644 --- a/Classes_cocos/JcWallet.cpp +++ b/Classes_cocos/JcWallet.cpp @@ -1,4 +1,5 @@ #include "JcWallet.h" +#include "WalletEvent.h" #include #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" #include "cocos/scripting/js-bindings/manual/jsb_global.h" @@ -6,7 +7,6 @@ #include "platform/CCApplication.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #import "AppDelegate.h" -#import "WalletEvent.hpp" #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) @@ -25,11 +25,11 @@ NS_CC_BEGIN void JcWallet::initEnv() { if (!_isStarted) { - #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) g_app = new AppDelegate(1, 1); - #elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) g_app = cocos_android_app_init(1, 1); - #endif +#endif EventDispatcher::init(); g_app->start(); _isStarted = true; @@ -78,9 +78,9 @@ NS_CC_BEGIN return const_cast(result.c_str()); } - char* runMethod(const char *methodName, const char *params) { + char* JcWallet::runJsMethod(const char *methodName, const char *paramObj) { std::string methodStr(methodName); - std::string paramsStr(params); + std::string paramsStr(paramObj); std::string jsCode = "jc.wallet."+methodStr+"('" + paramsStr + "')"; se::Value value; jsb_run_code(jsCode, &value); @@ -103,9 +103,10 @@ NS_CC_BEGIN char* importAccount(const char *privateKey) { return JcWallet::getInstance()->importAccount(privateKey); } - char* runWalletMethod(const char *methodName, const char *params) { - return JcWallet::getInstance()->runMethod(methodName, params); + char* runWalletMethod(const char *methodName, const char *paramObj) { + return JcWallet::getInstance()->runJsMethod(methodName, paramObj); } } NS_CC_END + diff --git a/Classes_cocos/JcWallet.h b/Classes_cocos/JcWallet.h index 583058a..7bfa322 100644 --- a/Classes_cocos/JcWallet.h +++ b/Classes_cocos/JcWallet.h @@ -1,19 +1,20 @@ #include "cocos2d.h" #include "base/ccMacros.h" NS_CC_BEGIN -class CC_DLL JcWallet { -public: - void initEnv(); - JcWallet(); - virtual ~JcWallet(); - static JcWallet* getInstance() { return _instance; } - char* initWallet(); - char* signLogin(const char *nonceChar, const char *tipChar); - char* createAccount(); - char* importAccount(const char *privateKey); - char* runMethod(const char *methodName, const char *params); -private: - static JcWallet* _instance; -}; + class CC_DLL JcWallet { + public: + void initEnv(); + JcWallet(); + virtual ~JcWallet(); + static JcWallet* getInstance() { return _instance; } + char* initWallet(); + char* signLogin(const char *nonceChar, const char *tipChar); + char* createAccount(); + char* importAccount(const char *privateKey); + char* runJsMethod(const char *methodName, const char *paramObj); + private: + static JcWallet* _instance; + }; NS_CC_END + diff --git a/Classes_cocos/WalletEvent.cpp b/Classes_cocos/WalletEvent.cpp index 0392a47..a2a2ce7 100644 --- a/Classes_cocos/WalletEvent.cpp +++ b/Classes_cocos/WalletEvent.cpp @@ -5,7 +5,7 @@ // Created by zhl on 2022/7/13. // -#include "WalletEvent.hpp" +#include "WalletEvent.h" // 定义函数指针,用来接受C#的委托 void(*WalletEvent::Emit)(char* name, char* message); diff --git a/Classes_cocos/WalletEvent.h b/Classes_cocos/WalletEvent.h new file mode 100644 index 0000000..19acfba --- /dev/null +++ b/Classes_cocos/WalletEvent.h @@ -0,0 +1,23 @@ +// +// WalletEvent.h +// Unity-iPhone +// +// Created by zhl on 2022/7/13. +// + + +#pragma once +extern "C" +{ +class WalletEvent +{ +public: + static void (*Emit)(char* name, char* message); +}; + +// 注册C#的委托 +void registWalletEventDelegate(void (*Emit)(char* name, char* message)); + +} + + diff --git a/Classes_cocos/WalletEvent.hpp b/Classes_cocos/WalletEvent.hpp deleted file mode 100644 index f96aa0d..0000000 --- a/Classes_cocos/WalletEvent.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// WalletEvent.hpp -// Unity-iPhone -// -// Created by zhl on 2022/7/13. -// - -#ifndef WalletEvent_hpp -#define WalletEvent_hpp - -#include - -#pragma once -#include -#include - -extern "C" -{ - class WalletEvent - { - public: - static void (*Emit)(char* name, char* message); - }; - - // 注册C#的委托 - void registWalletEventDelegate(void (*Emit)(char* name, char* message)); - -} - -#endif /* WalletEvent_hpp */ diff --git a/Unity-iPhone.xcodeproj/project.pbxproj b/Unity-iPhone.xcodeproj/project.pbxproj index 2384fc8..4b316c0 100644 --- a/Unity-iPhone.xcodeproj/project.pbxproj +++ b/Unity-iPhone.xcodeproj/project.pbxproj @@ -347,7 +347,7 @@ AAFE69D119F187C200638316 /* UnityViewControllerListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UnityViewControllerListener.mm; sourceTree = ""; }; C6CC4EECB3BBA57C6F9A8015 /* IUnityInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IUnityInterface.h; path = Classes/Unity/IUnityInterface.h; sourceTree = SOURCE_ROOT; }; D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WalletEvent.cpp; sourceTree = ""; }; - D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WalletEvent.hpp; sourceTree = ""; }; + D5538BA4287E9908000BDFB6 /* WalletEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WalletEvent.h; sourceTree = ""; }; D5F2CED5287BE9C4003C2B62 /* Data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Data; path = ../tebg/Data; sourceTree = ""; }; D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bulk_Generics_3.cpp; sourceTree = ""; }; D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppMethodPointerTable.cpp; sourceTree = ""; }; @@ -822,7 +822,7 @@ D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */, D5F2D105287C12DD003C2B62 /* JcWallet.h */, D5F2D104287C12DD003C2B62 /* JcWallet.cpp */, - D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */, + D5538BA4287E9908000BDFB6 /* WalletEvent.h */, D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */, ); path = Classes_cocos; diff --git a/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate b/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate index 836597b..460a4e4 100644 Binary files a/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate and b/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 8642064..0ed5718 100644 --- a/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Unity-iPhone.xcodeproj/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -20,38 +20,6 @@ landmarkType = "7"> - - - - - - - -