增加一个cpp到c#的回调方法

This commit is contained in:
cebgcontract 2022-07-13 14:59:29 +08:00
parent 34ad023b73
commit c4c56cd7bc
8 changed files with 166 additions and 49 deletions

View File

@ -6,6 +6,7 @@
#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)
@ -46,6 +47,7 @@ NS_CC_BEGIN
se::Value value;
jsb_run_code("jc.wallet.currentAccount().address", &value);
result = value.toString();
WalletEvent::Emit("wallet_inited", "{}");
return const_cast<char*>(result.c_str());
}

View File

@ -0,0 +1,17 @@
//
// WalletEvent.cpp
// Unity-iPhone
//
// Created by zhl on 2022/7/13.
//
#include "WalletEvent.hpp"
// 定义函数指针用来接受C#的委托
void(*WalletEvent::Emit)(char* name, char* message);
// 注册C#的委托
void registWalletEventDelegate(void(*Emit)(char* name, char* message))
{
WalletEvent::Emit = Emit;
}

View File

@ -0,0 +1,30 @@
//
// WalletEvent.hpp
// Unity-iPhone
//
// Created by zhl on 2022/7/13.
//
#ifndef WalletEvent_hpp
#define WalletEvent_hpp
#include <stdio.h>
#pragma once
#include<string.h>
#include<iostream>
extern "C"
{
class WalletEvent
{
public:
static void (*Emit)(char* name, char* message);
};
// 注册C#的委托
void registWalletEventDelegate(void (*Emit)(char* name, char* message));
}
#endif /* WalletEvent_hpp */

View File

@ -76,6 +76,7 @@
B39C4391A8C22B442413FE00 /* LaunchScreen-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 90994FBFA981DC89AB1ADF90 /* LaunchScreen-iPad.xib */; };
C7134CE09546D0C147DAA3D3 /* LaunchScreen-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 5C824C7597221AFF9649D008 /* LaunchScreen-iPad.png */; };
D0DD4D8D8AC82F06A4331428 /* libil2cpp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 924940699744FB37428516DD /* libil2cpp.a */; };
D5538BA5287E9908000BDFB6 /* WalletEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */; };
D5F2CED6287BE9C4003C2B62 /* Data in Resources */ = {isa = PBXBuildFile; fileRef = D5F2CED5287BE9C4003C2B62 /* Data */; };
D5F2CF41287BEC0D003C2B62 /* Bulk_Generics_3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */; };
D5F2CF42287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */; };
@ -345,6 +346,8 @@
AAFE69D019F187C200638316 /* UnityViewControllerListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnityViewControllerListener.h; sourceTree = "<group>"; };
AAFE69D119F187C200638316 /* UnityViewControllerListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UnityViewControllerListener.mm; sourceTree = "<group>"; };
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 = "<group>"; };
D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = WalletEvent.hpp; sourceTree = "<group>"; };
D5F2CED5287BE9C4003C2B62 /* Data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Data; path = ../tebg/Data; sourceTree = "<group>"; };
D5F2CED8287BEC0D003C2B62 /* Bulk_Generics_3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Bulk_Generics_3.cpp; sourceTree = "<group>"; };
D5F2CED9287BEC0D003C2B62 /* Il2CppMethodPointerTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Il2CppMethodPointerTable.cpp; sourceTree = "<group>"; };
@ -814,11 +817,13 @@
D5F2CFAB287BF3BD003C2B62 /* Classes_cocos */ = {
isa = PBXGroup;
children = (
D5F2CFAC287BF3BD003C2B62 /* AppDelegate.h */,
D5F2CFAE287BF3BD003C2B62 /* NativeConfig.h */,
D5F2CFAC287BF3BD003C2B62 /* AppDelegate.h */,
D5F2CFAF287BF3BD003C2B62 /* AppDelegate.cpp */,
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
D5F2D105287C12DD003C2B62 /* JcWallet.h */,
D5F2D104287C12DD003C2B62 /* JcWallet.cpp */,
D5538BA4287E9908000BDFB6 /* WalletEvent.hpp */,
D5538BA3287E9908000BDFB6 /* WalletEvent.cpp */,
);
path = Classes_cocos;
sourceTree = "<group>";
@ -1053,6 +1058,7 @@
D5F2CF98287BEC0D003C2B62 /* Bulk_UnityEngine_0.cpp in Sources */,
D5F2CF64287BEC0D003C2B62 /* Il2CppCompilerCalculateTypeValues_11Table.cpp in Sources */,
8A3EDDC81615B7C1001839E9 /* SplashScreen.mm in Sources */,
D5538BA5287E9908000BDFB6 /* WalletEvent.cpp in Sources */,
D5F2CFA7287BEC0D003C2B62 /* Bulk_UnityEngine.UI_2.cpp in Sources */,
8AC71EC419E7FBA90027502F /* OrientationSupport.mm in Sources */,
D5F2CFA5287BEC0D003C2B62 /* Bulk_Assembly-CSharp_0.cpp in Sources */,

View File

@ -30,8 +30,8 @@
filePath = "Classes_cocos/JcWallet.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "53"
endingLineNumber = "53"
startingLineNumber = "55"
endingLineNumber = "55"
landmarkName = "JcWallet::signLogin(nonceChar, tipChar)"
landmarkType = "7">
</BreakpointContent>
@ -46,8 +46,8 @@
filePath = "Classes_cocos/JcWallet.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
endingLineNumber = "63"
startingLineNumber = "65"
endingLineNumber = "65"
landmarkName = "JcWallet::createAccount()"
landmarkType = "7">
</BreakpointContent>
@ -56,7 +56,7 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "3116743D-0CBB-4D4D-BB44-E08064BF250E"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../../../cocos/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_global.cpp"

View File

@ -1,41 +1,103 @@
{
"images" : [
{
"filename" : "Icon-iPhone-120.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "Icon-iPhone-180.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"filename" : "Icon-iPad-76.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"filename" : "Icon-iPad-152.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"filename" : "Icon-iPad-167.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"pre-rendered" : false
}
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"filename" : "Icon-iPhone-120.png",
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"filename" : "Icon-iPhone-180.png",
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"filename" : "Icon-iPad-76.png",
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"filename" : "Icon-iPad-152.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"filename" : "Icon-iPad-167.png",
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

File diff suppressed because one or more lines are too long