Browse Source

增加自动修改.mm功能

jet 8 năm trước cách đây
mục cha
commit
83908a027b

+ 0 - 25
Assets/AtlasUtility/Script/Editor/TestEditor.cs

@@ -30,31 +30,6 @@
 
             if (GUILayout.Button("Test"))
             {
-                List<string> lines = new List<string>();
-
-                StreamReader streamReader = new StreamReader(@"C:\Users\Administrator\Desktop\新建文本文档.txt");
-
-                string line = "";
-
-                while (!string.IsNullOrEmpty(line = streamReader.ReadLine()))
-                {
-                    lines.Add(line);
-                }
-
-                streamReader.Close();
-
-        //        lines.Insert("if ([url.host isEqualToString:@"safepay"]) {
-        ////跳转支付宝钱包进行支付,处理支付结果
-        //[[AlipaySDK defaultService] processOrderWithPaymentResult: url standbyCallback:^ (NSDictionary * resultDic) {
-        //            NSLog(@"result 1 = %@", resultDic);
-        //        }];
-        //    }
-        //    ");
-
-                StreamWriter streamWriter = new StreamWriter(@"C:\Users\Administrator\Desktop\新建文本文档.txt");
-
-                streamWriter.Close();
-
                 //Texture2D texture2D = new Texture2D(Script.Texture2D.width, Script.Texture2D.height, TextureFormat.RGBA32, false);
 
                 //for (int i = 0; i < texture2D.width; i++)

+ 0 - 18
Assets/Resource/Logo.unity

@@ -427,7 +427,6 @@ GameObject:
   m_Component:
   - component: {fileID: 1833966245}
   - component: {fileID: 1833966244}
-  - component: {fileID: 1833966246}
   m_Layer: 0
   m_Name: ManagerGame
   m_TagString: Untagged
@@ -461,20 +460,3 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!114 &1833966246
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_PrefabParentObject: {fileID: 0}
-  m_PrefabInternal: {fileID: 0}
-  m_GameObject: {fileID: 1833966243}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: ef3c42f14ba649d4aaf2ea3afe194ba7, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  Sprite: {fileID: 0}
-  Graphic: {fileID: 0}
-  TextAsset1: {fileID: 0}
-  TextAsset2: {fileID: 0}
-  Texture2D: {fileID: 0}
-  SpriteRenderer: {fileID: 0}

+ 54 - 4
Assets/Script/Editor/PostProcessor.cs

@@ -55,21 +55,71 @@ public class NewBehaviourScript
         PlistDocument plist = new PlistDocument();
 
         plist.ReadFromFile(plistPath);
-        
+
         plist.root.SetString("Bundle display name", "${CFBundleDisplayName }");
 
-        var infoDirs = Directory.GetDirectories(Application.dataPath + "/AppleDependency/");
+        var infoDirs = Directory.GetDirectories(Application.dataPath + "\\AppleDependency");
         for (var i = 0; i < infoDirs.Length; ++i)
         {
             var files = Directory.GetFiles(infoDirs[i], "*.strings");
             project.AddLocalization(files[0], "InfoPlist.strings", "InfoPlist.strings");
         }
-        
+
 
         //修改UnityAppController.mm
         string scriptPath = buildPath + "/Classes/UnityAppController.mm";
 
+        List<string> lines = new List<string>();
+
+        StreamReader streamReader = new StreamReader(scriptPath);
+
+        string line = "";
 
+        while (!string.IsNullOrEmpty(line = streamReader.ReadLine()))
+        {
+            lines.Add(line);
+        }
+
+        streamReader.Close();
+
+        lines.Insert
+            (
+                0,
+                "#import <AlipaySDK/AlipaySDK.h>"
+            );
+
+        lines.Insert
+            (
+                231,
+                "if ([url.host isEqualToString:@\"safepay\"]) {\n" +
+                "//跳转支付宝钱包进行支付,处理支付结果\n" +
+                "[[AlipaySDK defaultService] processOrderWithPaymentResult: url standbyCallback:^ (NSDictionary * resultDic) {\n" +
+                "NSLog(@\"result 1 = % @\", resultDic);\n" +
+                " }];\n" +
+                "}\n"
+            );
+
+        lines.Insert
+            (
+                247,
+                "// NOTE: 9.0以后使用新API接口\n" +
+                "-(BOOL)application:(UIApplication*)app openURL: (NSURL*)url options: (NSDictionary<NSString*, id>*)options\n" +
+                "{\n" +
+                "if ([url.host isEqualToString: @\"safepay\"])\n" +
+                "{\n" +
+                "//跳转支付宝钱包进行支付,处理支付结果\n" +
+                "[[AlipaySDK defaultService]\n" +
+                "processOrderWithPaymentResult:url standbyCallback:^(NSDictionary* resultDic) {\n" +
+                "NSLog(@\"result 2 = % @\", resultDic);\n" +
+                "}];\n" +
+                "}\n" +
+                "return YES;\n" +
+                "}\n"
+            );
+
+        StreamWriter streamWriter = new StreamWriter(scriptPath);
+
+        streamWriter.Close();
 
 
         //添加URLScheme
@@ -81,7 +131,7 @@ public class NewBehaviourScript
         PlistElementArray urlInnerArray = urlDict.CreateArray("TestScheme");
         urlInnerArray.AddString("TestValue");
 
-       
+
         //保存Plist
         plist.WriteToFile(plistPath);