public class PlatformMethod : MonoBehaviour
{
#region 工具端
#if !UNITY_ANDROID
///
/// Unity测试专用
///
///
[DllImport("__Internal")]
private static extern void _unityPrint(string msg);
///
/// 初始化
///
[DllImport("__Internal")]
private static extern void _initDone();
///
/// 添加打点
///
/// 打点的json
[DllImport("__Internal")]
private static extern void _addTakePointEffect(string json);
///
/// 移动打点
///
/// 打点的json
[DllImport("__Internal")]
private static extern void _moveTakePointEffect(string json);
///
/// 点击打点
///
/// 打点的json
[DllImport("__Internal")]
private static extern void _clickTakePointEffect(string json);
///
/// 点击打点交互
///
/// 打点的json
[DllImport("__Internal")]
private static extern void _clickTakePointInteraction(string json);
///
/// 添加连线
///
/// 连线的json
[DllImport("__Internal")]
private static extern void _addLigatureEffect(string json);
///
/// 移动打点
///
/// 打点的json
[DllImport("__Internal")]
private static extern void _moveLigatureEffect(string json);
///
/// 点击连线
///
/// 连线的json
[DllImport("__Internal")]
private static extern void _clickLigatureEffect(string json);
///
/// 点击空白处
///
[DllImport("__Internal")]
private static extern void _clickBlank();
///
/// 操作成功
///
/// 平台id
[DllImport("__Internal")]
private static extern void _completeSomeOperation(string platformId);
///
/// 操作失败
///
/// 平台id
///
[DllImport("__Internal")]
private static extern void _faildSomeOpreation(string platformId, int code);
///
/// 回调下载模型
///
///
[DllImport("__Internal")]
private static extern void _downloadModel(string path);
///
/// 回调摄像机位置
///
///
[DllImport("__Internal")]
private static extern void _cameraPositionCb(string json);
///
/// 回调下载进度
///
///
[DllImport("__Internal")]
private static extern void _modelOnProgress(string progress);
///
/// 回调截图base64
///
[DllImport("__Internal")]
private static extern void _captureScreenCb(string texBytes);
///
/// 返回工具端
///
[DllImport("__Internal")]
private static extern void _returnTool();
///
/// 回调截图base64
///
///
public static void Web_CaptureScreenCb(string texBytes)
{
if (Application.platform == RuntimePlatform.WebGLPlayer && Application.platform != RuntimePlatform.WindowsEditor)
{
_captureScreenCb(texBytes);
}
}
///
/// Unity测试
///
/// 测试信息
public static void UnityPrint(string msg)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_unityPrint(msg);
}
///
/// 初始化
///
public static void InitDone()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_initDone();
#if UNITY_WEBGL
WebGLInput.captureAllKeyboardInput = false;
#endif
}
///
/// 添加打点
///
/// 打点的json
public static void AddTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_addTakePointEffect(json);
}
///
/// 移动打点
///
/// 打点的json
public static void MoveTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_moveTakePointEffect(json);
}
///
/// 点击打点
///
/// 打点的json
public static void ClickTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_clickTakePointEffect(json);
}
public static void ClickTakePointInteraction(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_clickTakePointInteraction(json);
}
///
/// 添加连线
///
/// 连线的json
public static void AddLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_addLigatureEffect(json);
}
///
/// 移动打点
///
/// 打点的json
public static void MoveLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_moveLigatureEffect(json);
}
///
/// 点击连线
///
/// 连线的json
public static void ClickLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_clickLigatureEffect(json);
}
///
/// 点击空白处
///
public static void ClickBlank()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_clickBlank();
}
///
/// 操作失败
///
/// 平台id
///
public static void FailedSomeOperation(string platformId, int code)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_faildSomeOpreation(platformId, code);
}
///
/// 回调下载模型
///
///
public static void DownloadComplete(string path)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_downloadModel(path);
}
///
/// 回调摄像机位置
///
///
public static void CameraPositionCb(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_cameraPositionCb(json);
}
///
/// 回调下载进度
///
/// 进度
public static void Web_DownloadProgress(string progress)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_modelOnProgress(progress);
}
public static void ReturnTool()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_returnTool();
}
#elif UNITY_ANDROID
static AndroidJavaClass jc = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
static AndroidJavaObject jo = jc.GetStatic ("currentActivity");
///
/// Unity测试
///
/// 测试信息
public static void UnityPrint(string msg)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_unityPrint",msg);
}
///
/// 初始化
///
public static void InitDone()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_initDone");
}
///
/// 添加打点
///
/// 打点的json
public static void AddTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_addTakePointEffect",json);
}
///
/// 移动打点
///
/// 打点的json
public static void MoveTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_moveTakePointEffect",json);
}
///
/// 点击打点
///
/// 打点的json
public static void ClickTakePointEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_clickTakePointEffect",json);
}
///
/// 点击打点交互
///
/// 打点的json
public static void ClickTakePointInteraction(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_clickTakePointInteraction",json);
}
///
/// 添加连线
///
/// 连线的json
public static void AddLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_addLigatureEffect",json);
}
///
/// 移动打点
///
/// 打点的json
public static void MoveLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_moveLigatureEffect",json);
}
///
/// 点击连线
///
/// 连线的json
public static void ClickLigatureEffect(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_clickLigatureEffect",json);
}
///
/// 点击空白处
///
public static void ClickBlank()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_clickBlank");
}
///
/// 操作失败
///
/// 平台id
///
public static void FailedSomeOperation(string platformId, int code)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_faildSomeOpreation",platformId,code);
}
///
/// 回调下载模型
///
///
public static void DownloadComplete(string path)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_downloadModel",path);
}
///
/// 回调摄像机位置
///
///
public static void CameraPositionCb(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_cameraPositionCb",json);
}
///
/// 回调下载进度
///
/// 进度
public static void Web_DownloadProgress(string progress)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_modelOnProgress",progress);
}
public static void ReturnTool()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_returnTool");
}
#endif
#endregion
#region 世界文化遗产
#if UNITY_ANDROID
public static void ShareTool(int imageTag){
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_shareOperation",imageTag);
}
public static void PrepareToReturn(){
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_prepareToReturn");
}
public static void OpenNavigation(string json){
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
jo.Call ("_mapNavigation",json);
}
#elif UNITY_WEBGL
///
/// 关闭web二维码界面
///
[DllImport("__Internal")]
private static extern void _CloseShareModel();
///
/// web分享
///
[DllImport("__Internal")]
private static extern void _shareOperationWeb(string json); //"name": "'BeJson'"
///
/// 经纬度回调ios 导航功能
///
[DllImport("__Internal")]
private static extern void _mapNavigation(string json);
///
///导航
///
public static void OpenNavigation(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_mapNavigation(json);
}
///
/// 关闭web分享界面
///
public static void CloseWEBShare()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_CloseShareModel();
}
///
/// web分享
///
///
public static void ShareOperationWeb(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_shareOperationWeb(json);
}
///
///回调ios退出
///
public static void PrepareToReturn()
{
}
#elif UNITY_IOS
///
/// 文化遗产分享功能ios
///
[DllImport("__Internal")]
private static extern void _shareOperation(string imageTag);
///
/// ios 退出
///
[DllImport("__Internal")]
private static extern void _prepareToReturn();/// 即将返回工具 void _prepareToReturn(void);
///
/// ios 复制
///
[DllImport("__Internal")]
private static extern void _IOSCopy();/// ios复制
///
/// 经纬度回调ios 导航功能
///
[DllImport("__Internal")]
private static extern void _mapNavigation(string json);
///
///导航
///
public static void OpenNavigation(string json)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_mapNavigation(json);
}
///
///文化遗产 分享功能 移动端使用
///
public static void ShareTool(string imageTag)
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_shareOperation(imageTag);
}
///
///回调ios退出
///
public static void PrepareToReturn()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_prepareToReturn();
}
///
///回调ios复制功能
///
public static void CopyFunction()
{
if (Application.platform == RuntimePlatform.WindowsEditor ||
Application.platform == RuntimePlatform.OSXEditor) return;
_IOSCopy();
}
#endif
#endregion
}