private static void EditorCode(string filePath)
    {
        UnityEditor.XCodeEditor.XClass UnityAppControllerH = new UnityEditor.XCodeEditor.XClass(filePath + "/Classes/UnityAppController.h");
        UnityAppControllerH.WriteBelow("#include \"PluginBase/RenderPluginDelegate.h\"", "#include \"WXApi.h\"");
        UnityAppControllerH.Replace("@interface UnityAppController : NSObject<UIApplicationDelegate>", "@interface UnityAppController : NSObject<UIApplicationDelegate, WXApiDelegate>");
        UnityAppControllerH.WriteBelow("- (void)startUnity:(UIApplication*)application;", "+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGFloat)newSize;");

        UnityEditor.XCodeEditor.XClass UnityAppControllerMM = new UnityEditor.XCodeEditor.XClass(filePath + "/Classes/UnityAppController.mm");
        UnityAppControllerMM.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"", "#include \"WechatTool/MXWechatConfig.h\"");
        UnityAppControllerMM.WriteBelow("@implementation UnityAppController", "#pragma mark - WXApiDelegate\n\n#define WeiXinID @\"wxafd936830b3cf60f\"\n\n#define WeiXinSecret @\"e72afcd7738d3fb3c6a6600f7a8f299f\"\n\n#define ksendAuthRequestNotification @\"ksendAuthRequestNotification\"\n// 支付\n#define ksendPayRequestNotification @\"ksendPayRequestNotification\"\n\n#define GameObjectName \"Logic\"\n\n#define MethodName \"GetCode\"\n\n#define ShareMethod \"Weixincallback_shareSuccess\"\n\nextern \"C\"\n{\n    bool isWXAppInstalled()\n    {\n        return [WXApi isWXAppInstalled];\n    }\n    bool isWXAppSupportApi()\n    {\n        return [WXApi isWXAppSupportApi];\n    }\n    // 给Unity3d调用的方法\n    void weixinLoginByIos()\n    {\n        // 登录\n        [[NSNotificationCenter defaultCenter] postNotificationName:ksendAuthRequestNotification object:nil];\n    }\n    \n    void weixinPay()\n    {\n        //发起微信支付\n        [MXWechatPayHandler jumpToWxPay];\n\n        // 登录\n        // [[NSNotificationCenter defaultCenter] postNotificationName:ksendPayRequestNotification object:nil];\n    }\n    \n    void weixinPayByPrepayID(const char* prepayid)\n    {\n        //发起微信支付\n        NSString *prepayidstr=[NSString stringWithUTF8String:prepayid];\n        [MXWechatPayHandler payByPrepayID:prepayidstr];\n        \n        // 登录\n        // [[NSNotificationCenter defaultCenter] postNotificationName:ksendPayRequestNotification object:nil];\n    }\n\n    \n    void ShareByIos(const char* title,const char*desc,const char*url)\n    {\n        NSString *urlStr=[NSString stringWithUTF8String:url];\n        NSString *filePath = [[NSBundle mainBundle]pathForResource:urlStr ofType:@\"png\"];\n        WXImageObject *ext = [WXImageObject object];\n        UIImage *image = [UIImage imageNamed:urlStr];\n        NSData *data = UIImageJPEGRepresentation(image,0.5);\n        ext.imageData = data;\n        //ext.imageUrl = filePath ;\n        WXMediaMessage *message = [WXMediaMessage message];\n        UIImage *imagea = [UIImage imageWithData:data];\n        UIImage* thumbImage = [UnityAppController imageWithImage:image scaledToSize:320];\n        message.mediaObject = ext;\n        [message setThumbImage:thumbImage];\n        SendMessageToWXReq* req = [[[SendMessageToWXReq alloc] init]autorelease];\n        req.bText = NO;\n        req.message = message;\n        req.scene = WXSceneSession;\n        \n        [WXApi sendReq:req];\n    }\n    \n    void ShareWebByIos(const char* title,const char*desc,const char*url)\n    {\n        NSString *titleStr=[NSString stringWithUTF8String:title];\n        NSString *descStr=[NSString stringWithUTF8String:desc];//0416aa28b5d2ed1f3199083b3806c6bl\n        NSString *urlStr=[NSString stringWithUTF8String:url];\n        NSLog(@\"ShareByIos titleStr:%@\",titleStr);\n        NSLog(@\"ShareByIos descStr:%@\",descStr);\n        NSLog(@\"ShareByIos urlStr:%@\",urlStr);\n        //UIImage *img=[UIImage imageNamed:urlStr];\n        //                        NSLog(@\"ShareByIos img:%@\",img);\n        // 分享\n        WXMediaMessage *message = [WXMediaMessage message];\n        message.title = titleStr;\n        message.description = descStr;\n        [message setThumbImage:[UIImage imageNamed:@\"AppIcon72x72\"]];\n        //[message setThumbImage:[UIImage imageNamed:urlStr]];\n        \n        WXWebpageObject *ext = [WXWebpageObject object];\n        ext.webpageUrl = urlStr;\n        \n        message.mediaObject = ext;\n        message.mediaTagName = @\"WECHAT_TAG_SHARE\";\n        //message.thumbData = UIImagePNGRepresentation(img);\n        //[message setThumbImage:img];\n        \n        SendMessageToWXReq* req = [[[SendMessageToWXReq alloc] init]autorelease];\n        req.bText = NO;\n        req.message = message;\n        req.scene = WXSceneSession;\n        [WXApi sendReq:req];\n    }\n}\n\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n    return [WXApi handleOpenURL:url delegate:self];\n}\n\n- (void)onReq:(BaseReq *)req // 微信向第三方程序发起请求,要求第三方程序响应\n{\n    \n}\n\n- (void)onResp:(BaseResp *)resp // 第三方程序向微信发送了sendReq的请求,那么onResp会被回调\n{\n    if([resp isKindOfClass:[SendAuthResp class]]) // 登录授权\n    {\n        SendAuthResp *temp = (SendAuthResp*)resp;\n        if(temp.code!=nil)UnitySendMessage(GameObjectName, MethodName, [temp.code cStringUsingEncoding:NSUTF8StringEncoding]);\n        \n        //        [self getAccessToken:temp.code];\n    }\n    else if([resp isKindOfClass:[SendMessageToWXResp class]])\n    {\n        // 分享\n        if(resp.errCode==0)\n        {\n            NSString *code = [NSString stringWithFormat:@\"%d\",resp.errCode]; // 0是成功 -2是取消\n            NSLog(@\"SendMessageToWXResp:%@\",code);\n            UnitySendMessage(GameObjectName, ShareMethod, [code cStringUsingEncoding:NSUTF8StringEncoding]);\n        }\n    }\n    else if([resp isKindOfClass:[PayResp class]])\n    {\n        NSString *code = [NSString stringWithFormat:@\"%d\",resp.errCode]; // 0是成功 -2是取消\n        NSLog(@\"PayResp:%@\",code);\n        if(resp.errCode==0)\n        {\n            \n            UnitySendMessage(GameObjectName, \"PaySuccess\", [@\"1\" cStringUsingEncoding:NSUTF8StringEncoding]);\n        }\n        else if(resp.errCode==-2)\n        {\n            UnitySendMessage(GameObjectName, \"PaySuccess\", [@\"2\" cStringUsingEncoding:NSUTF8StringEncoding]);\n        }\n        else\n        {\n            UnitySendMessage(GameObjectName, \"PaySuccess\", [@\"3\" cStringUsingEncoding:NSUTF8StringEncoding]);\n        }\n    }\n}\n\n#pragma mark - Private\n\n- (void)sendAuthRequest\n\n{\n    SendAuthReq* req = [[[SendAuthReq alloc] init] autorelease];\n    req.scope = @\"snsapi_userinfo\";\n    req.state = @\"only123\";\n    [WXApi sendAuthReq:req viewController:_rootController delegate:self];\n    \n}\n\n- (void)sendPayRequest\n\n{\n    PayReq *req = [[[PayReq alloc] init] autorelease];\n    req.partnerId = @\"1449873902\";\n    req.prepayId= @\"1101000000140415649af9fc314aa427\";\n    req.package = @\"Sign=WXPay\";\n    NSTimeInterval time = [[NSDate date] timeIntervalSince1970];\n    req.nonceStr= @\"a462b76e7436e98e0fjhe13c64b4fd1c\";\n    req.timeStamp= 12345;\n    req.sign= @\"582282D72DD2B03AD892830965F428CB16E7A256\";\n    [WXApi sendReq:req];\n}\n\n\n\n- (void)getAccessToken:(NSString *)code\n\n{\n    \n    NSString *path = [NSString stringWithFormat:@\"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=authorization_code\",WeiXinID,WeiXinSecret,code];\n    \n    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:path] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];\n    \n    NSOperationQueue *queue = [[NSOperationQueue alloc] init];\n    \n    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:\n     \n     ^(NSURLResponse *response,NSData *data,NSError *connectionError)\n     \n     {\n         \n         if (connectionError != NULL)\n             \n         {\n             \n         }\n         else\n             \n         {\n             \n             if (data != NULL)\n                 \n             {\n                 \n                 NSError *jsonParseError;\n                 \n                 NSDictionary *responseData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonParseError];\n                 \n                 NSLog(@\"#####responseData = %@\",responseData);\n                 \n                 if (jsonParseError != NULL)\n                     \n                 {\n                     \n                     //                    NSLog(@\"#####responseData = %@\",jsonParseError);\n                     \n                 }\n                 \n                 NSString *accessToken = [responseData valueForKey:@\"access_token\"];\n                 \n                 NSString *openid = [responseData valueForKey:@\"openid\"];\n                 \n                 [self getUserInfo:accessToken withOpenID:openid];\n                 \n             }\n             \n         }\n         \n     }];\n    \n}\n\n- (void)getUserInfo:(NSString *)accessToken withOpenID: (NSString *)openid\n\n{\n    \n    NSString *path = [NSString stringWithFormat:@\"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@\",accessToken,openid];\n    \n    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:path] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];\n    \n    NSOperationQueue *queue = [[NSOperationQueue alloc] init];\n    \n    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:\n     \n     ^(NSURLResponse *response,NSData *data,NSError *connectionError) {\n         \n         if (connectionError != NULL) {\n             \n             \n             \n         } else {\n             \n             if (data != NULL) {\n                 \n                 NSError *jsonError;\n                 \n                 NSString *responseData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];\n                 \n                 NSLog(@\"#####responseData = %@\",responseData);\n                 \n                 NSString *jsonData = [NSString stringWithFormat:@\"%@\",responseData];\n                 \n                 UnitySendMessage(GameObjectName, MethodName, [jsonData cStringUsingEncoding:NSUTF8StringEncoding]);\n                 \n                 if (jsonError != NULL) {\n                     \n                     //                     NSLog(@\"#####responseData = %@\",jsonError);\n                     \n                 }\n                 \n             }\n             \n         }\n         \n     }];\n    \n}\n#pragma mark -\n");
        UnityAppControllerMM.Replace("NSMutableArray* keys\t= [NSMutableArray arrayWithCapacity:3];\n\tNSMutableArray* values\t= [NSMutableArray arrayWithCapacity:3];\n\n\tauto addItem = [&](NSString* key, id value)\n\t{\n\t\t[keys addObject:key];\n\t\t[values addObject:value];\n\t};\n\n\taddItem(@\"url\", url);\n\taddItem(@\"sourceApplication\", sourceApplication);\n\taddItem(@\"annotation\", annotation);\n\n\tNSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys];\n\tAppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn YES;", "NSMutableArray* keys    = [NSMutableArray arrayWithCapacity:3];\n    NSMutableArray* values    = [NSMutableArray arrayWithCapacity:3];\n    \n#define ADD_ITEM(item)    do{ if(item) {[keys addObject:@#item]; [values addObject:item];} }while(0)\n    \n    ADD_ITEM(url);\n    ADD_ITEM(sourceApplication);\n    ADD_ITEM(annotation);\n    \n#undef ADD_ITEM\n    \n    NSDictionary* notifData = [NSDictionary dictionaryWithObjects:values forKeys:keys];\n    AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn [WXApi handleOpenURL:url delegate:self];");
        UnityAppControllerMM.WriteBelow("[KeyboardDelegate Initialize];\n", "// wx\n    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendAuthRequest) name:ksendAuthRequestNotification object:nil]; // 微信登录\n    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendPayRequest) name:ksendPayRequestNotification object:nil]; // 微信支付\n\n    \n    //向微信注册\n    [WXApi registerApp:WeiXinID];");
        UnityAppControllerMM.WriteBelow("- (void)startUnity:(UIApplication*)application\n{\n\tNSAssert(_unityAppReady == NO, @\"[UnityAppController startUnity:] called after Unity has been initialized\");\n\n\tUnityInitApplicationGraphics(UNITY_FORCE_DIRECT_RENDERING);\n\n\t// we make sure that first level gets correct display list and orientation\n\t[[DisplayManager Instance] updateDisplayListInUnity];\n\n\tUnityLoadApplication();\n\tProfiler_InitProfiler();\n\n\t[self showGameUI];\n\t[self createDisplayLink];\n\n\tUnitySetPlayerFocus(1);\n}", "\n+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGFloat)newSize\n{\n    CGFloat W = image.size.width;\n    CGFloat H = image.size.height;\n    CGFloat scaleFactorW = newSize / W;\n    CGFloat scaleFactorH = newSize / H;\n    CGFloat scaleFactor = MIN(scaleFactorH, scaleFactorW);\n    CGFloat newW = W * scaleFactor;\n    CGFloat newH = H * scaleFactor;\n    \n    if (W < newSize || H < newSize) {\n        return image;\n    }\n    \n    CGSize size = CGSizeMake(newW, newH);\n    UIGraphicsBeginImageContext(size);\n    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];\n    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();\n    UIGraphicsEndImageContext();\n    return newImage;\n}\n");
    }
    private static void EditorCode(string filePath)
    {
        //读取UnityAppController.mm文件
        XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm");

        //在指定代码后面增加一行代码
        UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <ShareSDK/ShareSDK.h>");

        //在指定代码中替换一行
        UnityAppController.Replace("return YES;","return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];");

        //在指定代码后面增加一行
        UnityAppController.WriteBelow("UnityCleanup();\n}","- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\r{\r    return [ShareSDK handleOpenURL:url wxDelegate:nil];\r}");
    }
Exemple #3
0
        public void ProcessTextModify(Hashtable items)
        {
            foreach (DictionaryEntry kv in items)
            {
                string    k = (string)kv.Key;
                Hashtable v = (Hashtable)kv.Value;
                if (k == null || k.Trim().Length == 0 || null == v)
                {
                    Debug.Log(string.Format("textmodify item error(k:{0})",
                                            k == null ? "[null]" : k,
                                            v == null ? 0 : v.Count));
                    continue;
                }

                string filePath = Path.Combine(this.projectRootPath, k);
                if (File.Exists(filePath))
                {
                    XClass xclass = new XClass(filePath);

                    ArrayList beforeList = (ArrayList)v["before"];
                    ProcessWriteText("before", beforeList, xclass.WriteAbove);

                    ArrayList afterList = (ArrayList)v["after"];
                    ProcessWriteText("after", afterList, xclass.WriteBelow);

                    ArrayList replaceList = (ArrayList)v["replace"];
                    ProcessWriteText("replace", replaceList, xclass.Replace);

                    string addText = (string)v["add"];
                    if (null != addText)
                    {
                        xclass.Add(addText);
                    }
                }
                else
                {
                    Debug.LogError(string.Format("text modify file '{0}' not found!!!", filePath));
                }
            }
        }
Exemple #4
0
        static void AddExtCode(string filePath)
        {
            if (JoyYouSDKPlugin.PlatformSDK == ProjectPlatform.PP)
            {
                //读取UnityAppController.mm文件
                XClass UnityAppController = new XClass(filePath + "/Classes/UnityAppController.mm");

                //在指定代码后面增加一行代码
                UnityAppController.WriteBelow("#include \"PluginBase/AppDelegateListener.h\"","#import <PPAppPlatformKit/PPAppPlatformKit.h>");

                //在指定代码中替换一行
                //UnityAppController.Replace("return YES;","return [ShareSDK handleOpenURL:url sourceApplication:sourceApplication annotation:annotation wxDelegate:nil];");

                //在指定代码后面增加一行
                UnityAppController.WriteBelow("UnityCleanup();\n}",
            @"
            - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
            [[PPAppPlatformKit sharedInstance] alixPayResult:url];
            return YES;
            }");
            }
        }
    //安卓处理
    static private void postProcessBuild_Android(string path)
    {
        //修改build.gradle
        UnityEditor.XCodeEditor.XClass buidGradle = new UnityEditor.XCodeEditor.XClass(path + "/build.gradle");
        buidGradle.Replace("storePassword ''", "storePassword '123456'");
        buidGradle.Replace("keyPassword ''", "keyPassword '123456'");
        buidGradle.WriteBelow("signingConfigs { release {", "storeFile file('/Users/wudongyang/Desktop/majiang/client/keystore/qingshui.keystore')\n\t\tstorePassword '123456'\n\t\tkeyAlias 'qingshui'\n\t\tkeyPassword '123456'\n\t}\n\tdebug{");
        buidGradle.WriteBelow("\t\tclasspath 'com.android.tools.build:gradle:2.1.0'", "\t\tclasspath 'com.mob.sdk:MobSDK:+'");
        buidGradle.WriteBelow("apply plugin: 'com.android.application'", "// 添加插件\napply plugin: 'com.mob.sdk'\n\n// 在MobSDK的扩展中注册PaySDK的相关信息\nMobSDK {\n\tappKey \"2324aeba579a0\"\n\tappSecret \"39388cda43b2e7f37ff706210da4f78f\"\n\n\tPaySDK {}\n}");


        //修改AndroidManifest
        UnityEditor.XCodeEditor.XClass manifest = new UnityEditor.XCodeEditor.XClass(path + "/src/main/AndroidManifest.xml");
        manifest.WriteBelow("<uses-permission android:name=\"android.permission.INTERNET\" />",
                            "    <uses-permission android:name=\"android.permission.GET_TASKS\" />\n" +
                            "    <uses-permission android:name=\"android.permission.INTERNET\" />\n" +
                            "    <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />\n" +
                            "    <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\n" +
                            "    <uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />\n" +
                            "    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n" +
                            "    <uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />\n" +
                            "    <uses-permission android:name=\"android.permission.MANAGE_ACCOUNTS\"/>\n" +
                            "    <uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>\n" +
                            "    <uses-permission android:name=\"android.permission.RECEIVE_SMS\" />\n" +
                            "    <!-- 蓝牙分享所需的权限 -->\n" +
                            "    <uses-permission android:name=\"android.permission.BLUETOOTH\" />\n" +
                            "    <uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />");
        manifest.WriteAbove("</application>", "<activity\n            android:name=\"com.mob.tools.MobUIShell\"\n            android:configChanges=\"keyboardHidden|orientation|screenSize\"\n            android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\n            android:windowSoftInputMode=\"stateHidden|adjustResize\" >\n       \n\t\t \t<!-- 新浪回调 -->\n            <intent-filter>\n\t\t\t\t<action android:name=\"com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY\" />\n\t\t\t\t\t\t<category android:name=\"android.intent.category.DEFAULT\" />\n\t\t\t\t</intent-filter>\n\t\t\t\t <!-- 集成Line客户端登录授权,需要添加如下格式的过滤器 -->\n            <intent-filter android:priority=\"1000\">\n               <action android:name=\"android.intent.action.VIEW\" />\n               <category android:name=\"android.intent.category.DEFAULT\" />\n               <category android:name=\"android.intent.category.BROWSABLE\" />\n  \t\t\t\t\t\t <data android:scheme=\"line.1477692153\" />\n            </intent-filter>\t\n        </activity>\n\n        <!--\n            如果集成QQ分享,或者使用QQ客户端来进行QQ空间的分享,须要在此处添加一个回调activity,\n            对ACTION_VIEW事件的过滤器,其中的scheme是“tencent”前缀再开发者应用的加上appId。如\n            果此过滤器不设置,则分享结束以后不能得到正确的回调\n        -->\n        <activity\n            android:name=\"cn.sharesdk.tencent.qq.ReceiveActivity\"\n            android:launchMode=\"singleTask\"\n            android:noHistory=\"true\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.VIEW\" />\n                <category android:name=\"android.intent.category.DEFAULT\" />\n                <category android:name=\"android.intent.category.BROWSABLE\" />\n                <data android:scheme=\"tencent100371282\" />\n            </intent-filter>\n        </activity>\n\n        <!-- 微信分享回调 -->\n        <activity\n            android:name=\".wxapi.WXEntryActivity\"\n            android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\n            android:configChanges=\"keyboardHidden|orientation|screenSize\"\n            android:exported=\"true\" />\n        <!-- 易信分享回调 -->\n        <activity\n            android:name=\".yxapi.YXEntryActivity\"\n            android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\n            android:configChanges=\"keyboardHidden|orientation|screenSize\"\n            android:excludeFromRecents=\"true\"\n            android:exported=\"true\"\n            android:launchMode=\"singleTop\" />\t\t\t\n        <!-- 支付宝分享回调 -->\n        <activity\n            android:name=\".apshare.ShareEntryActivity\"\n            android:theme=\"@android:style/Theme.Translucent.NoTitleBar\"\n            android:configChanges=\"keyboardHidden|orientation|screenSize\"\n            android:exported=\"true\"/>\n\n        <meta-data android:name=\"Mob-AppKey\" android:value=\"2324aeba579a0\"/>\n        <meta-data android:name=\"Mob-AppSecret\" android:value=\"39388cda43b2e7f37ff706210da4f78f\"/>");

        //修改proguard-unity.txt
        UnityEditor.XCodeEditor.XClass proguard = new UnityEditor.XCodeEditor.XClass(path + "/proguard-unity.txt");
        proguard.WriteBelow("-keep class org.fmod.* { *; }", "-keep class com.mob.**{*;}\n-dontwarn com.mob.**");

        //拷贝文件
        string sdkAndroidProject = Application.dataPath.Replace("Assets", "SdkAndroidProject");

        DirectoryCopy(sdkAndroidProject, path + "/src/main/java/com/gsqsjh/qsmj");
    }
Exemple #6
0
		public void ApplyMod(XCMod mod)
		{	
			PBXGroup modGroup = this.GetGroup(mod.group);
			
			Debug.Log("Adding libraries...");
			
			foreach (XCModFile libRef in mod.libs)
			{
				string completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
				Debug.Log("Adding library " + completeLibPath);
				this.AddFile(completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak);
			}
			
			Debug.Log("Adding frameworks...");
			PBXGroup frameworkGroup = this.GetGroup("Frameworks");
			foreach (string framework in mod.frameworks)
			{
				string[] filename = framework.Split(':');
				bool isWeak = (filename.Length > 1) ? true : false;
				string completePath = System.IO.Path.Combine("System/Library/Frameworks", filename[0]);
				this.AddFile(completePath, frameworkGroup, "SDKROOT", true, isWeak);
			}

			Debug.Log("Adding files...");
			foreach (string filePath in mod.files)
			{
				string absoluteFilePath = System.IO.Path.Combine(mod.path, filePath);
				this.AddFile(absoluteFilePath, modGroup);
			}

			Debug.Log("Adding embed binaries...");
			if (mod.embed_binaries != null)
			{
				//1. Add LD_RUNPATH_SEARCH_PATHS for embed framework
				this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Release");
				this.overwriteBuildSetting("LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks", "Debug");

				foreach (string binary in mod.embed_binaries)
				{
					string absoluteFilePath = System.IO.Path.Combine(mod.path, binary);
					this.AddEmbedFramework(absoluteFilePath);
				}
			}
			
			Debug.Log("Adding folders...");
			foreach (string folderPath in mod.folders)
			{
				string absoluteFolderPath = System.IO.Path.Combine(Application.dataPath, folderPath);
				Debug.Log("Adding folder " + absoluteFolderPath);
				this.AddFolder(absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray(typeof(string)));
			}
			
			Debug.Log("Adding headerpaths...");
			foreach (string headerpath in mod.headerpaths)
			{
				if (headerpath.Contains("$(inherited)"))
				{
					Debug.Log("not prepending a path to " + headerpath);
					this.AddHeaderSearchPaths(headerpath);
				}
				else
				{
					string absoluteHeaderPath = System.IO.Path.Combine(mod.path, headerpath);
					this.AddHeaderSearchPaths(absoluteHeaderPath);
				}
			}

			Debug.Log("Adding compiler flags...");
			foreach (string flag in mod.compiler_flags)
			{
				this.AddOtherCFlags(flag);
			}

			Debug.Log("Adding linker flags...");
			foreach (string flag in mod.linker_flags)
			{
				this.AddOtherLinkerFlags(flag);
			}

			Debug.Log("Adding plist items...");
			string plistPath = this.projectRootPath + "/Info.plist";
			XCPlist plist = new XCPlist(plistPath);
			plist.Process(mod.plist);

			Debug.Log("Adding classes...");
			string classesPath = this.projectRootPath + "/Classes/";
			XClass xclass = new XClass(classesPath);
			xclass.Process(mod.classes);


			this.Consolidate();
		}