提交
This commit is contained in:
Regular → Executable
+231
-232
@@ -1,232 +1,231 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using MYp0ZVTT2QSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MYp0ZVTT2QSDKDemo : MonoBehaviour
|
||||
{
|
||||
public void ShowReward()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowRewardVideo("TAG", b =>
|
||||
{
|
||||
Debug.LogError($"reward result = {b}");
|
||||
},(() =>
|
||||
{
|
||||
Debug.LogError($"reward close!!!");
|
||||
}));
|
||||
}
|
||||
|
||||
public void ShowInter()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowInter("TAG", () =>
|
||||
{
|
||||
Debug.LogError("inter hide");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowAdmobInter()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowAdmobInter("TAG", () =>
|
||||
{
|
||||
Debug.LogError("inter hide");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowSplash()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowSplash();
|
||||
}
|
||||
|
||||
public void CheckReward(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsVideoReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Reward : {isReady}");
|
||||
}
|
||||
|
||||
public void CheckInter(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsInterReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Inter : {isReady}");
|
||||
}
|
||||
|
||||
public void CheckSplash(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsSplashReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Splash : {isReady}");
|
||||
}
|
||||
|
||||
public void Track()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.Track("test", new Dictionary<string, string>()
|
||||
{
|
||||
{"evt1", "1"},
|
||||
{"evt2", "2"},
|
||||
{"evt3", "3"},
|
||||
{"evt4", "4"},
|
||||
{"evt5", "5"},
|
||||
{"evt6", "6"},
|
||||
{"evt7", "7"},
|
||||
{"evt8", "8"},
|
||||
{"evt9", "9"},
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GetCountryCode()
|
||||
{
|
||||
|
||||
var code = MYp0ZVTT2QSDKHelper.Instance.GetCountryCode();
|
||||
Debug.Log($"country : {code}");
|
||||
}
|
||||
|
||||
public void ShowH5()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5((() =>
|
||||
{
|
||||
Debug.Log("H5 close");
|
||||
}), () =>
|
||||
{
|
||||
Debug.Log($"H5 show failed!");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowH5(RectTransform rectTransform)
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5(rectTransform);
|
||||
}
|
||||
|
||||
public void HideH5()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.HideH5();
|
||||
}
|
||||
|
||||
public void CheckShowH5(Image btnImg)
|
||||
{
|
||||
var show = MYp0ZVTT2QSDKHelper.Instance.H5.IsShowH5();
|
||||
btnImg.color = show ? Color.green : Color.red;
|
||||
Debug.Log($"CheckShowH5 : {show}");
|
||||
}
|
||||
|
||||
private int _level = 1;
|
||||
public void TrackLevel()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.TrackLevelUp(_level);
|
||||
if (Random.Range(0, 100) < 50)
|
||||
{
|
||||
_level++;
|
||||
}
|
||||
}
|
||||
|
||||
private string withDrawSceneId = "";
|
||||
public void GetWithDrawConfigs()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawConfigs(((b, s) =>
|
||||
{
|
||||
Debug.Log($"GetWithDrawConfigs result : {b}, data : {s}");
|
||||
if (b)
|
||||
{
|
||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawConfig>>(s);
|
||||
int idx = 0;
|
||||
foreach (WithDrawConfig config in cfgs)
|
||||
{
|
||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||
if (idx == 0)
|
||||
withDrawSceneId = config.SecneId;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
private int payIndex = 0;
|
||||
public void CreateWithDrawOrder()
|
||||
{
|
||||
string taxNo = "99999999999";
|
||||
string payAccount = "tom@gmail.com";
|
||||
string accountType = "E";
|
||||
string payeeName = "testName";
|
||||
PaymentTypeCode payCode = PaymentTypeCode.PAYPAL;
|
||||
////GOPAY DANA 收款账号需要为电话号码
|
||||
//if (payIndex == 1 || payIndex == 0)
|
||||
//{
|
||||
// payCode = payIndex == 1 ? PaymentTypeCode.DANA : payCode;
|
||||
// payAccount = "0881234567890";
|
||||
// accountType = "P";
|
||||
//}
|
||||
//if (payIndex == 2)
|
||||
//{
|
||||
// // PIX 需要填写税号
|
||||
// payCode = PaymentTypeCode.PIX;
|
||||
// taxNo = "99999999999";
|
||||
//}
|
||||
//if (payIndex == 3) payCode = PaymentTypeCode.MERCADOPAGO;
|
||||
MYp0ZVTT2QSDKHelper.Instance.CreateWithDrawOrder(withDrawSceneId, payCode, payAccount, accountType, payeeName, taxNo, b =>
|
||||
{
|
||||
Debug.Log($"CreateWithDrawOrder result : {b}");
|
||||
});
|
||||
|
||||
payIndex++;
|
||||
payIndex = payIndex > 3 ? 0 : payIndex;
|
||||
}
|
||||
|
||||
public void GetWithDrawOrders()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawOrders(((b, s) =>
|
||||
{
|
||||
Debug.Log($"GetWithDrawOrders result : {b}, data : {s}");
|
||||
if (b)
|
||||
{
|
||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawOrder>>(s);
|
||||
int idx = 0;
|
||||
foreach (WithDrawOrder config in cfgs)
|
||||
{
|
||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
|
||||
Invoke("ShowSplash", 5);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.RegistIosParam((i =>
|
||||
{
|
||||
Debug.Log($"ios ab param : {i}");
|
||||
}));
|
||||
|
||||
void GameConfig(bool result, string config)
|
||||
{
|
||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
}
|
||||
|
||||
MYp0ZVTT2QSDKHelper.Instance.Init(null, "app_config", GameConfig);
|
||||
}
|
||||
|
||||
public static string GetSdkVersion()
|
||||
{
|
||||
return MYp0ZVTT2QSDKHelper.SdkVersion;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using MYp0ZVTT2QSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class MYp0ZVTT2QSDKDemo : MonoBehaviour
|
||||
{
|
||||
public void ShowReward()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowRewardVideo("TAG", b =>
|
||||
{
|
||||
Debug.LogError($"reward result = {b}");
|
||||
},(() =>
|
||||
{
|
||||
Debug.LogError($"reward close!!!");
|
||||
}));
|
||||
}
|
||||
|
||||
public void ShowInter()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowInter("TAG", () =>
|
||||
{
|
||||
Debug.LogError("inter hide");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowAdmobInter()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowAdmobInter("TAG", () =>
|
||||
{
|
||||
Debug.LogError("inter hide");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowSplash()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.ShowSplash();
|
||||
}
|
||||
|
||||
public void CheckReward(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsVideoReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Reward : {isReady}");
|
||||
}
|
||||
|
||||
public void CheckInter(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsInterReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Inter : {isReady}");
|
||||
}
|
||||
|
||||
public void CheckSplash(Image btnImg)
|
||||
{
|
||||
var isReady = MYp0ZVTT2QSDKHelper.Instance.IsSplashReady();
|
||||
btnImg.color = isReady ? Color.green : Color.white;
|
||||
Debug.Log($"Splash : {isReady}");
|
||||
}
|
||||
|
||||
public void Track()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.Track("test", new Dictionary<string, string>()
|
||||
{
|
||||
{"evt1", "1"},
|
||||
{"evt2", "2"},
|
||||
{"evt3", "3"},
|
||||
{"evt4", "4"},
|
||||
{"evt5", "5"},
|
||||
{"evt6", "6"},
|
||||
{"evt7", "7"},
|
||||
{"evt8", "8"},
|
||||
{"evt9", "9"},
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GetCountryCode()
|
||||
{
|
||||
|
||||
var code = MYp0ZVTT2QSDKHelper.Instance.GetCountryCode();
|
||||
Debug.Log($"country : {code}");
|
||||
}
|
||||
|
||||
public void ShowH5()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5((() =>
|
||||
{
|
||||
Debug.Log("H5 close");
|
||||
}), () =>
|
||||
{
|
||||
Debug.Log($"H5 show failed!");
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowH5(RectTransform rectTransform)
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.ShowH5(rectTransform);
|
||||
}
|
||||
|
||||
public void HideH5()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.H5.HideH5();
|
||||
}
|
||||
|
||||
public void CheckShowH5(Image btnImg)
|
||||
{
|
||||
var show = MYp0ZVTT2QSDKHelper.Instance.H5.IsShowH5();
|
||||
btnImg.color = show ? Color.green : Color.red;
|
||||
Debug.Log($"CheckShowH5 : {show}");
|
||||
}
|
||||
|
||||
private int _level = 1;
|
||||
public void TrackLevel()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.TrackLevelUp(_level);
|
||||
if (Random.Range(0, 100) < 50)
|
||||
{
|
||||
_level++;
|
||||
}
|
||||
}
|
||||
|
||||
private string withDrawSceneId = "";
|
||||
public void GetWithDrawConfigs()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawConfigs(((b, s) =>
|
||||
{
|
||||
Debug.Log($"GetWithDrawConfigs result : {b}, data : {s}");
|
||||
if (b)
|
||||
{
|
||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawConfig>>(s);
|
||||
int idx = 0;
|
||||
foreach (WithDrawConfig config in cfgs)
|
||||
{
|
||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||
if (idx == 0)
|
||||
withDrawSceneId = config.SecneId;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
private int payIndex = 0;
|
||||
public void CreateWithDrawOrder()
|
||||
{
|
||||
string taxNo = "";
|
||||
string payAccount = "tom@gmail.com";
|
||||
string accountType = "E";
|
||||
PaymentTypeCode payCode = PaymentTypeCode.GOPAY;
|
||||
//GOPAY DANA 收款账号需要为电话号码
|
||||
if (payIndex == 1 || payIndex == 0)
|
||||
{
|
||||
payCode = payIndex == 1 ? PaymentTypeCode.DANA : payCode;
|
||||
payAccount = "0881234567890";
|
||||
accountType = "P";
|
||||
}
|
||||
if (payIndex == 2)
|
||||
{
|
||||
// PIX 需要填写税号
|
||||
payCode = PaymentTypeCode.PIX;
|
||||
taxNo = "99999999999";
|
||||
}
|
||||
if (payIndex == 3) payCode = PaymentTypeCode.MERCADOPAGO;
|
||||
MYp0ZVTT2QSDKHelper.Instance.CreateWithDrawOrder(withDrawSceneId, payCode, payAccount, accountType, "testName", taxNo, b =>
|
||||
{
|
||||
Debug.Log($"CreateWithDrawOrder result : {b}");
|
||||
});
|
||||
|
||||
payIndex++;
|
||||
payIndex = payIndex > 3 ? 0 : payIndex;
|
||||
}
|
||||
|
||||
public void GetWithDrawOrders()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.GetWithDrawOrders(((b, s) =>
|
||||
{
|
||||
Debug.Log($"GetWithDrawOrders result : {b}, data : {s}");
|
||||
if (b)
|
||||
{
|
||||
var cfgs = JsonConvert.DeserializeObject<List<WithDrawOrder>>(s);
|
||||
int idx = 0;
|
||||
foreach (WithDrawOrder config in cfgs)
|
||||
{
|
||||
Debug.Log($"index = {idx}, {config.ToString()}");
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
|
||||
Invoke("ShowSplash", 5);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
MYp0ZVTT2QSDKHelper.Instance.RegistIosParam((i =>
|
||||
{
|
||||
Debug.Log($"ios ab param : {i}");
|
||||
}));
|
||||
|
||||
void GameConfig(bool result, string config)
|
||||
{
|
||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
}
|
||||
|
||||
MYp0ZVTT2QSDKHelper.Instance.Init(null, "app_config", GameConfig);
|
||||
}
|
||||
|
||||
public static string GetSdkVersion()
|
||||
{
|
||||
return MYp0ZVTT2QSDKHelper.SdkVersion;
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
+11
-11
@@ -1,11 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 959ec24a7131c9d488e5007fa82612be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 959ec24a7131c9d488e5007fa82612be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Regular → Executable
+653
-653
File diff suppressed because it is too large
Load Diff
Regular → Executable
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64a340d6f61782b4c8c883b62e1d5534
|
||||
guid: 388c0b17792cece47ba42e51b68fbd6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Regular → Executable
+16
-16
@@ -1,17 +1,17 @@
|
||||
package com.tool.countrycode;
|
||||
import android.app.Activity;
|
||||
import java.util.Locale;
|
||||
public class AcquireCountryCode {
|
||||
// 获取国家码
|
||||
public static String getCountryCode()
|
||||
{
|
||||
Locale locale = Locale.getDefault();
|
||||
return locale.getCountry();
|
||||
}
|
||||
|
||||
public static String getCountryCode3() {
|
||||
Locale currentLocale = Locale.getDefault();
|
||||
return currentLocale.getISO3Country();
|
||||
}
|
||||
|
||||
package com.tool.countrycode;
|
||||
import android.app.Activity;
|
||||
import java.util.Locale;
|
||||
public class AcquireCountryCode {
|
||||
// 获取国家码
|
||||
public static String getCountryCode()
|
||||
{
|
||||
Locale locale = Locale.getDefault();
|
||||
return locale.getCountry();
|
||||
}
|
||||
|
||||
public static String getCountryCode3() {
|
||||
Locale currentLocale = Locale.getDefault();
|
||||
return currentLocale.getISO3Country();
|
||||
}
|
||||
|
||||
}
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
+33
-33
@@ -1,33 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e3da5c7fe21c1347a563e64e8f305d4
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 6e3da5c7fe21c1347a563e64e8f305d4
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Regular → Executable
BIN
Binary file not shown.
Regular → Executable
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 380fbd6cbea0c354494400b091a059f7
|
||||
guid: fe19acc38fc5b2c44bd76633a63d0d6b
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Regular → Executable
+12
-12
@@ -1,12 +1,12 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern "C" {
|
||||
__attribute__((visibility("default")))
|
||||
const char* _GetDeviceCountryCode() {
|
||||
@autoreleasepool {
|
||||
NSLocale *currentLocale = [NSLocale currentLocale];
|
||||
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
|
||||
return strdup([countryCode UTF8String]); // 使用strdup确保内存安全
|
||||
}
|
||||
}
|
||||
}
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern "C" {
|
||||
__attribute__((visibility("default")))
|
||||
const char* _GetDeviceCountryCode() {
|
||||
@autoreleasepool {
|
||||
NSLocale *currentLocale = [NSLocale currentLocale];
|
||||
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
|
||||
return strdup([countryCode UTF8String]); // 使用strdup确保内存安全
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
+13
-13
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "SDKConfig",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
{
|
||||
"name": "SDKConfig",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
Regular → Executable
+7
-7
@@ -1,7 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b6da46957b38914aa097a61bd86a16d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
fileFormatVersion: 2
|
||||
guid: 8b6da46957b38914aa097a61bd86a16d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
Regular → Executable
+234
-234
@@ -1,234 +1,234 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MYp0ZVTT2QSDK
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SDKConfig : ScriptableObject
|
||||
{
|
||||
|
||||
public string appsFlyerDevKey;
|
||||
|
||||
public string appsFlyerIosAppleAppId;
|
||||
|
||||
public string appKey;
|
||||
|
||||
public string appSecret;
|
||||
|
||||
public string logReportUrl;
|
||||
|
||||
public string maxAppKey;
|
||||
|
||||
public string splashUnitId;
|
||||
|
||||
public string bannerUnitId;
|
||||
|
||||
public string interUnitId;
|
||||
|
||||
public string videoUnitId;
|
||||
|
||||
public string kwaiAppId;
|
||||
|
||||
public List<string> kwaiVideoUnitId = new();
|
||||
|
||||
public List<string> kwaiInterUnitId = new();
|
||||
|
||||
public string bigoAppId;
|
||||
|
||||
public List<string> bigoVideoUnitId = new();
|
||||
|
||||
public List<string> bigoInterUnitId = new();
|
||||
|
||||
public string bigoSplashUnitId;
|
||||
|
||||
public string toponAppId;
|
||||
|
||||
public string toponAppkey;
|
||||
|
||||
public string toponVideoUnitId;
|
||||
|
||||
public string toponInterUnitId;
|
||||
|
||||
public string admobAppId;
|
||||
|
||||
public string admobVideoUnitId;
|
||||
|
||||
public string admobInterUnitId;
|
||||
|
||||
public string admobSplashUnitId;
|
||||
|
||||
public bool isDebug = false;
|
||||
|
||||
public bool isPrintLog = false;
|
||||
|
||||
public bool isUseAdmobSplash = false;
|
||||
|
||||
private static SDKConfig _instance;
|
||||
|
||||
public static SDKConfig Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance != null) return _instance;
|
||||
_instance = AssetUtils.GetScriptableObject<SDKConfig>(typeof(SDKConfig).Name, "Assets/Resources", false, false);
|
||||
return _instance;
|
||||
}
|
||||
set
|
||||
{
|
||||
_instance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string AppsFlyerDevKey
|
||||
{
|
||||
get { return Instance.appsFlyerDevKey; }
|
||||
}
|
||||
|
||||
public static string AppsFlyerIosAppleAppId
|
||||
{
|
||||
get { return Instance.appsFlyerIosAppleAppId; }
|
||||
}
|
||||
|
||||
public static string AppKey
|
||||
{
|
||||
get { return Instance.appKey; }
|
||||
}
|
||||
|
||||
public static string AppSecret
|
||||
{
|
||||
get { return Instance.appSecret; }
|
||||
}
|
||||
|
||||
public static string LogReportUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Instance.logReportUrl.StartsWith("http"))
|
||||
{
|
||||
return "https://" + Instance.logReportUrl.Replace(" ", ""); ;
|
||||
}
|
||||
return Instance.logReportUrl.Replace(" ", ""); ;
|
||||
}
|
||||
}
|
||||
|
||||
public static string MaxAppKey
|
||||
{
|
||||
get { return Instance.maxAppKey; }
|
||||
}
|
||||
|
||||
public static string SplashUnitID
|
||||
{
|
||||
get { return Instance.splashUnitId; }
|
||||
}
|
||||
|
||||
public static string BannerUnitId
|
||||
{
|
||||
get { return Instance.bannerUnitId; }
|
||||
}
|
||||
|
||||
public static string InterUnitId
|
||||
{
|
||||
get { return Instance.interUnitId; }
|
||||
}
|
||||
|
||||
public static string VideoUnitId
|
||||
{
|
||||
get { return Instance.videoUnitId; }
|
||||
}
|
||||
|
||||
public static string KwaiAppId
|
||||
{
|
||||
get => Instance.kwaiAppId;
|
||||
set => Instance.kwaiAppId = value;
|
||||
}
|
||||
|
||||
public static List<string> KwaiVideoUnitId
|
||||
{
|
||||
get => Instance.kwaiVideoUnitId;
|
||||
set => Instance.kwaiVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static List<string> KwaiInterUnitId
|
||||
{
|
||||
get => Instance.kwaiInterUnitId;
|
||||
set => Instance.kwaiInterUnitId = value;
|
||||
}
|
||||
|
||||
public static string BigoAppId
|
||||
{
|
||||
get => Instance.bigoAppId;
|
||||
set => Instance.bigoAppId = value;
|
||||
}
|
||||
|
||||
public static List<string> BigoVideoUnitId
|
||||
{
|
||||
get => Instance.bigoVideoUnitId;
|
||||
set => Instance.bigoVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static List<string> BigoInterUnitId
|
||||
{
|
||||
get => Instance.bigoInterUnitId;
|
||||
set => Instance.bigoInterUnitId = value;
|
||||
}
|
||||
|
||||
public static string BigoSplashUnitId
|
||||
{
|
||||
get => Instance.bigoSplashUnitId;
|
||||
set => Instance.bigoSplashUnitId = value;
|
||||
}
|
||||
|
||||
public static string ToponAppId
|
||||
{
|
||||
get { return Instance.toponAppId; }
|
||||
}
|
||||
|
||||
public static string ToponAppkey
|
||||
{
|
||||
get { return Instance.toponAppkey; }
|
||||
}
|
||||
|
||||
public static string ToponVideoUnitId
|
||||
{
|
||||
get { return Instance.toponVideoUnitId; }
|
||||
}
|
||||
|
||||
public static string ToponInterUnitId
|
||||
{
|
||||
get { return Instance.toponInterUnitId; }
|
||||
}
|
||||
|
||||
public static string AdmobAppId
|
||||
{
|
||||
get => Instance.admobAppId;
|
||||
set => Instance.admobAppId = value;
|
||||
}
|
||||
|
||||
public static string AdmobVideoUnitId
|
||||
{
|
||||
get => Instance.admobVideoUnitId;
|
||||
set => Instance.admobVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static string AdmobSplashUnitId
|
||||
{
|
||||
get => Instance.admobSplashUnitId;
|
||||
set => Instance.admobSplashUnitId = value;
|
||||
}
|
||||
|
||||
public static string AdmobInterUnitId
|
||||
{
|
||||
get => Instance.admobInterUnitId;
|
||||
set => Instance.admobInterUnitId = value;
|
||||
}
|
||||
|
||||
public static bool IsDebug => Instance.isDebug;
|
||||
|
||||
public static bool IsPrintLog => Instance.isPrintLog;
|
||||
|
||||
public static bool IsUseAdmobSplash => Instance.isUseAdmobSplash;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MYp0ZVTT2QSDK
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SDKConfig : ScriptableObject
|
||||
{
|
||||
|
||||
public string appsFlyerDevKey;
|
||||
|
||||
public string appsFlyerIosAppleAppId;
|
||||
|
||||
public string appKey;
|
||||
|
||||
public string appSecret;
|
||||
|
||||
public string logReportUrl;
|
||||
|
||||
public string maxAppKey;
|
||||
|
||||
public string splashUnitId;
|
||||
|
||||
public string bannerUnitId;
|
||||
|
||||
public string interUnitId;
|
||||
|
||||
public string videoUnitId;
|
||||
|
||||
public string kwaiAppId;
|
||||
|
||||
public List<string> kwaiVideoUnitId = new();
|
||||
|
||||
public List<string> kwaiInterUnitId = new();
|
||||
|
||||
public string bigoAppId;
|
||||
|
||||
public List<string> bigoVideoUnitId = new();
|
||||
|
||||
public List<string> bigoInterUnitId = new();
|
||||
|
||||
public string bigoSplashUnitId;
|
||||
|
||||
public string toponAppId;
|
||||
|
||||
public string toponAppkey;
|
||||
|
||||
public string toponVideoUnitId;
|
||||
|
||||
public string toponInterUnitId;
|
||||
|
||||
public string admobAppId;
|
||||
|
||||
public string admobVideoUnitId;
|
||||
|
||||
public string admobInterUnitId;
|
||||
|
||||
public string admobSplashUnitId;
|
||||
|
||||
public bool isDebug = false;
|
||||
|
||||
public bool isPrintLog = false;
|
||||
|
||||
public bool isUseAdmobSplash = false;
|
||||
|
||||
private static SDKConfig _instance;
|
||||
|
||||
public static SDKConfig Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance != null) return _instance;
|
||||
_instance = AssetUtils.GetScriptableObject<SDKConfig>(typeof(SDKConfig).Name, "Assets/Resources", false, false);
|
||||
return _instance;
|
||||
}
|
||||
set
|
||||
{
|
||||
_instance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string AppsFlyerDevKey
|
||||
{
|
||||
get { return Instance.appsFlyerDevKey; }
|
||||
}
|
||||
|
||||
public static string AppsFlyerIosAppleAppId
|
||||
{
|
||||
get { return Instance.appsFlyerIosAppleAppId; }
|
||||
}
|
||||
|
||||
public static string AppKey
|
||||
{
|
||||
get { return Instance.appKey; }
|
||||
}
|
||||
|
||||
public static string AppSecret
|
||||
{
|
||||
get { return Instance.appSecret; }
|
||||
}
|
||||
|
||||
public static string LogReportUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Instance.logReportUrl.StartsWith("http"))
|
||||
{
|
||||
return "https://" + Instance.logReportUrl.Replace(" ", ""); ;
|
||||
}
|
||||
return Instance.logReportUrl.Replace(" ", ""); ;
|
||||
}
|
||||
}
|
||||
|
||||
public static string MaxAppKey
|
||||
{
|
||||
get { return Instance.maxAppKey; }
|
||||
}
|
||||
|
||||
public static string SplashUnitID
|
||||
{
|
||||
get { return Instance.splashUnitId; }
|
||||
}
|
||||
|
||||
public static string BannerUnitId
|
||||
{
|
||||
get { return Instance.bannerUnitId; }
|
||||
}
|
||||
|
||||
public static string InterUnitId
|
||||
{
|
||||
get { return Instance.interUnitId; }
|
||||
}
|
||||
|
||||
public static string VideoUnitId
|
||||
{
|
||||
get { return Instance.videoUnitId; }
|
||||
}
|
||||
|
||||
public static string KwaiAppId
|
||||
{
|
||||
get => Instance.kwaiAppId;
|
||||
set => Instance.kwaiAppId = value;
|
||||
}
|
||||
|
||||
public static List<string> KwaiVideoUnitId
|
||||
{
|
||||
get => Instance.kwaiVideoUnitId;
|
||||
set => Instance.kwaiVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static List<string> KwaiInterUnitId
|
||||
{
|
||||
get => Instance.kwaiInterUnitId;
|
||||
set => Instance.kwaiInterUnitId = value;
|
||||
}
|
||||
|
||||
public static string BigoAppId
|
||||
{
|
||||
get => Instance.bigoAppId;
|
||||
set => Instance.bigoAppId = value;
|
||||
}
|
||||
|
||||
public static List<string> BigoVideoUnitId
|
||||
{
|
||||
get => Instance.bigoVideoUnitId;
|
||||
set => Instance.bigoVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static List<string> BigoInterUnitId
|
||||
{
|
||||
get => Instance.bigoInterUnitId;
|
||||
set => Instance.bigoInterUnitId = value;
|
||||
}
|
||||
|
||||
public static string BigoSplashUnitId
|
||||
{
|
||||
get => Instance.bigoSplashUnitId;
|
||||
set => Instance.bigoSplashUnitId = value;
|
||||
}
|
||||
|
||||
public static string ToponAppId
|
||||
{
|
||||
get { return Instance.toponAppId; }
|
||||
}
|
||||
|
||||
public static string ToponAppkey
|
||||
{
|
||||
get { return Instance.toponAppkey; }
|
||||
}
|
||||
|
||||
public static string ToponVideoUnitId
|
||||
{
|
||||
get { return Instance.toponVideoUnitId; }
|
||||
}
|
||||
|
||||
public static string ToponInterUnitId
|
||||
{
|
||||
get { return Instance.toponInterUnitId; }
|
||||
}
|
||||
|
||||
public static string AdmobAppId
|
||||
{
|
||||
get => Instance.admobAppId;
|
||||
set => Instance.admobAppId = value;
|
||||
}
|
||||
|
||||
public static string AdmobVideoUnitId
|
||||
{
|
||||
get => Instance.admobVideoUnitId;
|
||||
set => Instance.admobVideoUnitId = value;
|
||||
}
|
||||
|
||||
public static string AdmobSplashUnitId
|
||||
{
|
||||
get => Instance.admobSplashUnitId;
|
||||
set => Instance.admobSplashUnitId = value;
|
||||
}
|
||||
|
||||
public static string AdmobInterUnitId
|
||||
{
|
||||
get => Instance.admobInterUnitId;
|
||||
set => Instance.admobInterUnitId = value;
|
||||
}
|
||||
|
||||
public static bool IsDebug => Instance.isDebug;
|
||||
|
||||
public static bool IsPrintLog => Instance.isPrintLog;
|
||||
|
||||
public static bool IsUseAdmobSplash => Instance.isUseAdmobSplash;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
+152
-152
@@ -1,152 +1,152 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace MYp0ZVTT2QSDK
|
||||
{
|
||||
public static class AssetUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a reference to a scriptable object of type T with the given fileName at the relative resourcesPath.
|
||||
/// <para/> If the asset is not found, one will get created automatically (in the Editor only)
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="resourcesPath"></param>
|
||||
/// <param name="saveAssetDatabase"></param>
|
||||
/// <param name="refreshAssetDatabase"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static T GetScriptableObject<T>(string fileName,
|
||||
string resourcesPath,
|
||||
bool saveAssetDatabase,
|
||||
bool refreshAssetDatabase)
|
||||
where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||
resourcesPath = CleanPath(resourcesPath);
|
||||
|
||||
var obj = (T)Resources.Load(fileName, typeof(T));
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
string simpleResourcesPath = resourcesPath.Replace(resourcesPath.Substring(0, resourcesPath.LastIndexOf("Resources", StringComparison.Ordinal)), "");
|
||||
simpleResourcesPath = simpleResourcesPath.Replace("Resources", "").Remove(0, 1);
|
||||
obj = (T)Resources.Load(Path.Combine(simpleResourcesPath, fileName), typeof(T));
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (obj != null) return obj;
|
||||
if (!Directory.Exists("Assets/Resources"))
|
||||
{
|
||||
Directory.CreateDirectory("Assets/Resources");
|
||||
}
|
||||
obj = CreateAsset<T>(resourcesPath, fileName, ".asset", saveAssetDatabase, refreshAssetDatabase);
|
||||
#endif
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static T GetResource<T>(string resourcesPath, string fileName) where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
resourcesPath = CleanPath(resourcesPath);
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||
|
||||
return (T)Resources.Load(resourcesPath + fileName, typeof(T));
|
||||
}
|
||||
|
||||
public static string CleanPath(string path)
|
||||
{
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
if (!path[path.Length - 1].Equals(@"\")) path += @"\";
|
||||
path = path.Replace(@"\\", @"\");
|
||||
path = path.Replace(@"\", "/");
|
||||
return path;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static T CreateAsset<T>(string relativePath,
|
||||
string fileName,
|
||||
string extension = ".asset",
|
||||
bool saveAssetDatabase = true,
|
||||
bool refreshAssetDatabase = true)
|
||||
where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(relativePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
relativePath = CleanPath(relativePath);
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||
// relativePath = relativePath.Replace(@"\\", @"\");
|
||||
var asset = ScriptableObject.CreateInstance<T>();
|
||||
AssetDatabase.CreateAsset(asset, relativePath + fileName + extension);
|
||||
EditorUtility.SetDirty(asset);
|
||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||
return asset;
|
||||
}
|
||||
|
||||
public static List<T> GetAssets<T>() where T : ScriptableObject
|
||||
{
|
||||
var list = new List<T>();
|
||||
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
|
||||
if (asset == null) continue;
|
||||
list.Add(asset);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
|
||||
bool refreshAssetDatabase = true, bool printDebugMessage = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(relativePath)) return;
|
||||
if (string.IsNullOrEmpty(fileName)) return;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||
relativePath = CleanPath(relativePath);
|
||||
if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset")) return;
|
||||
if (printDebugMessage) Debug.Log("The " + fileName + ".asset file has been moved to trash.");
|
||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public static Texture GetTexture(string filePath, string fileName, string fileExtension = ".png")
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||
filePath = CleanPath(filePath);
|
||||
return AssetDatabase.LoadAssetAtPath<Texture>(filePath + fileName + fileExtension);
|
||||
}
|
||||
|
||||
public static Texture2D GetTexture2D(string filePath, string fileName, string fileExtension = ".png")
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||
filePath = CleanPath(filePath);
|
||||
return AssetDatabase.LoadAssetAtPath<Texture2D>(filePath + fileName + fileExtension);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace MYp0ZVTT2QSDK
|
||||
{
|
||||
public static class AssetUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a reference to a scriptable object of type T with the given fileName at the relative resourcesPath.
|
||||
/// <para/> If the asset is not found, one will get created automatically (in the Editor only)
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="resourcesPath"></param>
|
||||
/// <param name="saveAssetDatabase"></param>
|
||||
/// <param name="refreshAssetDatabase"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static T GetScriptableObject<T>(string fileName,
|
||||
string resourcesPath,
|
||||
bool saveAssetDatabase,
|
||||
bool refreshAssetDatabase)
|
||||
where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||
resourcesPath = CleanPath(resourcesPath);
|
||||
|
||||
var obj = (T)Resources.Load(fileName, typeof(T));
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
string simpleResourcesPath = resourcesPath.Replace(resourcesPath.Substring(0, resourcesPath.LastIndexOf("Resources", StringComparison.Ordinal)), "");
|
||||
simpleResourcesPath = simpleResourcesPath.Replace("Resources", "").Remove(0, 1);
|
||||
obj = (T)Resources.Load(Path.Combine(simpleResourcesPath, fileName), typeof(T));
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (obj != null) return obj;
|
||||
if (!Directory.Exists("Assets/Resources"))
|
||||
{
|
||||
Directory.CreateDirectory("Assets/Resources");
|
||||
}
|
||||
obj = CreateAsset<T>(resourcesPath, fileName, ".asset", saveAssetDatabase, refreshAssetDatabase);
|
||||
#endif
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static T GetResource<T>(string resourcesPath, string fileName) where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourcesPath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
resourcesPath = CleanPath(resourcesPath);
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!resourcesPath[resourcesPath.Length - 1].Equals(@"\")) resourcesPath += @"\";
|
||||
// resourcesPath = resourcesPath.Replace(@"\", "/");
|
||||
|
||||
return (T)Resources.Load(resourcesPath + fileName, typeof(T));
|
||||
}
|
||||
|
||||
public static string CleanPath(string path)
|
||||
{
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
if (!path[path.Length - 1].Equals(@"\")) path += @"\";
|
||||
path = path.Replace(@"\\", @"\");
|
||||
path = path.Replace(@"\", "/");
|
||||
return path;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static T CreateAsset<T>(string relativePath,
|
||||
string fileName,
|
||||
string extension = ".asset",
|
||||
bool saveAssetDatabase = true,
|
||||
bool refreshAssetDatabase = true)
|
||||
where T : ScriptableObject
|
||||
{
|
||||
if (string.IsNullOrEmpty(relativePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
relativePath = CleanPath(relativePath);
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||
// relativePath = relativePath.Replace(@"\\", @"\");
|
||||
var asset = ScriptableObject.CreateInstance<T>();
|
||||
AssetDatabase.CreateAsset(asset, relativePath + fileName + extension);
|
||||
EditorUtility.SetDirty(asset);
|
||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||
return asset;
|
||||
}
|
||||
|
||||
public static List<T> GetAssets<T>() where T : ScriptableObject
|
||||
{
|
||||
var list = new List<T>();
|
||||
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
var asset = AssetDatabase.LoadAssetAtPath<T>(AssetDatabase.GUIDToAssetPath(guid));
|
||||
if (asset == null) continue;
|
||||
list.Add(asset);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void MoveAssetToTrash(string relativePath, string fileName, bool saveAssetDatabase = true,
|
||||
bool refreshAssetDatabase = true, bool printDebugMessage = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(relativePath)) return;
|
||||
if (string.IsNullOrEmpty(fileName)) return;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!relativePath[relativePath.Length - 1].Equals(@"\")) relativePath += @"\";
|
||||
relativePath = CleanPath(relativePath);
|
||||
if (!AssetDatabase.MoveAssetToTrash(relativePath + fileName + ".asset")) return;
|
||||
if (printDebugMessage) Debug.Log("The " + fileName + ".asset file has been moved to trash.");
|
||||
if (saveAssetDatabase) AssetDatabase.SaveAssets();
|
||||
if (refreshAssetDatabase) AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public static Texture GetTexture(string filePath, string fileName, string fileExtension = ".png")
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||
filePath = CleanPath(filePath);
|
||||
return AssetDatabase.LoadAssetAtPath<Texture>(filePath + fileName + fileExtension);
|
||||
}
|
||||
|
||||
public static Texture2D GetTexture2D(string filePath, string fileName, string fileExtension = ".png")
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) return null;
|
||||
if (string.IsNullOrEmpty(fileName)) return null;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
// if (!filePath[filePath.Length - 1].Equals(@"\")) filePath += @"\";
|
||||
filePath = CleanPath(filePath);
|
||||
return AssetDatabase.LoadAssetAtPath<Texture2D>(filePath + fileName + fileExtension);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
+71
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AppsFlyerSDK
|
||||
{
|
||||
public enum MediationNetwork : ulong
|
||||
{
|
||||
GoogleAdMob = 1,
|
||||
IronSource = 2,
|
||||
ApplovinMax = 3,
|
||||
Fyber = 4,
|
||||
Appodeal = 5,
|
||||
Admost = 6,
|
||||
Topon = 7,
|
||||
Tradplus = 8,
|
||||
Yandex = 9,
|
||||
ChartBoost = 10,
|
||||
Unity = 11,
|
||||
ToponPte = 12,
|
||||
Custom = 13,
|
||||
DirectMonetization = 14
|
||||
}
|
||||
|
||||
public static class AdRevenueScheme
|
||||
{
|
||||
/**
|
||||
* code ISO 3166-1 format
|
||||
*/
|
||||
public const string COUNTRY = "country";
|
||||
|
||||
/**
|
||||
* ID of the ad unit for the impression
|
||||
*/
|
||||
public const string AD_UNIT = "ad_unit";
|
||||
|
||||
/**
|
||||
* Format of the ad
|
||||
*/
|
||||
public const string AD_TYPE = "ad_type";
|
||||
|
||||
/**
|
||||
* ID of the ad placement for the impression
|
||||
*/
|
||||
public const string PLACEMENT = "placement";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
// Data class representing ad revenue information.
|
||||
//
|
||||
// @property monetizationNetwork The name of the network that monetized the ad.
|
||||
// @property mediationNetwork An instance of MediationNetwork representing the mediation service used.
|
||||
// @property currencyIso4217Code The ISO 4217 currency code describing the currency of the revenue.
|
||||
// @property eventRevenue The amount of revenue generated by the ad.
|
||||
/// </summary>
|
||||
public class AFAdRevenueData
|
||||
{
|
||||
public string monetizationNetwork { get; private set; }
|
||||
public MediationNetwork mediationNetwork { get; private set; }
|
||||
public string currencyIso4217Code { get; private set; }
|
||||
public double eventRevenue { get; private set; }
|
||||
|
||||
public AFAdRevenueData(string monetization, MediationNetwork mediation, string currency, double revenue)
|
||||
{
|
||||
monetizationNetwork = monetization;
|
||||
mediationNetwork = mediation;
|
||||
currencyIso4217Code = currency;
|
||||
eventRevenue = revenue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49e1906ae949e4bfea400bd1da9f7e39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace AppsFlyerSDK
|
||||
{
|
||||
|
||||
public interface IAppsFlyerPurchaseRevenueDataSource
|
||||
{
|
||||
Dictionary<string, object> PurchaseRevenueAdditionalParametersForProducts(HashSet<object> products, HashSet<object> transactions);
|
||||
}
|
||||
|
||||
public interface IAppsFlyerPurchaseRevenueDataSourceStoreKit2
|
||||
{
|
||||
Dictionary<string, object> PurchaseRevenueAdditionalParametersStoreKit2ForProducts(HashSet<object> products, HashSet<object> transactions);
|
||||
}
|
||||
|
||||
public class AppsFlyerPurchaseRevenueBridge : MonoBehaviour
|
||||
{
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[DllImport("__Internal")]
|
||||
private static extern void RegisterUnityPurchaseRevenueParamsCallback(Func<string, string, string> callback);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void RegisterUnityPurchaseRevenueParamsCallbackSK2(Func<string, string, string> callback);
|
||||
#endif
|
||||
|
||||
private static IAppsFlyerPurchaseRevenueDataSource _dataSource;
|
||||
private static IAppsFlyerPurchaseRevenueDataSourceStoreKit2 _dataSourceSK2;
|
||||
|
||||
public static void RegisterDataSource(IAppsFlyerPurchaseRevenueDataSource dataSource)
|
||||
{
|
||||
_dataSource = dataSource;
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
RegisterUnityPurchaseRevenueParamsCallback(GetAdditionalParameters);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
using (AndroidJavaClass jc = new AndroidJavaClass("com.appsflyer.unity.PurchaseRevenueBridge"))
|
||||
{
|
||||
jc.CallStatic("setUnityBridge", new UnityPurchaseRevenueBridgeProxy());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void RegisterDataSourceStoreKit2(IAppsFlyerPurchaseRevenueDataSourceStoreKit2 dataSource)
|
||||
{
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_dataSourceSK2 = dataSource;
|
||||
RegisterUnityPurchaseRevenueParamsCallbackSK2(GetAdditionalParametersSK2);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> GetAdditionalParametersForAndroid(HashSet<object> products, HashSet<object> transactions)
|
||||
{
|
||||
return _dataSource?.PurchaseRevenueAdditionalParametersForProducts(products, transactions)
|
||||
?? new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[AOT.MonoPInvokeCallback(typeof(Func<string, string, string>))]
|
||||
public static string GetAdditionalParameters(string productsJson, string transactionsJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
HashSet<object> products = new HashSet<object>();
|
||||
HashSet<object> transactions = new HashSet<object>();
|
||||
|
||||
if (!string.IsNullOrEmpty(productsJson))
|
||||
{
|
||||
var dict = AFMiniJSON.Json.Deserialize(productsJson) as Dictionary<string, object>;
|
||||
if (dict != null)
|
||||
{
|
||||
if (dict.TryGetValue("products", out var productsObj) && productsObj is List<object> productList)
|
||||
products = new HashSet<object>(productList);
|
||||
|
||||
if (dict.TryGetValue("transactions", out var transactionsObj) && transactionsObj is List<object> transactionList)
|
||||
transactions = new HashSet<object>(transactionList);
|
||||
}
|
||||
}
|
||||
|
||||
var parameters = _dataSource?.PurchaseRevenueAdditionalParametersForProducts(products, transactions)
|
||||
?? new Dictionary<string, object>();
|
||||
return AFMiniJSON.Json.Serialize(parameters);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[AppsFlyer] Exception in GetAdditionalParameters: {e}");
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
[AOT.MonoPInvokeCallback(typeof(Func<string, string, string>))]
|
||||
public static string GetAdditionalParametersSK2(string productsJson, string transactionsJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
HashSet<object> products = new HashSet<object>();
|
||||
HashSet<object> transactions = new HashSet<object>();
|
||||
|
||||
if (!string.IsNullOrEmpty(productsJson))
|
||||
{
|
||||
var dict = AFMiniJSON.Json.Deserialize(productsJson) as Dictionary<string, object>;
|
||||
if (dict != null && dict.TryGetValue("products", out var productsObj) && productsObj is List<object> productList)
|
||||
products = new HashSet<object>(productList);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(transactionsJson))
|
||||
{
|
||||
var dict = AFMiniJSON.Json.Deserialize(transactionsJson) as Dictionary<string, object>;
|
||||
if (dict != null && dict.TryGetValue("transactions", out var transactionsObj) && transactionsObj is List<object> transactionList)
|
||||
transactions = new HashSet<object>(transactionList);
|
||||
}
|
||||
|
||||
var parameters = _dataSourceSK2?.PurchaseRevenueAdditionalParametersStoreKit2ForProducts(products, transactions)
|
||||
?? new Dictionary<string, object>();
|
||||
return AFMiniJSON.Json.Serialize(parameters);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[AppsFlyer] Exception in GetAdditionalParametersSK2: {e}");
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public class UnityPurchaseRevenueBridgeProxy : AndroidJavaProxy
|
||||
{
|
||||
public UnityPurchaseRevenueBridgeProxy() : base("com.appsflyer.unity.PurchaseRevenueBridge$UnityPurchaseRevenueBridge") { }
|
||||
|
||||
public string getAdditionalParameters(string productsJson, string transactionsJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create empty sets if JSON is null or empty
|
||||
HashSet<object> products = new HashSet<object>();
|
||||
HashSet<object> transactions = new HashSet<object>();
|
||||
|
||||
// Only try to parse if we have valid JSON
|
||||
if (!string.IsNullOrEmpty(productsJson))
|
||||
{
|
||||
try
|
||||
{
|
||||
// First try to parse as a simple array
|
||||
var parsedProducts = AFMiniJSON.Json.Deserialize(productsJson);
|
||||
if (parsedProducts is List<object> productList)
|
||||
{
|
||||
products = new HashSet<object>(productList);
|
||||
}
|
||||
else if (parsedProducts is Dictionary<string, object> dict)
|
||||
{
|
||||
if (dict.ContainsKey("events") && dict["events"] is List<object> eventsList)
|
||||
{
|
||||
products = new HashSet<object>(eventsList);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it's a dictionary but doesn't have events, add the whole dict
|
||||
products.Add(dict);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Error parsing products JSON: {e.Message}\nJSON: {productsJson}");
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(transactionsJson))
|
||||
{
|
||||
try
|
||||
{
|
||||
// First try to parse as a simple array
|
||||
var parsedTransactions = AFMiniJSON.Json.Deserialize(transactionsJson);
|
||||
if (parsedTransactions is List<object> transactionList)
|
||||
{
|
||||
transactions = new HashSet<object>(transactionList);
|
||||
}
|
||||
else if (parsedTransactions is Dictionary<string, object> dict)
|
||||
{
|
||||
if (dict.ContainsKey("events") && dict["events"] is List<object> eventsList)
|
||||
{
|
||||
transactions = new HashSet<object>(eventsList);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it's a dictionary but doesn't have events, add the whole dict
|
||||
transactions.Add(dict);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Error parsing transactions JSON: {e.Message}\nJSON: {transactionsJson}");
|
||||
}
|
||||
}
|
||||
|
||||
var parameters = AppsFlyerPurchaseRevenueBridge.GetAdditionalParametersForAndroid(products, transactions);
|
||||
return AFMiniJSON.Json.Serialize(parameters);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"Error in getAdditionalParameters: {e.Message}\nProducts JSON: {productsJson}\nTransactions JSON: {transactionsJson}");
|
||||
return "{}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class AppsFlyerPurchaseConnector : MonoBehaviour {
|
||||
|
||||
private static AppsFlyerPurchaseConnector instance;
|
||||
private Dictionary<string, object> pendingParameters;
|
||||
private Action<Dictionary<string, object>> pendingCallback;
|
||||
|
||||
public static AppsFlyerPurchaseConnector Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
GameObject go = new GameObject("AppsFlyerPurchaseConnector");
|
||||
instance = go.AddComponent<AppsFlyerPurchaseConnector>();
|
||||
DontDestroyOnLoad(go);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
private static AndroidJavaClass appsFlyerAndroidConnector = new AndroidJavaClass("com.appsflyer.unity.AppsFlyerAndroidWrapper");
|
||||
#endif
|
||||
|
||||
public static void init(MonoBehaviour unityObject, Store s) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_initPurchaseConnector(unityObject.name);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
int store = mapStoreToInt(s);
|
||||
appsFlyerAndroidConnector.CallStatic("initPurchaseConnector", unityObject ? unityObject.name : null, store);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void build() {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
//not for iOS
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
appsFlyerAndroidConnector.CallStatic("build");
|
||||
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void startObservingTransactions() {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_startObservingTransactions();
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
appsFlyerAndroidConnector.CallStatic("startObservingTransactions");
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void stopObservingTransactions() {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_stopObservingTransactions();
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
appsFlyerAndroidConnector.CallStatic("stopObservingTransactions");
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setIsSandbox(bool isSandbox) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_setIsSandbox(isSandbox);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
appsFlyerAndroidConnector.CallStatic("setIsSandbox", isSandbox);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setPurchaseRevenueValidationListeners(bool enableCallbacks) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_setPurchaseRevenueDelegate();
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
appsFlyerAndroidConnector.CallStatic("setPurchaseRevenueValidationListeners", enableCallbacks);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setAutoLogPurchaseRevenue(params AppsFlyerAutoLogPurchaseRevenueOptions[] autoLogPurchaseRevenueOptions) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
int option = 0;
|
||||
foreach (AppsFlyerAutoLogPurchaseRevenueOptions op in autoLogPurchaseRevenueOptions) {
|
||||
option = option | (int)op;
|
||||
}
|
||||
_setAutoLogPurchaseRevenue(option);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
if (autoLogPurchaseRevenueOptions.Length == 0) {
|
||||
return;
|
||||
}
|
||||
foreach (AppsFlyerAutoLogPurchaseRevenueOptions op in autoLogPurchaseRevenueOptions) {
|
||||
switch(op) {
|
||||
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsDisabled:
|
||||
break;
|
||||
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions:
|
||||
appsFlyerAndroidConnector.CallStatic("setAutoLogSubscriptions", true);
|
||||
break;
|
||||
case AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsInAppPurchases:
|
||||
appsFlyerAndroidConnector.CallStatic("setAutoLogInApps", true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void setPurchaseRevenueDataSource(IAppsFlyerPurchaseRevenueDataSource dataSource)
|
||||
{
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
|
||||
if (dataSource != null)
|
||||
{
|
||||
_setPurchaseRevenueDataSource(dataSource.GetType().Name);
|
||||
AppsFlyerPurchaseRevenueBridge.RegisterDataSource(dataSource);
|
||||
}
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
if (dataSource != null)
|
||||
{
|
||||
AppsFlyerPurchaseRevenueBridge.RegisterDataSource(dataSource);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public static void setPurchaseRevenueDataSourceStoreKit2(IAppsFlyerPurchaseRevenueDataSourceStoreKit2 dataSourceSK2)
|
||||
{
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
if (dataSourceSK2 != null)
|
||||
{
|
||||
AppsFlyerPurchaseRevenueBridge.RegisterDataSourceStoreKit2(dataSourceSK2);
|
||||
_setPurchaseRevenueDataSource("AppsFlyerObjectScript_StoreKit2");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
private static int mapStoreToInt(Store s) {
|
||||
switch(s) {
|
||||
case(Store.GOOGLE):
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setStoreKitVersion(StoreKitVersion storeKitVersion) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_setStoreKitVersion((int)storeKitVersion);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
// Android doesn't use StoreKit
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void logConsumableTransaction(string transactionJson) {
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
_logConsumableTransaction(transactionJson);
|
||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||
// Android doesn't use StoreKit
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _startObservingTransactions();
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _stopObservingTransactions();
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _setIsSandbox(bool isSandbox);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _setPurchaseRevenueDelegate();
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _setPurchaseRevenueDataSource(string dataSourceName);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _setAutoLogPurchaseRevenue(int option);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _initPurchaseConnector(string objectName);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _setStoreKitVersion(int storeKitVersion);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void _logConsumableTransaction(string transactionJson);
|
||||
|
||||
#endif
|
||||
}
|
||||
public enum Store {
|
||||
GOOGLE = 0
|
||||
}
|
||||
public enum AppsFlyerAutoLogPurchaseRevenueOptions
|
||||
{
|
||||
AppsFlyerAutoLogPurchaseRevenueOptionsDisabled = 0,
|
||||
AppsFlyerAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions = 1 << 0,
|
||||
AppsFlyerAutoLogPurchaseRevenueOptionsInAppPurchases = 1 << 1
|
||||
}
|
||||
|
||||
public enum StoreKitVersion {
|
||||
SK1 = 0,
|
||||
SK2 = 1
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0636ea07d370d437183f3762280c08ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace AppsFlyerSDK
|
||||
{
|
||||
public interface IAppsFlyerPurchaseValidation
|
||||
{
|
||||
void didReceivePurchaseRevenueValidationInfo(string validationInfo);
|
||||
void didReceivePurchaseRevenueError(string error);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c60f499ae0d048b1be8ffd6878a184c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
Vendored
Regular → Executable
+184
@@ -0,0 +1,184 @@
|
||||
#nullable enable
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class InAppPurchaseValidationResult : EventArgs
|
||||
{
|
||||
public bool success;
|
||||
public ProductPurchase? productPurchase;
|
||||
public ValidationFailureData? failureData;
|
||||
public string? token;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ProductPurchase
|
||||
{
|
||||
public string? kind;
|
||||
public string? purchaseTimeMillis;
|
||||
public int purchaseState;
|
||||
public int consumptionState;
|
||||
public string? developerPayload;
|
||||
public string? orderId;
|
||||
public int purchaseType;
|
||||
public int acknowledgementState;
|
||||
public string? purchaseToken;
|
||||
public string? productId;
|
||||
public int quantity;
|
||||
public string? obfuscatedExternalAccountId;
|
||||
public string? obfuscatedExternalProfil;
|
||||
public string? regionCode;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ValidationFailureData
|
||||
{
|
||||
public int status;
|
||||
public string? description;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubscriptionValidationResult
|
||||
{
|
||||
public bool success;
|
||||
public SubscriptionPurchase? subscriptionPurchase;
|
||||
public ValidationFailureData? failureData;
|
||||
public string? token;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubscriptionPurchase
|
||||
{
|
||||
public string? acknowledgementState;
|
||||
public CanceledStateContext? canceledStateContext;
|
||||
public ExternalAccountIdentifiers? externalAccountIdentifiers;
|
||||
public string? kind;
|
||||
public string? latestOrderId;
|
||||
public List<SubscriptionPurchaseLineItem>? lineItems;
|
||||
public string? linkedPurchaseToken;
|
||||
public PausedStateContext? pausedStateContext;
|
||||
public string? regionCode;
|
||||
public string? startTime;
|
||||
public SubscribeWithGoogleInfo? subscribeWithGoogleInfo;
|
||||
public string? subscriptionState;
|
||||
public TestPurchase? testPurchase;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CanceledStateContext
|
||||
{
|
||||
public DeveloperInitiatedCancellation? developerInitiatedCancellation;
|
||||
public ReplacementCancellation? replacementCancellation;
|
||||
public SystemInitiatedCancellation? systemInitiatedCancellation;
|
||||
public UserInitiatedCancellation? userInitiatedCancellation;
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ExternalAccountIdentifiers
|
||||
{
|
||||
public string? externalAccountId;
|
||||
public string? obfuscatedExternalAccountId;
|
||||
public string? obfuscatedExternalProfileId;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubscriptionPurchaseLineItem
|
||||
{
|
||||
public AutoRenewingPlan? autoRenewingPlan;
|
||||
public DeferredItemReplacement? deferredItemReplacement;
|
||||
public string? expiryTime;
|
||||
public OfferDetails? offerDetails;
|
||||
public PrepaidPlan? prepaidPlan;
|
||||
public string? productId;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PausedStateContext
|
||||
{
|
||||
public string? autoResumeTime;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubscribeWithGoogleInfo
|
||||
{
|
||||
public string? emailAddress;
|
||||
public string? familyName;
|
||||
public string? givenName;
|
||||
public string? profileId;
|
||||
public string? profileName;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class TestPurchase{}
|
||||
|
||||
[System.Serializable]
|
||||
public class DeveloperInitiatedCancellation{}
|
||||
|
||||
[System.Serializable]
|
||||
public class ReplacementCancellation{}
|
||||
|
||||
[System.Serializable]
|
||||
public class SystemInitiatedCancellation{}
|
||||
|
||||
[System.Serializable]
|
||||
public class UserInitiatedCancellation
|
||||
{
|
||||
public CancelSurveyResult? cancelSurveyResult;
|
||||
public string? cancelTime;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AutoRenewingPlan
|
||||
{
|
||||
public string? autoRenewEnabled;
|
||||
public SubscriptionItemPriceChangeDetails? priceChangeDetails;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class DeferredItemReplacement
|
||||
{
|
||||
public string? productId;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class OfferDetails
|
||||
{
|
||||
public List<string>? offerTags;
|
||||
public string? basePlanId;
|
||||
public string? offerId;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PrepaidPlan
|
||||
{
|
||||
public string? allowExtendAfterTime;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class CancelSurveyResult
|
||||
{
|
||||
public string? reason;
|
||||
public string? reasonUserInput;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SubscriptionItemPriceChangeDetails
|
||||
{
|
||||
public string? expectedNewPriceChargeTime;
|
||||
public Money? newPrice;
|
||||
public string? priceChangeMode;
|
||||
public string? priceChangeState;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Money
|
||||
{
|
||||
public string? currencyCode;
|
||||
public long nanos;
|
||||
public long units;
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a1435104a69d4c8ebcc6f237cc29a54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"name": "BigoAds"
|
||||
}
|
||||
{
|
||||
"name": "BigoAds"
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+106
-106
@@ -1,106 +1,106 @@
|
||||
package sg.bigo.ads;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sg.bigo.ads.api.AdOptionsView;
|
||||
import sg.bigo.ads.api.AdTag;
|
||||
import sg.bigo.ads.api.MediaView;
|
||||
import sg.bigo.ads.api.NativeAd;
|
||||
|
||||
public class AdHelper {
|
||||
|
||||
public static void postToAndroidMainThread(Runnable runnable) {
|
||||
new Handler(Looper.getMainLooper()).post(runnable);
|
||||
}
|
||||
|
||||
public static void addAdView(Activity activity, View adView, int position) {
|
||||
if (adView == null) return;
|
||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||
String tag = "ad_container";
|
||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||
if (adContainer == null) {
|
||||
adContainer = new FrameLayout(activity);
|
||||
adContainer.setTag(tag);
|
||||
}
|
||||
contentView.removeView(adContainer);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, position);
|
||||
contentView.addView(adContainer, layoutParams);
|
||||
adContainer.removeAllViews();
|
||||
adContainer.addView(adView);
|
||||
}
|
||||
|
||||
public static void removeAdView(Activity activity)
|
||||
{
|
||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||
String tag = "ad_container";
|
||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||
if (adContainer == null) return;
|
||||
adContainer.removeAllViews();
|
||||
}
|
||||
|
||||
public static int getLayoutIdByResName(Activity activity, String resName) {
|
||||
return activity.getResources().getIdentifier(resName, "layout", activity.getPackageName());
|
||||
}
|
||||
|
||||
public static int getDrawableIdByResName(Activity activity, String resName) {
|
||||
return activity.getResources().getIdentifier(resName, "drawable", activity.getPackageName());
|
||||
}
|
||||
|
||||
public static View renderNativeAdView(Activity activity, NativeAd nativeAd, String layoutResName) {
|
||||
int layoutId = getLayoutIdByResName(activity, layoutResName);
|
||||
if (layoutId <= 0) {
|
||||
Log.w("BigoAds-Unity", "Invalid res name: " + layoutResName);
|
||||
return null;
|
||||
}
|
||||
View view = LayoutInflater.from(activity).inflate(layoutId, null, false);
|
||||
if (!(view instanceof ViewGroup)) {
|
||||
return view;
|
||||
}
|
||||
ViewGroup nativeView = (ViewGroup) view;
|
||||
TextView titleView = findViewByIdName(nativeView, "native_title");
|
||||
TextView descriptionView = findViewByIdName(nativeView, "native_description");
|
||||
TextView warningView = findViewByIdName(nativeView, "native_warning");
|
||||
Button ctaButton = findViewByIdName(nativeView, "native_cta");
|
||||
MediaView mediaView = findViewByIdName(nativeView, "native_media_view");
|
||||
ImageView iconView = findViewByIdName(nativeView, "native_icon_view");
|
||||
AdOptionsView optionsView = findViewByIdName(nativeView, "native_option_view");
|
||||
|
||||
titleView.setTag(AdTag.TITLE);
|
||||
descriptionView.setTag(AdTag.DESCRIPTION);
|
||||
warningView.setTag(AdTag.WARNING);
|
||||
ctaButton.setTag(AdTag.CALL_TO_ACTION);
|
||||
|
||||
titleView.setText(nativeAd.getTitle());
|
||||
descriptionView.setText(nativeAd.getDescription());
|
||||
warningView.setText(nativeAd.getWarning());
|
||||
ctaButton.setText(nativeAd.getCallToAction());
|
||||
|
||||
List<View> clickableViews = new ArrayList<>();
|
||||
clickableViews.add(titleView);
|
||||
clickableViews.add(descriptionView);
|
||||
clickableViews.add(ctaButton);
|
||||
nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews);
|
||||
return nativeView;
|
||||
}
|
||||
|
||||
private static <T extends View> T findViewByIdName(ViewGroup parent, String name) {
|
||||
Context context = parent.getContext();
|
||||
int id = context.getResources().getIdentifier(name, "id", context.getPackageName());
|
||||
return parent.findViewById(id);
|
||||
}
|
||||
}
|
||||
package sg.bigo.ads;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sg.bigo.ads.api.AdOptionsView;
|
||||
import sg.bigo.ads.api.AdTag;
|
||||
import sg.bigo.ads.api.MediaView;
|
||||
import sg.bigo.ads.api.NativeAd;
|
||||
|
||||
public class AdHelper {
|
||||
|
||||
public static void postToAndroidMainThread(Runnable runnable) {
|
||||
new Handler(Looper.getMainLooper()).post(runnable);
|
||||
}
|
||||
|
||||
public static void addAdView(Activity activity, View adView, int position) {
|
||||
if (adView == null) return;
|
||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||
String tag = "ad_container";
|
||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||
if (adContainer == null) {
|
||||
adContainer = new FrameLayout(activity);
|
||||
adContainer.setTag(tag);
|
||||
}
|
||||
contentView.removeView(adContainer);
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, position);
|
||||
contentView.addView(adContainer, layoutParams);
|
||||
adContainer.removeAllViews();
|
||||
adContainer.addView(adView);
|
||||
}
|
||||
|
||||
public static void removeAdView(Activity activity)
|
||||
{
|
||||
ViewGroup contentView = activity.findViewById(android.R.id.content);
|
||||
String tag = "ad_container";
|
||||
ViewGroup adContainer = contentView.findViewWithTag(tag);
|
||||
if (adContainer == null) return;
|
||||
adContainer.removeAllViews();
|
||||
}
|
||||
|
||||
public static int getLayoutIdByResName(Activity activity, String resName) {
|
||||
return activity.getResources().getIdentifier(resName, "layout", activity.getPackageName());
|
||||
}
|
||||
|
||||
public static int getDrawableIdByResName(Activity activity, String resName) {
|
||||
return activity.getResources().getIdentifier(resName, "drawable", activity.getPackageName());
|
||||
}
|
||||
|
||||
public static View renderNativeAdView(Activity activity, NativeAd nativeAd, String layoutResName) {
|
||||
int layoutId = getLayoutIdByResName(activity, layoutResName);
|
||||
if (layoutId <= 0) {
|
||||
Log.w("BigoAds-Unity", "Invalid res name: " + layoutResName);
|
||||
return null;
|
||||
}
|
||||
View view = LayoutInflater.from(activity).inflate(layoutId, null, false);
|
||||
if (!(view instanceof ViewGroup)) {
|
||||
return view;
|
||||
}
|
||||
ViewGroup nativeView = (ViewGroup) view;
|
||||
TextView titleView = findViewByIdName(nativeView, "native_title");
|
||||
TextView descriptionView = findViewByIdName(nativeView, "native_description");
|
||||
TextView warningView = findViewByIdName(nativeView, "native_warning");
|
||||
Button ctaButton = findViewByIdName(nativeView, "native_cta");
|
||||
MediaView mediaView = findViewByIdName(nativeView, "native_media_view");
|
||||
ImageView iconView = findViewByIdName(nativeView, "native_icon_view");
|
||||
AdOptionsView optionsView = findViewByIdName(nativeView, "native_option_view");
|
||||
|
||||
titleView.setTag(AdTag.TITLE);
|
||||
descriptionView.setTag(AdTag.DESCRIPTION);
|
||||
warningView.setTag(AdTag.WARNING);
|
||||
ctaButton.setTag(AdTag.CALL_TO_ACTION);
|
||||
|
||||
titleView.setText(nativeAd.getTitle());
|
||||
descriptionView.setText(nativeAd.getDescription());
|
||||
warningView.setText(nativeAd.getWarning());
|
||||
ctaButton.setText(nativeAd.getCallToAction());
|
||||
|
||||
List<View> clickableViews = new ArrayList<>();
|
||||
clickableViews.add(titleView);
|
||||
clickableViews.add(descriptionView);
|
||||
clickableViews.add(ctaButton);
|
||||
nativeAd.registerViewForInteraction(nativeView, mediaView, iconView, optionsView, clickableViews);
|
||||
return nativeView;
|
||||
}
|
||||
|
||||
private static <T extends View> T findViewByIdName(ViewGroup parent, String name) {
|
||||
Context context = parent.getContext();
|
||||
int id = context.getResources().getIdentifier(name, "id", context.getPackageName());
|
||||
return parent.findViewById(id);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+13
-13
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dependencies>
|
||||
<iosPods>
|
||||
<iosPod name="BigoADS" version="5.1.2"/>
|
||||
</iosPods>
|
||||
<androidPackages>
|
||||
<androidPackage spec="com.bigossp:bigo-ads:5.3.0">
|
||||
<repositories>
|
||||
<repository>https://repo1.maven.org/maven2/</repository>
|
||||
</repositories>
|
||||
</androidPackage>
|
||||
</androidPackages>
|
||||
</dependencies>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dependencies>
|
||||
<iosPods>
|
||||
<iosPod name="BigoADS" version="5.1.2"/>
|
||||
</iosPods>
|
||||
<androidPackages>
|
||||
<androidPackage spec="com.bigossp:bigo-ads:5.3.0">
|
||||
<repositories>
|
||||
<repository>https://repo1.maven.org/maven2/</repository>
|
||||
</repositories>
|
||||
</androidPackage>
|
||||
</androidPackages>
|
||||
</dependencies>
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+104
-104
@@ -1,104 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<sg.bigo.ads.api.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/native_ad_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white"
|
||||
android:padding="8dp"
|
||||
tools:ignore="ContentDescription">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_ad_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerInside"
|
||||
android:text="Ad" />
|
||||
|
||||
<sg.bigo.ads.api.MediaView
|
||||
android:id="@+id/native_media_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/native_ad_label"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/native_icon_view"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_below="@id/native_media_view"
|
||||
android:layout_marginTop="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/native_icon_view"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_toEndOf="@id/native_icon_view"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/native_title"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toEndOf="@id/native_icon_view"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/native_cta"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_below="@id/native_icon_view"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="@android:color/holo_blue_light"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="ObsoleteLayoutParam" />
|
||||
|
||||
<sg.bigo.ads.api.AdOptionsView
|
||||
android:id="@+id/native_option_view"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignTop="@id/native_icon_view"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/native_ad_label"
|
||||
android:layout_alignBottom="@id/native_ad_label"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/native_ad_label"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</sg.bigo.ads.api.NativeAdView>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<sg.bigo.ads.api.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/native_ad_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/white"
|
||||
android:padding="8dp"
|
||||
tools:ignore="ContentDescription">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_ad_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="centerInside"
|
||||
android:text="Ad" />
|
||||
|
||||
<sg.bigo.ads.api.MediaView
|
||||
android:id="@+id/native_media_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/native_ad_label"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/native_icon_view"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_below="@id/native_media_view"
|
||||
android:layout_marginTop="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/native_icon_view"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_toEndOf="@id/native_icon_view"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/native_title"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toEndOf="@id/native_icon_view"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/native_cta"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_below="@id/native_icon_view"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="@android:color/holo_blue_light"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textAllCaps="false"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="ObsoleteLayoutParam" />
|
||||
|
||||
<sg.bigo.ads.api.AdOptionsView
|
||||
android:id="@+id/native_option_view"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignTop="@id/native_icon_view"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/native_warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/native_ad_label"
|
||||
android:layout_alignBottom="@id/native_ad_label"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/native_ad_label"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text=""
|
||||
android:textColor="@android:color/darker_gray"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</sg.bigo.ads.api.NativeAdView>
|
||||
|
||||
Assets/MYp0ZVTT2QSDK/ThirdParty/BigoAdsAll/Plugins/Android/res/layout/layout_bigo_native_ad.xml.meta
Vendored
Regular → Executable
+11
-11
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dependencies>
|
||||
<androidPackages>
|
||||
<androidPackage spec="androidx.media3:media3-exoplayer:1.0.0-alpha01" />
|
||||
<androidPackage spec="androidx.appcompat:appcompat:1.2.0"/>
|
||||
<androidPackage spec="com.google.android.material:material:1.2.1"/>
|
||||
<androidPackage spec="androidx.annotation:annotation:1.2.0"/>
|
||||
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
|
||||
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.0.1"/>
|
||||
</androidPackages>
|
||||
</dependencies>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dependencies>
|
||||
<androidPackages>
|
||||
<androidPackage spec="androidx.media3:media3-exoplayer:1.0.0-alpha01" />
|
||||
<androidPackage spec="androidx.appcompat:appcompat:1.2.0"/>
|
||||
<androidPackage spec="com.google.android.material:material:1.2.1"/>
|
||||
<androidPackage spec="androidx.annotation:annotation:1.2.0"/>
|
||||
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"/>
|
||||
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.0.1"/>
|
||||
</androidPackages>
|
||||
</dependencies>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api
|
||||
|
||||
Vendored
Regular → Executable
+21
-21
@@ -1,21 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IKwaiAdListener
|
||||
{
|
||||
void OnLoaded(string unitId, string price);
|
||||
|
||||
void OnLoadFailed(string unitId, int code, string msg);
|
||||
|
||||
void OnShow();
|
||||
|
||||
void OnShowFailed(int code, string msg);
|
||||
|
||||
void OnClick();
|
||||
|
||||
void OnClosed();
|
||||
|
||||
void OnReward();
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IKwaiAdListener
|
||||
{
|
||||
void OnLoaded(string unitId, string price);
|
||||
|
||||
void OnLoadFailed(string unitId, int code, string msg);
|
||||
|
||||
void OnShow();
|
||||
|
||||
void OnShowFailed(int code, string msg);
|
||||
|
||||
void OnClick();
|
||||
|
||||
void OnClosed();
|
||||
|
||||
void OnReward();
|
||||
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+3
-3
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"name": "KwaiAds"
|
||||
}
|
||||
{
|
||||
"name": "KwaiAds"
|
||||
}
|
||||
|
||||
+66
-66
@@ -1,66 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsMgr
|
||||
{
|
||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||
{
|
||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId) // ±ØÌî
|
||||
.SetToken(token) // ±ØÌî
|
||||
.SetAppName("")
|
||||
.SetAppDomain("")
|
||||
.SetAppStoreUrl("")
|
||||
.SetDebugLog(debug)
|
||||
.Build();
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||
}
|
||||
|
||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
private Action<bool, int, string> _initCallBack;
|
||||
|
||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||
{
|
||||
_initCallBack = callBack;
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
_initCallBack?.Invoke(false, code, msg);
|
||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||
}
|
||||
|
||||
public void OnSuccess()
|
||||
{
|
||||
_initCallBack?.Invoke(true, 0, "");
|
||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class KwaiLog
|
||||
{
|
||||
public static bool isShow = true;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.LogError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsMgr
|
||||
{
|
||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||
{
|
||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId) // ±ØÌî
|
||||
.SetToken(token) // ±ØÌî
|
||||
.SetAppName("")
|
||||
.SetAppDomain("")
|
||||
.SetAppStoreUrl("")
|
||||
.SetDebugLog(debug)
|
||||
.Build();
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||
}
|
||||
|
||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
private Action<bool, int, string> _initCallBack;
|
||||
|
||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||
{
|
||||
_initCallBack = callBack;
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
_initCallBack?.Invoke(false, code, msg);
|
||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||
}
|
||||
|
||||
public void OnSuccess()
|
||||
{
|
||||
_initCallBack?.Invoke(true, 0, "");
|
||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class KwaiLog
|
||||
{
|
||||
public static bool isShow = true;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.LogError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+133
-133
@@ -1,133 +1,133 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiInterAd
|
||||
{
|
||||
private IInterstitialAdController _kwaiInter;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||
if (_kwaiInter != null)
|
||||
{
|
||||
_kwaiInter.Destroy();
|
||||
_kwaiInter = null;
|
||||
}
|
||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
// 构建KwaiInterstitialAdRequest
|
||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiInterstitialAdRequest 配置请求参数
|
||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
_kwaiInter.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||
_kwaiInter?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyLoss();
|
||||
_kwaiInter?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
|
||||
public InterstitialAdListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiInterAd
|
||||
{
|
||||
private IInterstitialAdController _kwaiInter;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||
if (_kwaiInter != null)
|
||||
{
|
||||
_kwaiInter.Destroy();
|
||||
_kwaiInter = null;
|
||||
}
|
||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
// 构建KwaiInterstitialAdRequest
|
||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiInterstitialAdRequest 配置请求参数
|
||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
_kwaiInter.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||
_kwaiInter?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyLoss();
|
||||
_kwaiInter?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
|
||||
public InterstitialAdListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+139
-139
@@ -1,139 +1,139 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiVideoAd
|
||||
{
|
||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
if(_kwaiReward != null)
|
||||
{
|
||||
_kwaiReward.Destroy();
|
||||
_kwaiReward = null;
|
||||
}
|
||||
|
||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
|
||||
// 构建KwaiRewardAdRequest
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiRewardAdRequest 配置请求参数
|
||||
// - IRewardAdListener实现类,回调为激励
|
||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(IsReady())
|
||||
{
|
||||
_kwaiReward.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||
_kwaiReward?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyLoss();
|
||||
_kwaiReward?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
|
||||
private class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiVideoAd
|
||||
{
|
||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
if(_kwaiReward != null)
|
||||
{
|
||||
_kwaiReward.Destroy();
|
||||
_kwaiReward = null;
|
||||
}
|
||||
|
||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
|
||||
// 构建KwaiRewardAdRequest
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiRewardAdRequest 配置请求参数
|
||||
// - IRewardAdListener实现类,回调为激励
|
||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(IsReady())
|
||||
{
|
||||
_kwaiReward.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||
_kwaiReward?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyLoss();
|
||||
_kwaiReward?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
|
||||
private class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+124
-124
@@ -1,125 +1,125 @@
|
||||
#if UNITY_ANDROID
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildPostProcessorVoSdk : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
public int callbackOrder => 0;
|
||||
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
Debug.Log("AndroidBuildPostProcessor running after gradle project generation");
|
||||
|
||||
// 添加AndroidManifest权限
|
||||
AddManifestPermissions(path);
|
||||
|
||||
}
|
||||
|
||||
private void AddManifestPermissions(string gradleProjectPath)
|
||||
{
|
||||
string manifestPath = Path.Combine(gradleProjectPath, "src/main/AndroidManifest.xml");
|
||||
if (!File.Exists(manifestPath))
|
||||
{
|
||||
Debug.LogError("AndroidManifest.xml not found at: " + manifestPath);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(manifestPath);
|
||||
|
||||
// 更可靠的方式查找 manifest 节点
|
||||
XmlNode manifestNode = doc.SelectSingleNode("//manifest");
|
||||
if (manifestNode == null)
|
||||
{
|
||||
Debug.LogError("No manifest node found in AndroidManifest.xml");
|
||||
Debug.Log("Trying to parse document element as manifest...");
|
||||
manifestNode = doc.DocumentElement;
|
||||
if (manifestNode == null || manifestNode.Name != "manifest")
|
||||
{
|
||||
Debug.LogError("Failed to find manifest node, document element is: " +
|
||||
(manifestNode?.Name ?? "null"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 要添加的权限列表
|
||||
string[] permissions = new string[]
|
||||
{
|
||||
"android.permission.INTERNET",
|
||||
"android.permission.ACCESS_NETWORK_STATE",
|
||||
"android.permission.ACCESS_WIFI_STATE",
|
||||
"android.permission.WAKE_LOCK",
|
||||
//"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||
//"android.permission.READ_PHONE_STATE",
|
||||
};
|
||||
|
||||
// 添加权限
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
if (!PermissionExists(doc, permission))
|
||||
{
|
||||
XmlElement element = doc.CreateElement("uses-permission");
|
||||
element.SetAttribute("name", "http://schemas.android.com/apk/res/android", permission);
|
||||
manifestNode.AppendChild(element);
|
||||
Debug.Log("Added permission: " + permission);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加queries
|
||||
AddQueriesIfNeeded(doc, manifestNode);
|
||||
|
||||
// 保存修改
|
||||
doc.Save(manifestPath);
|
||||
Debug.Log("Successfully updated AndroidManifest.xml");
|
||||
}
|
||||
|
||||
private bool PermissionExists(XmlDocument doc, string permissionName)
|
||||
{
|
||||
XmlNodeList nodes = doc.GetElementsByTagName("uses-permission");
|
||||
foreach (XmlNode node in nodes)
|
||||
{
|
||||
var nameAttr = node.Attributes?["android:name"];
|
||||
if (nameAttr != null && nameAttr.Value == permissionName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AddQueriesIfNeeded(XmlDocument doc, XmlNode manifestNode)
|
||||
{
|
||||
// 检查是否已存在queries节点
|
||||
XmlNode queriesNode = doc.SelectSingleNode("//queries");
|
||||
if (queriesNode != null) return;
|
||||
|
||||
// 创建queries节点
|
||||
queriesNode = doc.CreateElement("queries");
|
||||
|
||||
// 添加package节点
|
||||
string[] packages = { "com.android.vending", "com.google.android.gms" };
|
||||
foreach (var package in packages)
|
||||
{
|
||||
XmlElement packageElement = doc.CreateElement("package");
|
||||
packageElement.SetAttribute("name", "http://schemas.android.com/apk/res/android", package);
|
||||
queriesNode.AppendChild(packageElement);
|
||||
}
|
||||
|
||||
// 将queries节点添加到manifest中(application节点之前)
|
||||
XmlNode applicationNode = doc.SelectSingleNode("//application");
|
||||
if (applicationNode != null)
|
||||
{
|
||||
manifestNode.InsertBefore(queriesNode, applicationNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
manifestNode.AppendChild(queriesNode);
|
||||
}
|
||||
Debug.Log("Added queries section to AndroidManifest.xml");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#if UNITY_ANDROID
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
|
||||
public class BuildPostProcessorVoSdk : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
public int callbackOrder => 0;
|
||||
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
Debug.Log("AndroidBuildPostProcessor running after gradle project generation");
|
||||
|
||||
// 添加AndroidManifest权限
|
||||
AddManifestPermissions(path);
|
||||
|
||||
}
|
||||
|
||||
private void AddManifestPermissions(string gradleProjectPath)
|
||||
{
|
||||
string manifestPath = Path.Combine(gradleProjectPath, "src/main/AndroidManifest.xml");
|
||||
if (!File.Exists(manifestPath))
|
||||
{
|
||||
Debug.LogError("AndroidManifest.xml not found at: " + manifestPath);
|
||||
return;
|
||||
}
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(manifestPath);
|
||||
|
||||
// 更可靠的方式查找 manifest 节点
|
||||
XmlNode manifestNode = doc.SelectSingleNode("//manifest");
|
||||
if (manifestNode == null)
|
||||
{
|
||||
Debug.LogError("No manifest node found in AndroidManifest.xml");
|
||||
Debug.Log("Trying to parse document element as manifest...");
|
||||
manifestNode = doc.DocumentElement;
|
||||
if (manifestNode == null || manifestNode.Name != "manifest")
|
||||
{
|
||||
Debug.LogError("Failed to find manifest node, document element is: " +
|
||||
(manifestNode?.Name ?? "null"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 要添加的权限列表
|
||||
string[] permissions = new string[]
|
||||
{
|
||||
"android.permission.INTERNET",
|
||||
"android.permission.ACCESS_NETWORK_STATE",
|
||||
"android.permission.ACCESS_WIFI_STATE",
|
||||
"android.permission.WAKE_LOCK",
|
||||
//"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||
//"android.permission.READ_PHONE_STATE",
|
||||
};
|
||||
|
||||
// 添加权限
|
||||
foreach (var permission in permissions)
|
||||
{
|
||||
if (!PermissionExists(doc, permission))
|
||||
{
|
||||
XmlElement element = doc.CreateElement("uses-permission");
|
||||
element.SetAttribute("name", "http://schemas.android.com/apk/res/android", permission);
|
||||
manifestNode.AppendChild(element);
|
||||
Debug.Log("Added permission: " + permission);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加queries
|
||||
AddQueriesIfNeeded(doc, manifestNode);
|
||||
|
||||
// 保存修改
|
||||
doc.Save(manifestPath);
|
||||
Debug.Log("Successfully updated AndroidManifest.xml");
|
||||
}
|
||||
|
||||
private bool PermissionExists(XmlDocument doc, string permissionName)
|
||||
{
|
||||
XmlNodeList nodes = doc.GetElementsByTagName("uses-permission");
|
||||
foreach (XmlNode node in nodes)
|
||||
{
|
||||
var nameAttr = node.Attributes?["android:name"];
|
||||
if (nameAttr != null && nameAttr.Value == permissionName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AddQueriesIfNeeded(XmlDocument doc, XmlNode manifestNode)
|
||||
{
|
||||
// 检查是否已存在queries节点
|
||||
XmlNode queriesNode = doc.SelectSingleNode("//queries");
|
||||
if (queriesNode != null) return;
|
||||
|
||||
// 创建queries节点
|
||||
queriesNode = doc.CreateElement("queries");
|
||||
|
||||
// 添加package节点
|
||||
string[] packages = { "com.android.vending", "com.google.android.gms" };
|
||||
foreach (var package in packages)
|
||||
{
|
||||
XmlElement packageElement = doc.CreateElement("package");
|
||||
packageElement.SetAttribute("name", "http://schemas.android.com/apk/res/android", package);
|
||||
queriesNode.AppendChild(packageElement);
|
||||
}
|
||||
|
||||
// 将queries节点添加到manifest中(application节点之前)
|
||||
XmlNode applicationNode = doc.SelectSingleNode("//application");
|
||||
if (applicationNode != null)
|
||||
{
|
||||
manifestNode.InsertBefore(queriesNode, applicationNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
manifestNode.AppendChild(queriesNode);
|
||||
}
|
||||
Debug.Log("Added queries section to AndroidManifest.xml");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
Vendored
Regular → Executable
+20
-20
@@ -1,20 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
// ISDKInitCallback.cs
|
||||
public class ISDKInitCallback : AndroidJavaProxy
|
||||
{
|
||||
public Action<bool, string> onInitResult;
|
||||
|
||||
public ISDKInitCallback() : base("com.rixengine.unity_plugin.ISDKInit") { }
|
||||
|
||||
public void initResult(bool success, string message)
|
||||
{
|
||||
onInitResult?.Invoke(success, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
// ISDKInitCallback.cs
|
||||
public class ISDKInitCallback : AndroidJavaProxy
|
||||
{
|
||||
public Action<bool, string> onInitResult;
|
||||
|
||||
public ISDKInitCallback() : base("com.rixengine.unity_plugin.ISDKInit") { }
|
||||
|
||||
public void initResult(bool success, string message)
|
||||
{
|
||||
onInitResult?.Invoke(success, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+80
-80
@@ -1,80 +1,80 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoAdSDK
|
||||
{
|
||||
private static AndroidJavaClass _adClass;
|
||||
|
||||
// 初始化SDK
|
||||
public static void Initialize(string host, string token, string sid, string appId, Action<bool, string> callback)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
LogD("SDK only works on Android platform");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java回调对象
|
||||
var initCallback = new ISDKInitCallback
|
||||
{
|
||||
onInitResult = callback
|
||||
};
|
||||
|
||||
// 调用Java方法
|
||||
GetAdClass().CallStatic("init", host, token, sid, appId, initCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogE($"Initialize failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 其他接口封装
|
||||
public static void SetDebug(bool enable) => GetAdClass().CallStatic("setDebug", enable);
|
||||
|
||||
public static void SetGDPRConsent(bool consent) => GetAdClass().CallStatic("setSubjectToGDPR", consent);
|
||||
|
||||
public static void SetUserConsent(string consent) => GetAdClass().CallStatic("setUserConsent", consent);
|
||||
|
||||
public static void SetUSPrivacy(string privacy) => GetAdClass().CallStatic("subjectToUSPrivacy", privacy);
|
||||
|
||||
public static void SetExtraParameters(Dictionary<string, object> parameters)
|
||||
{
|
||||
using AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
||||
foreach (var kv in parameters)
|
||||
{
|
||||
map.Call<AndroidJavaObject>("put", kv.Key, kv.Value);
|
||||
}
|
||||
GetAdClass().CallStatic("setExtraParameters", map);
|
||||
}
|
||||
|
||||
// 获取网络信息
|
||||
public static string GetNetworkName() => GetAdClass().CallStatic<string>("getNetWorkName");
|
||||
public static string GetNetworkVersion() => GetAdClass().CallStatic<string>("getNetWorkVersion");
|
||||
|
||||
public static void LogD(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogD", msg);
|
||||
}
|
||||
|
||||
public static void LogE(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogE", msg);
|
||||
}
|
||||
|
||||
private static AndroidJavaClass GetAdClass()
|
||||
{
|
||||
if (_adClass == null)
|
||||
{
|
||||
_adClass = new AndroidJavaClass("com.rixengine.unity_plugin.RiEngineAd");
|
||||
}
|
||||
return _adClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoAdSDK
|
||||
{
|
||||
private static AndroidJavaClass _adClass;
|
||||
|
||||
// 初始化SDK
|
||||
public static void Initialize(string host, string token, string sid, string appId, Action<bool, string> callback)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
LogD("SDK only works on Android platform");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java回调对象
|
||||
var initCallback = new ISDKInitCallback
|
||||
{
|
||||
onInitResult = callback
|
||||
};
|
||||
|
||||
// 调用Java方法
|
||||
GetAdClass().CallStatic("init", host, token, sid, appId, initCallback);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogE($"Initialize failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 其他接口封装
|
||||
public static void SetDebug(bool enable) => GetAdClass().CallStatic("setDebug", enable);
|
||||
|
||||
public static void SetGDPRConsent(bool consent) => GetAdClass().CallStatic("setSubjectToGDPR", consent);
|
||||
|
||||
public static void SetUserConsent(string consent) => GetAdClass().CallStatic("setUserConsent", consent);
|
||||
|
||||
public static void SetUSPrivacy(string privacy) => GetAdClass().CallStatic("subjectToUSPrivacy", privacy);
|
||||
|
||||
public static void SetExtraParameters(Dictionary<string, object> parameters)
|
||||
{
|
||||
using AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap");
|
||||
foreach (var kv in parameters)
|
||||
{
|
||||
map.Call<AndroidJavaObject>("put", kv.Key, kv.Value);
|
||||
}
|
||||
GetAdClass().CallStatic("setExtraParameters", map);
|
||||
}
|
||||
|
||||
// 获取网络信息
|
||||
public static string GetNetworkName() => GetAdClass().CallStatic<string>("getNetWorkName");
|
||||
public static string GetNetworkVersion() => GetAdClass().CallStatic<string>("getNetWorkVersion");
|
||||
|
||||
public static void LogD(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogD", msg);
|
||||
}
|
||||
|
||||
public static void LogE(string msg)
|
||||
{
|
||||
GetAdClass().CallStatic("LogE", msg);
|
||||
}
|
||||
|
||||
private static AndroidJavaClass GetAdClass()
|
||||
{
|
||||
if (_adClass == null)
|
||||
{
|
||||
_adClass = new AndroidJavaClass("com.rixengine.unity_plugin.RiEngineAd");
|
||||
}
|
||||
return _adClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+157
-157
@@ -1,157 +1,157 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAd
|
||||
{
|
||||
private AndroidJavaObject _interAd;
|
||||
private VosacoInterAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoInterAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_interAd = new AndroidJavaObject("com.rixengine.unity_plugin.InterAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoInterAdListenerProxy();
|
||||
_interAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"InterAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Load");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_interAd.Call("Show");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _interAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _interAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Destroy");
|
||||
_interAd?.Dispose();
|
||||
_interAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddShowListener(Action callback)
|
||||
=> _listenerProxy.OnShow += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_interAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAd
|
||||
{
|
||||
private AndroidJavaObject _interAd;
|
||||
private VosacoInterAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoInterAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_interAd = new AndroidJavaObject("com.rixengine.unity_plugin.InterAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoInterAdListenerProxy();
|
||||
_interAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"InterAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Load");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_interAd.Call("Show");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _interAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _interAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_interAd.Call("Destroy");
|
||||
_interAd?.Dispose();
|
||||
_interAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddShowListener(Action callback)
|
||||
=> _listenerProxy.OnShow += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_interAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+71
-71
@@ -1,71 +1,71 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnShow;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoInterAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IInterAdListener") { }
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onShow");
|
||||
OnShow?.Invoke();
|
||||
}
|
||||
|
||||
public void onClose()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClose");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoError()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoError");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoInterAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnShow;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoInterAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IInterAdListener") { }
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onShow");
|
||||
OnShow?.Invoke();
|
||||
}
|
||||
|
||||
public void onClose()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onClose");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onVideoError()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY INTER Call : onVideoError");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+155
-155
@@ -1,155 +1,155 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAd
|
||||
{
|
||||
private AndroidJavaObject _rewardAd;
|
||||
private VosacoRewardAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoRewardAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_rewardAd = new AndroidJavaObject("com.rixengine.unity_plugin.RewardAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoRewardAdListenerProxy();
|
||||
_rewardAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"RewardAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Load");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Show");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Destroy");
|
||||
_rewardAd?.Dispose();
|
||||
_rewardAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddRewardListener(Action callback)
|
||||
=> _listenerProxy.OnReward += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_rewardAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAd
|
||||
{
|
||||
private AndroidJavaObject _rewardAd;
|
||||
private VosacoRewardAdListenerProxy _listenerProxy;
|
||||
|
||||
public VosacoRewardAd(string unitId)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建Java插屏广告对象
|
||||
_rewardAd = new AndroidJavaObject("com.rixengine.unity_plugin.RewardAd", unitId);
|
||||
|
||||
// 创建并设置监听器
|
||||
_listenerProxy = new VosacoRewardAdListenerProxy();
|
||||
_rewardAd.Call("SetListener", _listenerProxy);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"RewardAd creation failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
// 加载广告
|
||||
public void LoadAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Load");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"LoadAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 显示广告
|
||||
public void ShowAd()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Show");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"ShowAd failed: {e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查广告是否就绪
|
||||
public bool IsAdReady()
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<bool>("IsReady");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"IsAdReady error :{e.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取广告价格
|
||||
public double GetAdPrice()
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
try
|
||||
{
|
||||
return _rewardAd.Call<double>("GetPrice");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"GetAdPrice error :{e.Message}");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 销毁广告对象
|
||||
public void Destroy()
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
try
|
||||
{
|
||||
_rewardAd.Call("Destroy");
|
||||
_rewardAd?.Dispose();
|
||||
_rewardAd = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
VosacoAdSDK.LogE($"Destroy error :{e.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 注册事件监听器
|
||||
public void AddLoadedListener(Action callback)
|
||||
=> _listenerProxy.OnLoaded += callback;
|
||||
|
||||
public void AddLoadFailedListener(Action callback)
|
||||
=> _listenerProxy.OnLoadFailed += callback;
|
||||
|
||||
public void AddClickedListener(Action callback)
|
||||
=> _listenerProxy.OnClicked += callback;
|
||||
|
||||
public void AddRewardListener(Action callback)
|
||||
=> _listenerProxy.OnReward += callback;
|
||||
|
||||
public void AddCloseListener(Action callback)
|
||||
=> _listenerProxy.OnClose += callback;
|
||||
|
||||
public void AddVideoStartListener(Action callback)
|
||||
=> _listenerProxy.OnVideoStart += callback;
|
||||
|
||||
public void AddVideoEndListener(Action callback)
|
||||
=> _listenerProxy.OnVideoEnd += callback;
|
||||
|
||||
public void AddVideoErrorListener(Action callback)
|
||||
=> _listenerProxy.OnVideoError += callback;
|
||||
|
||||
|
||||
private bool IsValid()
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android)
|
||||
{
|
||||
VosacoAdSDK.LogD("Interstitial ads only supported on Android");
|
||||
return false;
|
||||
}
|
||||
if (_rewardAd == null)
|
||||
{
|
||||
VosacoAdSDK.LogE("Interstitial ad not initialized");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+73
-73
@@ -1,73 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnReward;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoRewardAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IRewardListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayFailed");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClosed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClosed");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onReward()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onReward");
|
||||
OnReward?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AD.VosacoSDK
|
||||
{
|
||||
public class VosacoRewardAdListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
public event Action OnLoaded;
|
||||
public event Action OnLoadFailed;
|
||||
public event Action OnClicked;
|
||||
public event Action OnReward;
|
||||
public event Action OnClose;
|
||||
public event Action OnVideoStart;
|
||||
public event Action OnVideoEnd;
|
||||
public event Action OnVideoError;
|
||||
|
||||
public VosacoRewardAdListenerProxy()
|
||||
: base("com.rixengine.unity_plugin.IRewardListener")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoaded");
|
||||
OnLoaded?.Invoke();
|
||||
}
|
||||
|
||||
public void onLoadFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onLoadFailed");
|
||||
OnLoadFailed?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayStart()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayStart");
|
||||
OnVideoStart?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayEnd()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayEnd");
|
||||
OnVideoEnd?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardPlayFailed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardPlayFailed");
|
||||
OnVideoError?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClosed()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClosed");
|
||||
OnClose?.Invoke();
|
||||
}
|
||||
|
||||
public void onRewardClicked()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onRewardClicked");
|
||||
OnClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void onReward()
|
||||
{
|
||||
VosacoAdSDK.LogD($"UNITY Reward Call : onReward");
|
||||
OnReward?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+3
-3
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"name": "WebView"
|
||||
}
|
||||
{
|
||||
"name": "WebView"
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+126
-126
@@ -1,127 +1,127 @@
|
||||
#if UNITY_IOS
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfigurableLocalizationPostProcess
|
||||
{
|
||||
[PostProcessBuild(500)]
|
||||
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS) return;
|
||||
|
||||
// 加载配置
|
||||
IOSLocalizationSettings settings = AssetDatabase.LoadAssetAtPath<IOSLocalizationSettings>("Assets/Editor/LocalizationSettings.asset");
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("未找到LocalizationSettings配置,使用默认多语言设置");
|
||||
settings = ScriptableObject.CreateInstance<IOSLocalizationSettings>();
|
||||
}
|
||||
|
||||
// 处理主Info.plist
|
||||
string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
|
||||
|
||||
if (!File.Exists(plistPath))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("Info.plist文件未找到: " + plistPath);
|
||||
return;
|
||||
}
|
||||
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
PlistElementDict rootDict = plist.root;
|
||||
|
||||
// 查找英语描述或使用第一个描述作为默认
|
||||
string defaultDescription = settings.languageDescriptions[0].trackingDescription;
|
||||
foreach (var desc in settings.languageDescriptions)
|
||||
{
|
||||
if (desc.languageCode == "en")
|
||||
{
|
||||
defaultDescription = desc.trackingDescription;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rootDict.SetString("NSUserTrackingUsageDescription", defaultDescription);
|
||||
plist.WriteToFile(plistPath);
|
||||
|
||||
// 为每种语言创建本地化文件
|
||||
foreach (var langDesc in settings.languageDescriptions)
|
||||
{
|
||||
if (langDesc.languageCode == "en") continue;
|
||||
|
||||
string lprojPath = Path.Combine(pathToBuiltProject, $"{langDesc.languageCode}.lproj");
|
||||
if (!Directory.Exists(lprojPath))
|
||||
{
|
||||
Directory.CreateDirectory(lprojPath);
|
||||
}
|
||||
|
||||
string stringsPath = Path.Combine(lprojPath, "InfoPlist.strings");
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(stringsPath, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
writer.WriteLine($"\"NSUserTrackingUsageDescription\" = \"{langDesc.trackingDescription}\";");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新Xcode项目
|
||||
UpdateXcodeProject(pathToBuiltProject, settings);
|
||||
|
||||
UnityEngine.Debug.Log("多语言隐私描述已成功添加到Xcode项目。");
|
||||
}
|
||||
|
||||
private static void UpdateXcodeProject(string pathToBuiltProject, IOSLocalizationSettings settings)
|
||||
{
|
||||
string pbxProjectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
|
||||
PBXProject pbxProject = new PBXProject();
|
||||
pbxProject.ReadFromFile(pbxProjectPath);
|
||||
|
||||
string targetGuid = pbxProject.GetUnityMainTargetGuid();
|
||||
|
||||
foreach (var langDesc in settings.languageDescriptions)
|
||||
{
|
||||
if (langDesc.languageCode == "en") continue;
|
||||
|
||||
string lprojPath = $"{langDesc.languageCode}.lproj";
|
||||
string stringsPath = Path.Combine(lprojPath, "InfoPlist.strings");
|
||||
|
||||
string fileGuid = pbxProject.AddFile(stringsPath, stringsPath, PBXSourceTree.Source);
|
||||
pbxProject.AddFileToBuild(targetGuid, fileGuid);
|
||||
}
|
||||
|
||||
pbxProject.WriteToFile(pbxProjectPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建配置文件的编辑器菜单
|
||||
public class LocalizationSettingsCreator
|
||||
{
|
||||
[MenuItem("Tools/IOS Localization Settings")]
|
||||
public static void CreateLocalizationSettings()
|
||||
{
|
||||
IOSLocalizationSettings asset = ScriptableObject.CreateInstance<IOSLocalizationSettings>();
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = "Assets";
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Path.GetExtension(path)))
|
||||
{
|
||||
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
|
||||
}
|
||||
|
||||
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/LocalizationSettings.asset");
|
||||
|
||||
AssetDatabase.CreateAsset(asset, assetPathAndName);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
}
|
||||
#if UNITY_IOS
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfigurableLocalizationPostProcess
|
||||
{
|
||||
[PostProcessBuild(500)]
|
||||
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS) return;
|
||||
|
||||
// 加载配置
|
||||
IOSLocalizationSettings settings = AssetDatabase.LoadAssetAtPath<IOSLocalizationSettings>("Assets/Editor/LocalizationSettings.asset");
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("未找到LocalizationSettings配置,使用默认多语言设置");
|
||||
settings = ScriptableObject.CreateInstance<IOSLocalizationSettings>();
|
||||
}
|
||||
|
||||
// 处理主Info.plist
|
||||
string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
|
||||
|
||||
if (!File.Exists(plistPath))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning("Info.plist文件未找到: " + plistPath);
|
||||
return;
|
||||
}
|
||||
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
PlistElementDict rootDict = plist.root;
|
||||
|
||||
// 查找英语描述或使用第一个描述作为默认
|
||||
string defaultDescription = settings.languageDescriptions[0].trackingDescription;
|
||||
foreach (var desc in settings.languageDescriptions)
|
||||
{
|
||||
if (desc.languageCode == "en")
|
||||
{
|
||||
defaultDescription = desc.trackingDescription;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rootDict.SetString("NSUserTrackingUsageDescription", defaultDescription);
|
||||
plist.WriteToFile(plistPath);
|
||||
|
||||
// 为每种语言创建本地化文件
|
||||
foreach (var langDesc in settings.languageDescriptions)
|
||||
{
|
||||
if (langDesc.languageCode == "en") continue;
|
||||
|
||||
string lprojPath = Path.Combine(pathToBuiltProject, $"{langDesc.languageCode}.lproj");
|
||||
if (!Directory.Exists(lprojPath))
|
||||
{
|
||||
Directory.CreateDirectory(lprojPath);
|
||||
}
|
||||
|
||||
string stringsPath = Path.Combine(lprojPath, "InfoPlist.strings");
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(stringsPath, false, System.Text.Encoding.UTF8))
|
||||
{
|
||||
writer.WriteLine($"\"NSUserTrackingUsageDescription\" = \"{langDesc.trackingDescription}\";");
|
||||
}
|
||||
}
|
||||
|
||||
// 更新Xcode项目
|
||||
UpdateXcodeProject(pathToBuiltProject, settings);
|
||||
|
||||
UnityEngine.Debug.Log("多语言隐私描述已成功添加到Xcode项目。");
|
||||
}
|
||||
|
||||
private static void UpdateXcodeProject(string pathToBuiltProject, IOSLocalizationSettings settings)
|
||||
{
|
||||
string pbxProjectPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
|
||||
PBXProject pbxProject = new PBXProject();
|
||||
pbxProject.ReadFromFile(pbxProjectPath);
|
||||
|
||||
string targetGuid = pbxProject.GetUnityMainTargetGuid();
|
||||
|
||||
foreach (var langDesc in settings.languageDescriptions)
|
||||
{
|
||||
if (langDesc.languageCode == "en") continue;
|
||||
|
||||
string lprojPath = $"{langDesc.languageCode}.lproj";
|
||||
string stringsPath = Path.Combine(lprojPath, "InfoPlist.strings");
|
||||
|
||||
string fileGuid = pbxProject.AddFile(stringsPath, stringsPath, PBXSourceTree.Source);
|
||||
pbxProject.AddFileToBuild(targetGuid, fileGuid);
|
||||
}
|
||||
|
||||
pbxProject.WriteToFile(pbxProjectPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建配置文件的编辑器菜单
|
||||
public class LocalizationSettingsCreator
|
||||
{
|
||||
[MenuItem("Tools/IOS Localization Settings")]
|
||||
public static void CreateLocalizationSettings()
|
||||
{
|
||||
IOSLocalizationSettings asset = ScriptableObject.CreateInstance<IOSLocalizationSettings>();
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = "Assets";
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Path.GetExtension(path)))
|
||||
{
|
||||
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
|
||||
}
|
||||
|
||||
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/LocalizationSettings.asset");
|
||||
|
||||
AssetDatabase.CreateAsset(asset, assetPathAndName);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.FocusProjectWindow();
|
||||
Selection.activeObject = asset;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+26
-26
@@ -1,26 +1,26 @@
|
||||
#if UNITY_IOS
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
// 可配置的多语言描述ScriptableObject
|
||||
public class IOSLocalizationSettings : ScriptableObject
|
||||
{
|
||||
[System.Serializable]
|
||||
public class LanguageDescription
|
||||
{
|
||||
public string languageCode;
|
||||
public string trackingDescription;
|
||||
}
|
||||
|
||||
public List<LanguageDescription> languageDescriptions = new List<LanguageDescription>
|
||||
{
|
||||
new LanguageDescription { languageCode = "en", trackingDescription = "Allow tracking to reduce irrelevant ads and keep the app free." },
|
||||
new LanguageDescription { languageCode = "ja", trackingDescription = "トラッキングを許可すると、無関係な広告を減らしてアプリを無料で利用できます。" },
|
||||
new LanguageDescription { languageCode = "fr", trackingDescription = "Autoriser le suivi pour réduire les publicités non pertinentes et garder l’application gratuite" },
|
||||
new LanguageDescription { languageCode = "pt", trackingDescription = "Permitir rastreamento para reduzir anúncios irrelevantes e manter o app gratuito." }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#if UNITY_IOS
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
// 可配置的多语言描述ScriptableObject
|
||||
public class IOSLocalizationSettings : ScriptableObject
|
||||
{
|
||||
[System.Serializable]
|
||||
public class LanguageDescription
|
||||
{
|
||||
public string languageCode;
|
||||
public string trackingDescription;
|
||||
}
|
||||
|
||||
public List<LanguageDescription> languageDescriptions = new List<LanguageDescription>
|
||||
{
|
||||
new LanguageDescription { languageCode = "en", trackingDescription = "Allow tracking to reduce irrelevant ads and keep the app free." },
|
||||
new LanguageDescription { languageCode = "ja", trackingDescription = "トラッキングを許可すると、無関係な広告を減らしてアプリを無料で利用できます。" },
|
||||
new LanguageDescription { languageCode = "fr", trackingDescription = "Autoriser le suivi pour réduire les publicités non pertinentes et garder l’application gratuite" },
|
||||
new LanguageDescription { languageCode = "pt", trackingDescription = "Permitir rastreamento para reduzir anúncios irrelevantes e manter o app gratuito." }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Vendored
Regular → Executable
Reference in New Issue
Block a user