1
0
Fork 0
LaboratoryProtection/Assets/Plugins/WebGLSupport/WebGLFullscreen/WebGLFullscreen.cs

59 lines
1.4 KiB
C#

#if UNITY_WEBGL && !UNITY_EDITOR
using System.Runtime.InteropServices; // for DllImport
#endif
using UnityEngine;
namespace WebGLSupport
{
static class WebGLFullscreenPlugin
{
#if UNITY_WEBGL && !UNITY_EDITOR
[DllImport("__Internal")]
public static extern void WebGLFullscreenInject();
[DllImport("__Internal")]
public static extern void WebGLSetFullscreen();
[DllImport("__Internal")]
public static extern void WebGLSetFullscreen2019();
#else
public static void WebGLFullscreenInject() { }
public static void WebGLSetFullscreen() { }
public static void WebGLSetFullscreen2019() { }
#endif
}
public static class WebGLFullscreen
{
static void Init()
{
WebGLFullscreenPlugin.WebGLFullscreenInject();
}
[RuntimeInitializeOnLoadMethod]
static void RuntimeInitializeOnLoadMethod()
{
Init();
}
public static void SetFullscreen()
{
#if UNITY_2020_3_OR_NEWER
WebGLFullscreenPlugin.WebGLSetFullscreen();
#else
WebGLFullscreenPlugin.WebGLSetFullscreen2019();
#endif
}
public static void SetFullscreenOld()
{
#pragma warning disable CS0618 // 类型或成员已过时
Application.ExternalCall("SetFullscreenOld");
#pragma warning restore CS0618 // 类型或成员已过时
}
}
}