This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -5,11 +5,46 @@ using System.Diagnostics;
using UnityEngine;
using Cysharp.Threading.Tasks;
using System.Threading.Tasks;
using BITKit.UX;
using Cinemachine.Utility;
using UnityEngine.InputSystem;
using Debug = UnityEngine.Debug;
#if !UNITY_EDITOR
using UnityEngine;
using UnityEngine.Rendering;
public class SkipSplash
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
private static void BeforeSplashScreen()
{
#if UNITY_WEBGL
Application.focusChanged += Application_focusChanged;
#else
System.Threading.Tasks.Task.Run(AsyncSkip);
#endif
}
#if UNITY_WEBGL
private static void Application_focusChanged(bool obj)
{
Application.focusChanged -= Application_focusChanged;
SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
}
#else
private static void AsyncSkip()
{
SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
}
#endif
}
#endif
namespace BITKit
{
public class MouseNotOverGameViewException : System.Exception
{
public MouseNotOverGameViewException()
@@ -22,10 +57,11 @@ namespace BITKit
[Serializable]
public class OpenUrl:IAction
{
[SerializeField] private string url;
public void Execute()
[SerializeField] public string url;
[SerializeReference,SubclassSelector] public IReference urlReference;
public virtual void Execute()
{
Application.OpenURL(url);
Application.OpenURL(urlReference is not null?urlReference.Value:url);
}
}
@@ -43,6 +79,17 @@ namespace BITKit
}
public static bool IsPlaying { get;private set; }
public static bool IsPointerOverUI { get; set; }
public static bool IsEditor
{
get
{
#if UNITY_EDITOR
return true;
#endif
return false;
}
}
public static ValidHandle AllowCursor = new();
public static ValidHandle AllowTouchSupport = new();
public static GameObject GameObject;
@@ -59,6 +106,16 @@ namespace BITKit
public static void ThrowIfWindowNotFocus()
{
#if UNITY_EDITOR
switch (Camera.main)
{
case {} camera:
if (camera.pixelRect.Contains(Input.mousePosition) is false)
{
throw new MouseNotOverGameViewException();
}
break;
}
var window = UnityEditor.EditorWindow.focusedWindow;
var windowName = window is not null ? window.ToString() : string.Empty;
switch (windowName)
@@ -106,8 +163,9 @@ namespace BITKit
}
}
[BITCommand]
public static void Exit()
public static async void Exit()
{
await BITApp.SwitchToMainThread();
BITApp.Stop();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;