备份CatanBuilding瘦身独立工程
8
LocalPackages/aihelp-5.3/Runtime.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 977f1e1832aca4f46886f2213b880cbe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
LocalPackages/aihelp-5.3/Runtime/AIHelp.asmdef
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "AIHelp"
|
||||
}
|
||||
7
LocalPackages/aihelp-5.3/Runtime/AIHelp.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24ea91e68ad6b468c97c7a6824d7a738
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/Runtime/AIHelp.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d709c602725eb4e14820e7ab46261481
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
129
LocalPackages/aihelp-5.3/Runtime/AIHelp/AIHelpSupport.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
public class AIHelpSupport
|
||||
{
|
||||
public static void Initialize(string domain, string appId, string language)
|
||||
{
|
||||
AIHelpCore.getInstance().Initialize(domain, appId, language);
|
||||
}
|
||||
|
||||
public static void Initialize(string domain, string appId)
|
||||
{
|
||||
Initialize(domain, appId, "");
|
||||
}
|
||||
|
||||
public static void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
|
||||
{
|
||||
AIHelpCore.getInstance().RegisterAsyncEventListener(eventType, listener);
|
||||
}
|
||||
|
||||
public static void UnregisterAsyncEventListener(AIHelp.EventType eventType)
|
||||
{
|
||||
AIHelpCore.getInstance().UnregisterAsyncEventListener(eventType);
|
||||
}
|
||||
|
||||
public static bool Show(string entranceId)
|
||||
{
|
||||
return AIHelpCore.getInstance().Show(entranceId);
|
||||
}
|
||||
|
||||
public static bool Show(ApiConfig apiConfig)
|
||||
{
|
||||
return AIHelpCore.getInstance().Show(apiConfig);
|
||||
}
|
||||
|
||||
public static void ShowSingleFAQ(string faqId, ConversationMoment moment)
|
||||
{
|
||||
AIHelpCore.getInstance().ShowSingleFAQ(faqId, moment);
|
||||
}
|
||||
|
||||
public static void Login(string userId)
|
||||
{
|
||||
Login(new LoginConfig.Builder().SetUserId(userId).Build());
|
||||
}
|
||||
|
||||
public static void Login(LoginConfig loginConfig)
|
||||
{
|
||||
AIHelpCore.getInstance().Login(loginConfig);
|
||||
}
|
||||
|
||||
public static void UpdateUserInfo(UserConfig userConfig)
|
||||
{
|
||||
AIHelpCore.getInstance().UpdateUserInfo(userConfig);
|
||||
}
|
||||
|
||||
public static void ResetUserInfo()
|
||||
{
|
||||
AIHelpCore.getInstance().ResetUserInfo();
|
||||
}
|
||||
|
||||
public static void UpdateSDKLanguage(string language)
|
||||
{
|
||||
AIHelpCore.getInstance().UpdateSDKLanguage(language);
|
||||
}
|
||||
|
||||
public static void SetUploadLogPath(string path)
|
||||
{
|
||||
AIHelpCore.getInstance().SetUploadLogPath(path);
|
||||
}
|
||||
|
||||
public static void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
|
||||
{
|
||||
AIHelpCore.getInstance().SetPushTokenAndPlatform(pushToken, platform);
|
||||
}
|
||||
|
||||
public static void FetchUnreadMessageCount()
|
||||
{
|
||||
AIHelpCore.getInstance().FetchUnreadMessageCount();
|
||||
}
|
||||
|
||||
public static void FetchUnreadTaskCount()
|
||||
{
|
||||
AIHelpCore.getInstance().FetchUnreadTaskCount();
|
||||
}
|
||||
|
||||
public static string GetSDKVersion()
|
||||
{
|
||||
return AIHelpCore.getInstance().GetSDKVersion();
|
||||
}
|
||||
|
||||
public static bool IsAIHelpShowing()
|
||||
{
|
||||
return AIHelpCore.getInstance().IsAIHelpShowing();
|
||||
}
|
||||
|
||||
public static void enableLogging(bool enable)
|
||||
{
|
||||
AIHelpCore.getInstance().EnableLogging(enable);
|
||||
}
|
||||
|
||||
public static void ShowUrl(string url)
|
||||
{
|
||||
AIHelpCore.getInstance().ShowUrl(url);
|
||||
}
|
||||
|
||||
public static void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
|
||||
{
|
||||
AIHelpCore.getInstance().AdditionalSupportFor(countryOrRegion);
|
||||
}
|
||||
|
||||
public static void Close() {
|
||||
AIHelpCore.getInstance().Close();
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
|
||||
public static void SetRequestedOrientation(int requestedOrientation)
|
||||
{
|
||||
AIHelpCore.getInstance().SetRequestedOrientation(requestedOrientation);
|
||||
}
|
||||
|
||||
public static void SetSDKAppearanceMode(int mode)
|
||||
{
|
||||
AIHelpCore.getInstance().SetSDKAppearanceMode(mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1e7be80affb4af588e5c113403b225
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/Runtime/AIHelp/Config.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2849caac28eb049d1aeabcee4d7abe31
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
LocalPackages/aihelp-5.3/Runtime/AIHelp/Config/ApiConfig.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
public class ApiConfig
|
||||
{
|
||||
public string EntranceId { get; }
|
||||
public string WelcomeMessage { get; }
|
||||
|
||||
private ApiConfig(Builder builder)
|
||||
{
|
||||
EntranceId = builder.EntranceId;
|
||||
WelcomeMessage = builder.WelcomeMessage;
|
||||
}
|
||||
|
||||
public class Builder
|
||||
{
|
||||
public string EntranceId { get; private set; }
|
||||
public string WelcomeMessage { get; private set; }
|
||||
|
||||
public Builder SetEntranceId(string entranceId)
|
||||
{
|
||||
EntranceId = entranceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetWelcomeMessage(string welcomeMessage)
|
||||
{
|
||||
WelcomeMessage = welcomeMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ApiConfig Build()
|
||||
{
|
||||
return new ApiConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af06fba061d114dee8bab53d2386c967
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
public class AIHelpDelegate
|
||||
{
|
||||
public delegate void AsyncEventListener(String jsonEventData, Action<string> acknowledge);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 667f6671ba9b540dba0f6c7aedc71883
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
70
LocalPackages/aihelp-5.3/Runtime/AIHelp/Config/Enum.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
|
||||
public enum PushPlatform
|
||||
{
|
||||
APNS = 1, FIREBASE = 2, JIGUANG = 3, GETUI = 4, HUAWEI = 6, ONE_SIGNAL = 7
|
||||
}
|
||||
|
||||
public enum ConversationMoment
|
||||
{
|
||||
NEVER = 1, ALWAYS = 2, ONLY_IN_ANSWER_PAGE = 3, AFTER_MARKING_UNHELPFUL = 4
|
||||
}
|
||||
|
||||
public enum PublishCountryOrRegion
|
||||
{
|
||||
CN = 1, IN = 2
|
||||
};
|
||||
|
||||
public enum EventType
|
||||
{
|
||||
/**
|
||||
* Event for SDK initialization
|
||||
*/
|
||||
Initialization,
|
||||
|
||||
/**
|
||||
* Event for user login
|
||||
*/
|
||||
UserLogin,
|
||||
|
||||
/**
|
||||
* Event for enterprise authentication
|
||||
*/
|
||||
EnterpriseAuth,
|
||||
|
||||
/**
|
||||
* Event for opening or closing a session (window)
|
||||
*/
|
||||
SessionOpen,
|
||||
SessionClose,
|
||||
|
||||
/**
|
||||
* Event for message arrival
|
||||
*/
|
||||
MessageArrival,
|
||||
|
||||
/**
|
||||
* Event for log upload
|
||||
*/
|
||||
LogUpload,
|
||||
|
||||
/**
|
||||
* Event for URL click
|
||||
*/
|
||||
UrlClick,
|
||||
|
||||
/**
|
||||
* Event for unread task count
|
||||
*/
|
||||
UnreadTaskCount,
|
||||
|
||||
/**
|
||||
* Event for conversation start, along with the user's first message
|
||||
*/
|
||||
ConversationStart,
|
||||
}
|
||||
|
||||
}
|
||||
11
LocalPackages/aihelp-5.3/Runtime/AIHelp/Config/Enum.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fbae61ea0fb14752bcd772995401549
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
public class LoginConfig
|
||||
{
|
||||
public string UserId { get; }
|
||||
public UserConfig UserConfig { get; }
|
||||
public bool EnterpriseAuth { get; }
|
||||
|
||||
private LoginConfig(Builder builder)
|
||||
{
|
||||
UserId = builder.UserId;
|
||||
UserConfig = builder.UserConfig;
|
||||
EnterpriseAuth = builder.EnterpriseAuth;
|
||||
}
|
||||
|
||||
public class Builder
|
||||
{
|
||||
public string UserId { get; private set; }
|
||||
public UserConfig UserConfig { get; private set; }
|
||||
public bool EnterpriseAuth { get; private set; }
|
||||
|
||||
public Builder SetUserId(string userId)
|
||||
{
|
||||
UserId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetUserConfig(UserConfig userConfig)
|
||||
{
|
||||
UserConfig = userConfig;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetEnterpriseAuth(bool enterpriseAuth)
|
||||
{
|
||||
EnterpriseAuth = enterpriseAuth;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginConfig Build()
|
||||
{
|
||||
return new LoginConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53e798a014f114fdf8e104f67b645563
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
57
LocalPackages/aihelp-5.3/Runtime/AIHelp/Config/UserConfig.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
public class UserConfig
|
||||
{
|
||||
public string UserName { get; }
|
||||
public string ServerId { get; }
|
||||
public string UserTags { get; }
|
||||
public string CustomData { get; }
|
||||
|
||||
private UserConfig(Builder builder)
|
||||
{
|
||||
UserName = builder.UserName;
|
||||
ServerId = builder.ServerId;
|
||||
UserTags = builder.UserTags;
|
||||
CustomData = builder.CustomData;
|
||||
}
|
||||
|
||||
public class Builder
|
||||
{
|
||||
public string UserName { get; private set; } = "anonymous";
|
||||
public string ServerId { get; private set; } = "-1";
|
||||
public string UserTags { get; private set; } = string.Empty;
|
||||
public string CustomData { get; private set; } = string.Empty;
|
||||
|
||||
public Builder SetUserName(string userName)
|
||||
{
|
||||
UserName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetServerId(string serverId)
|
||||
{
|
||||
ServerId = serverId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetUserTags(string userTags)
|
||||
{
|
||||
UserTags = userTags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder SetCustomData(string customDataJsonstring)
|
||||
{
|
||||
CustomData = customDataJsonstring;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserConfig Build()
|
||||
{
|
||||
return new UserConfig(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8a896a44c3dd450a881ddd9cc5ba37e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/Runtime/AIHelp/Core.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d75f665a144f143bebb1e0d2bd5d3266
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,233 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
|
||||
public class AIHelpAndroidCore : IAIHelpCore
|
||||
{
|
||||
|
||||
private AndroidJavaClass javaSupport;
|
||||
private AndroidJavaObject currentActivity;
|
||||
|
||||
public AIHelpAndroidCore()
|
||||
{
|
||||
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
javaSupport = new AndroidJavaClass("net.aihelp.init.AIHelpSupport");
|
||||
currentActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
}
|
||||
|
||||
public void Initialize(string domain, string appId, string language)
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
javaSupport.CallStatic("initialize", currentActivity, domain, appId, language);
|
||||
}
|
||||
}
|
||||
|
||||
private AndroidJavaObject getLoginConfig(LoginConfig config)
|
||||
{
|
||||
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.LoginConfig$Builder");
|
||||
builder.Call<AndroidJavaObject>("setUserId", config.UserId);
|
||||
builder.Call<AndroidJavaObject>("setUserConfig", getUserConfig(config.UserConfig));
|
||||
builder.Call<AndroidJavaObject>("setEnterpriseAuth", config.EnterpriseAuth);
|
||||
return builder.Call<AndroidJavaObject>("build");
|
||||
}
|
||||
|
||||
private AndroidJavaObject getApiConfig(ApiConfig config)
|
||||
{
|
||||
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.ApiConfig$Builder");
|
||||
return builder.Call<AndroidJavaObject>("build", config.EntranceId, config.WelcomeMessage);
|
||||
}
|
||||
|
||||
private AndroidJavaObject getUserConfig(UserConfig config)
|
||||
{
|
||||
if(config == null) return null;
|
||||
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.UserConfig$Builder");
|
||||
builder.Call<AndroidJavaObject>("setUserName", config.UserName);
|
||||
builder.Call<AndroidJavaObject>("setServerId", config.ServerId);
|
||||
builder.Call<AndroidJavaObject>("setUserTags", config.UserTags);
|
||||
builder.Call<AndroidJavaObject>("setCustomData", config.CustomData);
|
||||
return builder.Call<AndroidJavaObject>("build");
|
||||
}
|
||||
|
||||
private AndroidJavaObject getPublishCountryOrRegion(PublishCountryOrRegion countryOrRegion)
|
||||
{
|
||||
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.PublishCountryOrRegion");
|
||||
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)countryOrRegion);
|
||||
}
|
||||
|
||||
private AndroidJavaObject getPushPlatform(PushPlatform platform)
|
||||
{
|
||||
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.PushPlatform");
|
||||
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)platform);
|
||||
}
|
||||
|
||||
private AndroidJavaObject getShowConversationMoment(ConversationMoment conversationMoment)
|
||||
{
|
||||
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.ShowConversationMoment");
|
||||
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)conversationMoment);
|
||||
}
|
||||
|
||||
private AndroidJavaObject getEventType(EventType eventType)
|
||||
{
|
||||
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.event.EventType");
|
||||
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)eventType);
|
||||
}
|
||||
|
||||
public bool Show(string entranceId)
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
return javaSupport.CallStatic<bool>("show", entranceId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Show(ApiConfig apiConfig)
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
return javaSupport.CallStatic<bool>("show", getApiConfig(apiConfig));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ShowSingleFAQ(string faqId, ConversationMoment conversationMoment)
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
javaSupport.CallStatic("showSingleFAQ", faqId, getShowConversationMoment(conversationMoment));
|
||||
}
|
||||
}
|
||||
|
||||
public void Login(LoginConfig loginConfig)
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
javaSupport.CallStatic("login", getLoginConfig(loginConfig));
|
||||
}
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
if (javaSupport != null && currentActivity != null)
|
||||
{
|
||||
javaSupport.CallStatic("logout");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateUserInfo(UserConfig config)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("updateUserInfo", getUserConfig(config));
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetUserInfo()
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("resetUserInfo");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSDKLanguage(string language)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("updateSDKLanguage", language);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetUploadLogPath(string logPath)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("setUploadLogPath", logPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPushTokenAndPlatform(string logPath, PushPlatform pushPlatform)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("setPushTokenAndPlatform", logPath, getPushPlatform(pushPlatform));
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
|
||||
{
|
||||
javaSupport.CallStatic("registerAsyncEventListener", getEventType(eventType), listener == null ? null : new AsyncEventListenerProxy(listener));
|
||||
}
|
||||
|
||||
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
|
||||
{
|
||||
javaSupport.CallStatic("unregisterAsyncEventListener", getEventType(eventType));
|
||||
}
|
||||
|
||||
public void FetchUnreadMessageCount()
|
||||
{
|
||||
javaSupport.CallStatic("fetchUnreadMessageCount");
|
||||
}
|
||||
|
||||
public void FetchUnreadTaskCount()
|
||||
{
|
||||
javaSupport.CallStatic("fetchUnreadTaskCount");
|
||||
}
|
||||
|
||||
public void ShowUrl(string url)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("showUrl", url);
|
||||
}
|
||||
}
|
||||
|
||||
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("additionalSupportFor", getPublishCountryOrRegion(countryOrRegion));
|
||||
}
|
||||
}
|
||||
|
||||
public string GetSDKVersion()
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
return javaSupport.CallStatic<string>("getSDKVersion");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public bool IsAIHelpShowing()
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
return javaSupport.CallStatic<bool>("isAIHelpShowing");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void EnableLogging(bool isOpen)
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("enableLogging", isOpen);
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (javaSupport != null)
|
||||
{
|
||||
javaSupport.CallStatic("close");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5025625f2980b4854a698e38b5e1478f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
LocalPackages/aihelp-5.3/Runtime/AIHelp/Core/AIHelpCore.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
namespace AIHelp
|
||||
{
|
||||
public class AIHelpCore
|
||||
{
|
||||
private IAIHelpCore helpCore;
|
||||
private static AIHelpCore sInstance;
|
||||
|
||||
private AIHelpCore()
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
if (Application.platform == RuntimePlatform.Android) {
|
||||
helpCore = new AIHelpAndroidCore();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS
|
||||
if (Application.platform == RuntimePlatform.IPhonePlayer)
|
||||
{
|
||||
helpCore = new AIHelpiOSCore();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static AIHelpCore getInstance()
|
||||
{
|
||||
if (sInstance == null)
|
||||
{
|
||||
sInstance = new AIHelpCore();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void Initialize(string domain, string appId, string language)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.Initialize(domain, appId, language);
|
||||
}
|
||||
|
||||
public void Initialize(string domain, string appId)
|
||||
{
|
||||
Initialize(domain, appId, "");
|
||||
}
|
||||
|
||||
public bool Show(string entranceId)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return false;
|
||||
return helpCore.Show(entranceId);
|
||||
}
|
||||
|
||||
public bool Show(ApiConfig apiConfig)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return false;
|
||||
return helpCore.Show(apiConfig);
|
||||
}
|
||||
|
||||
public void ShowSingleFAQ(string faqId, ConversationMoment moment)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.ShowSingleFAQ(faqId, moment);
|
||||
}
|
||||
|
||||
public void Login(LoginConfig loginConfig)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.Login(loginConfig);
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.Logout();
|
||||
}
|
||||
|
||||
public void UpdateUserInfo(UserConfig userConfig)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.UpdateUserInfo(userConfig);
|
||||
}
|
||||
|
||||
public void ResetUserInfo()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.ResetUserInfo();
|
||||
}
|
||||
|
||||
public void UpdateSDKLanguage(string language)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.UpdateSDKLanguage(language);
|
||||
}
|
||||
|
||||
public void SetUploadLogPath(string path)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.SetUploadLogPath(path);
|
||||
}
|
||||
|
||||
public void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.SetPushTokenAndPlatform(pushToken, platform);
|
||||
}
|
||||
|
||||
public void FetchUnreadMessageCount()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.FetchUnreadMessageCount();
|
||||
}
|
||||
|
||||
public void FetchUnreadTaskCount()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.FetchUnreadTaskCount();
|
||||
}
|
||||
|
||||
public string GetSDKVersion()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return "";
|
||||
return helpCore.GetSDKVersion();
|
||||
}
|
||||
|
||||
public bool IsAIHelpShowing()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return false;
|
||||
return helpCore.IsAIHelpShowing();
|
||||
}
|
||||
|
||||
public void EnableLogging(bool enable)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.EnableLogging(enable);
|
||||
}
|
||||
|
||||
public void ShowUrl(string url)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.ShowUrl(url);
|
||||
}
|
||||
|
||||
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.AdditionalSupportFor(countryOrRegion);
|
||||
}
|
||||
|
||||
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.RegisterAsyncEventListener(eventType, listener);
|
||||
}
|
||||
|
||||
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.UnregisterAsyncEventListener(eventType);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.Close();
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
|
||||
public void SetRequestedOrientation(int requestedOrientation)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.SetRequestedOrientation(requestedOrientation);
|
||||
}
|
||||
|
||||
public void SetSDKAppearanceMode(int mode)
|
||||
{
|
||||
if (!IsHelpCorePrepared()) return;
|
||||
helpCore.SetSDKAppearanceMode(mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private bool IsHelpCorePrepared()
|
||||
{
|
||||
return helpCore != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f9ac1ead074e4a2586b265550d1fae8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
160
LocalPackages/aihelp-5.3/Runtime/AIHelp/Core/AIHelpiOSCore.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
// We need this one for importing our IOS functions
|
||||
using System.Runtime.InteropServices;
|
||||
using AOT;
|
||||
using System;
|
||||
namespace AIHelp
|
||||
{
|
||||
|
||||
#if UNITY_IOS
|
||||
public partial class AIHelpiOSCore : IAIHelpCore
|
||||
{
|
||||
|
||||
public void Initialize(string domain, string appId, string language = "")
|
||||
{
|
||||
unity_initiailize(domain, appId, language);
|
||||
}
|
||||
|
||||
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
|
||||
{
|
||||
eventListeners[eventType] = listener;
|
||||
unity_registerAsyncEventListener(eventType, OCAsyncEventListener);
|
||||
}
|
||||
|
||||
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
|
||||
{
|
||||
unity_unregisterAsyncEventListener(eventType);
|
||||
}
|
||||
|
||||
public bool Show(string entranceId)
|
||||
{
|
||||
return unity_show(entranceId, "");
|
||||
}
|
||||
|
||||
public bool Show(ApiConfig apiConfig)
|
||||
{
|
||||
return unity_show(apiConfig.EntranceId, apiConfig.WelcomeMessage);
|
||||
}
|
||||
|
||||
public void ShowSingleFAQ(string faqId, ConversationMoment moment)
|
||||
{
|
||||
unity_showSingleFAQ(faqId, (int)moment);
|
||||
}
|
||||
|
||||
public void Login(LoginConfig loginConfig) {
|
||||
var userConfig = loginConfig.UserConfig;
|
||||
if (userConfig == null) {
|
||||
userConfig = new UserConfig.Builder().Build();
|
||||
}
|
||||
unity_login(loginConfig.UserId, userConfig.UserName, userConfig.ServerId, userConfig.UserTags, userConfig.CustomData, loginConfig.EnterpriseAuth);
|
||||
}
|
||||
|
||||
public void Logout() {
|
||||
unity_logout();
|
||||
}
|
||||
|
||||
public void UpdateUserInfo(UserConfig userConfig)
|
||||
{
|
||||
unity_updateUserInfo(userConfig.UserName, userConfig.ServerId, userConfig.UserTags, userConfig.CustomData);
|
||||
}
|
||||
|
||||
public void ResetUserInfo()
|
||||
{
|
||||
unity_resetUserInfo();
|
||||
}
|
||||
|
||||
public void UpdateSDKLanguage(string language)
|
||||
{
|
||||
unity_updateSDKLanguage(language);
|
||||
}
|
||||
|
||||
public void SetUploadLogPath(string path)
|
||||
{
|
||||
unity_setUploadLogPath(path);
|
||||
}
|
||||
|
||||
public void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
|
||||
{
|
||||
unity_setPushTokenAndPlatform(pushToken, getPushPlatform(platform));
|
||||
}
|
||||
|
||||
public void FetchUnreadMessageCount()
|
||||
{
|
||||
unity_fetchUnreadMessageCount();
|
||||
}
|
||||
|
||||
public void FetchUnreadTaskCount()
|
||||
{
|
||||
unity_fetchUnreadTaskCount();
|
||||
}
|
||||
|
||||
public string GetSDKVersion()
|
||||
{
|
||||
return unity_getSDKVersion();
|
||||
}
|
||||
|
||||
public bool IsAIHelpShowing()
|
||||
{
|
||||
return unity_isAIHelpShowing();
|
||||
}
|
||||
|
||||
public void EnableLogging(bool enable)
|
||||
{
|
||||
unity_enableLogging(enable);
|
||||
}
|
||||
|
||||
public void ShowUrl(string url)
|
||||
{
|
||||
unity_showUrl(url);
|
||||
}
|
||||
|
||||
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
|
||||
{
|
||||
unity_additionalSupportFor(countryOrRegion);
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
unity_close();
|
||||
}
|
||||
|
||||
public void SetRequestedOrientation(int requestedOrientation)
|
||||
{
|
||||
unity_setSDKInterfaceOrientationMask(requestedOrientation);
|
||||
}
|
||||
|
||||
public void SetSDKAppearanceMode(int mode)
|
||||
{
|
||||
unity_setSDKInterfaceOrientationMask(mode);
|
||||
}
|
||||
|
||||
private int getPushPlatform(PushPlatform platform){
|
||||
int tempPlatform = 2;
|
||||
if (platform == PushPlatform.APNS)
|
||||
{
|
||||
tempPlatform = 1;
|
||||
}
|
||||
else if (platform == PushPlatform.FIREBASE)
|
||||
{
|
||||
tempPlatform = 2;
|
||||
}
|
||||
else if (platform == PushPlatform.JIGUANG)
|
||||
{
|
||||
tempPlatform = 3;
|
||||
}
|
||||
else if (platform == PushPlatform.GETUI)
|
||||
{
|
||||
tempPlatform = 4;
|
||||
}
|
||||
else if (platform == PushPlatform.HUAWEI)
|
||||
{
|
||||
tempPlatform = 6;
|
||||
}
|
||||
else if (platform == PushPlatform.ONE_SIGNAL)
|
||||
{
|
||||
tempPlatform = 7;
|
||||
}
|
||||
return tempPlatform;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2a510a461fd54d4881c024ad42035ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b10e874e5837b4579b62e9924a20f806
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
public class AsyncEventListenerProxy : AndroidJavaProxy
|
||||
{
|
||||
private readonly AIHelpDelegate.AsyncEventListener eventListener;
|
||||
private AndroidJavaObject ackRef;
|
||||
|
||||
public AsyncEventListenerProxy(AIHelpDelegate.AsyncEventListener eventListener) : base("net.aihelp.event.AsyncEventListener")
|
||||
{
|
||||
this.eventListener = eventListener;
|
||||
}
|
||||
|
||||
void onAsyncEventReceived(string jsonEventData, AndroidJavaObject ack)
|
||||
{
|
||||
ackRef = ack;
|
||||
var jniThread = System.Threading.Thread.CurrentThread;
|
||||
|
||||
Action<string> acknowledge = jsonAckData =>
|
||||
{
|
||||
bool isAttached = false;
|
||||
bool isAsync = System.Threading.Thread.CurrentThread != jniThread;
|
||||
try
|
||||
{
|
||||
// Attach the current thread to the JNI environment
|
||||
if (AndroidJNI.AttachCurrentThread() == (int)IntPtr.Zero)
|
||||
{
|
||||
isAttached = true;
|
||||
}
|
||||
if (ackRef != null)
|
||||
{
|
||||
ackRef.Call("acknowledge", jsonAckData);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Handle any exceptions that may occur during the JNI call
|
||||
Debug.LogError("Exception during JNI call: " + e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (isAsync && isAttached)
|
||||
{
|
||||
// Ensure we detach the current thread from the JNI environment if it was attached
|
||||
AndroidJNI.DetachCurrentThread();
|
||||
}
|
||||
}
|
||||
};
|
||||
eventListener(jsonEventData, acknowledge);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 212c0cec872fc40fca66b6827ac48f80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
LocalPackages/aihelp-5.3/Runtime/AIHelp/Core/IAIHelpCore.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
public interface IAIHelpCore
|
||||
{
|
||||
void Initialize(string domain, string appId, string language);
|
||||
|
||||
bool Show(string entranceId);
|
||||
bool Show(ApiConfig apiConfig);
|
||||
void ShowSingleFAQ(string faqId, ConversationMoment moment);
|
||||
|
||||
void Login(LoginConfig loginConfig);
|
||||
void Logout();
|
||||
void UpdateUserInfo(UserConfig userConfig);
|
||||
void ResetUserInfo();
|
||||
|
||||
void UpdateSDKLanguage(string language);
|
||||
void SetUploadLogPath(string path);
|
||||
void SetPushTokenAndPlatform(string pushToken, PushPlatform platform);
|
||||
|
||||
void FetchUnreadMessageCount();
|
||||
void FetchUnreadTaskCount();
|
||||
|
||||
string GetSDKVersion();
|
||||
bool IsAIHelpShowing();
|
||||
void EnableLogging(bool enable);
|
||||
void ShowUrl(string url);
|
||||
void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion);
|
||||
|
||||
void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener);
|
||||
void UnregisterAsyncEventListener(AIHelp.EventType eventType);
|
||||
|
||||
void Close();
|
||||
|
||||
#if UNITY_IOS
|
||||
void SetRequestedOrientation(int requestedOrientation); // ios only
|
||||
void SetSDKAppearanceMode(int mode); // iOS only 0: follow the system 1: light mode 2: dark mode
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b63a845cae20749c1be5d13f2ccd2ede
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/Runtime/AIHelp/Core/iOS.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54ad73766cfa345e6a6859b9ade52598
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using AOT;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
#if UNITY_IOS
|
||||
public partial class AIHelpiOSCore
|
||||
{
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_initiailize(string domainName, string appId, string language);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_registerAsyncEventListener(AIHelp.EventType eventType, AIHelpAsyncEventListener listener);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_unregisterAsyncEventListener(AIHelp.EventType eventType);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_login(string userId, string userName, string serverId, string userTags, string customData, bool isEnterpriseAuth);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_logout();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_updateUserInfo(string userName, string serverId, string userTags, string customData);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_resetUserInfo();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_updateSDKLanguage(string language);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_setUploadLogPath(string path);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_setPushTokenAndPlatform(string pushToken, int pushPlatform);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string unity_getSDKVersion();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool unity_isAIHelpShowing();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_enableLogging(bool enable);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_close();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool unity_show(string entranceId, string welcomeMessage);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_showSingleFAQ(string faqId, int conversationMoment);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_fetchUnreadMessageCount();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_fetchUnreadTaskCount();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_showUrl(string url);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_additionalSupportFor(PublishCountryOrRegion countryOrRegion);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_setSDKAppearanceMode(int mode);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unity_setSDKInterfaceOrientationMask(int interfaceOrientationMask);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35414e6ccf0a84d9bb2566d2180a0a6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using AOT;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AIHelp
|
||||
{
|
||||
#if UNITY_IOS
|
||||
public partial class AIHelpiOSCore
|
||||
{
|
||||
private static Dictionary<AIHelp.EventType, AIHelpDelegate.AsyncEventListener> eventListeners =
|
||||
new Dictionary<AIHelp.EventType, AIHelpDelegate.AsyncEventListener>();
|
||||
|
||||
// 在 cs 注册的回调方法
|
||||
static event AIHelpDelegate.AsyncEventListener csAsyncEventListener;
|
||||
|
||||
// oc 传过来的 ack 回调,缓存下来异步使用
|
||||
public static Acknowledgement AckDelegate { get; set; }
|
||||
|
||||
// 声明一个符合 ack 回调的代理,用来持有 ack 回调指针的时候使用
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void Acknowledgement(string ackJsonData);
|
||||
|
||||
// OC 回调方法签名 - event, ack
|
||||
public delegate void AIHelpAsyncEventListener(string jsonEventData, IntPtr acknowledgePtr);
|
||||
|
||||
[MonoPInvokeCallback(typeof(AIHelpAsyncEventListener))]
|
||||
private static void OCAsyncEventListener(string jsonEventData, IntPtr acknowledgePtr)
|
||||
{
|
||||
var intEventType = SimpleJsonParser.ExtractEventTypeFromJson(jsonEventData);
|
||||
if (intEventType != -1) {
|
||||
AIHelp.EventType eventType = (AIHelp.EventType)SimpleJsonParser.ExtractEventTypeFromJson(jsonEventData);
|
||||
if (eventListeners.TryGetValue(eventType, out var listener))
|
||||
{
|
||||
Action<string> acknowledge = jsonAckData => {
|
||||
if (acknowledgePtr != IntPtr.Zero) {
|
||||
AckDelegate = Marshal.GetDelegateForFunctionPointer<Acknowledgement>(acknowledgePtr);
|
||||
AckDelegate?.Invoke(jsonAckData);
|
||||
}
|
||||
};
|
||||
listener?.Invoke(jsonEventData, acknowledge);
|
||||
} else {
|
||||
Debug.LogError($"[AIHelp] Unable to find any listener for event type: {eventType}. Have you declared it?");
|
||||
}
|
||||
} else {
|
||||
Debug.LogError($"[AIHelp] Unable to retrieve eventType from eventData: {jsonEventData}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07b537e2737b74ea38fb190ca953a218
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
|
||||
public static class SimpleJsonParser
|
||||
{
|
||||
public static int ExtractEventTypeFromJson(string json)
|
||||
{
|
||||
string fieldValue = ExtractFieldFromJson(json, "eventType");
|
||||
if (string.IsNullOrEmpty(fieldValue))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return int.Parse(fieldValue);
|
||||
}
|
||||
|
||||
public static string ExtractFieldFromJson(string json, string fieldName)
|
||||
{
|
||||
string target = $"\"{fieldName}\":";
|
||||
int startIndex = json.IndexOf(target, StringComparison.OrdinalIgnoreCase);
|
||||
if (startIndex >= 0)
|
||||
{
|
||||
startIndex += target.Length;
|
||||
// Skip whitespace
|
||||
while (char.IsWhiteSpace(json[startIndex])) startIndex++;
|
||||
|
||||
// Determine if the value is a string or number
|
||||
if (json[startIndex] == '"') // string value
|
||||
{
|
||||
startIndex++;
|
||||
int endIndex = json.IndexOf('"', startIndex);
|
||||
if (endIndex > startIndex)
|
||||
{
|
||||
return json.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
}
|
||||
else // numeric value
|
||||
{
|
||||
int endIndex = json.IndexOfAny(new[] { ',', '}', ' ' }, startIndex);
|
||||
if (endIndex > startIndex)
|
||||
{
|
||||
return json.Substring(startIndex, endIndex - startIndex).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb9be6b068ec448f48556f9a85df870c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
LocalPackages/aihelp-5.3/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "aihelp",
|
||||
"version": "5.3.0",
|
||||
"displayName": "aihelp",
|
||||
"unity": "2020.3",
|
||||
"unityRelease": "4f1",
|
||||
"author": {
|
||||
"name": "Skistua",
|
||||
"email": "b166er.dada@gmail.com"
|
||||
}
|
||||
}
|
||||
7
LocalPackages/aihelp-5.3/package.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca500307ab3dc4c32bebffb11f90a131
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/plugins.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a21d91b771a3042e79bffb7428b2d783
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/plugins/iOS.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c641f8cade6dd40879791f67af904f43
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
LocalPackages/aihelp-5.3/plugins/iOS/AIHelpSDK.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28f954260a8a24e4bb26b78941da81db
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34c46cf5a81094a739a70168c76b0daa
|
||||
folderAsset: yes
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d7b3d6dfeed44cdcbbbcaf6f723c3cd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 457 B |
|
After Width: | Height: | Size: 729 B |
|
After Width: | Height: | Size: 641 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 821 B |
|
After Width: | Height: | Size: 344 B |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 577 B |
|
After Width: | Height: | Size: 194 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 320 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 155 B |
|
After Width: | Height: | Size: 934 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 814 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 953 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 499 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 723 B |
|
After Width: | Height: | Size: 777 B |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1013 B |
|
After Width: | Height: | Size: 969 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 950 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 42 KiB |