1
This commit is contained in:
@@ -7,7 +7,10 @@ using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using BITKit.UX;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
@@ -107,7 +110,7 @@ namespace BITKit
|
||||
}
|
||||
public static void ThrowIfWindowNotFocus()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_EDITOR && ENABLE_INPUT_SYSTEM
|
||||
switch (Camera.main)
|
||||
{
|
||||
case {} camera:
|
||||
@@ -132,10 +135,8 @@ namespace BITKit
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Reload()
|
||||
{
|
||||
|
||||
IsPlaying = true;
|
||||
BIT4Log.OnLog += Debug.Log;
|
||||
BIT4Log.OnWarning += Debug.LogWarning;
|
||||
BIT4Log.OnException += Debug.LogException;
|
||||
//启动BITApp
|
||||
BITApp.SynchronizationContext = SynchronizationContext.Current;
|
||||
BITApp.Start(Application.productName, new BITApp.AppSettings()).Forget();
|
||||
@@ -148,34 +149,42 @@ namespace BITKit
|
||||
DontDestroyOnLoad(GameObject);
|
||||
AllowCursor.AddListener(ToggleCursor);
|
||||
AllowTouchSupport.AddListener(ToggleTouchSupport);
|
||||
|
||||
}
|
||||
static void ToggleCursor(bool active)
|
||||
private static void ToggleCursor(bool active)
|
||||
{
|
||||
Cursor.lockState = active ? CursorLockMode.None : CursorLockMode.Locked;
|
||||
Cursor.visible = active;
|
||||
}
|
||||
static void ToggleTouchSupport(bool active)
|
||||
private static void ToggleTouchSupport(bool active)
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (active)
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Disable();
|
||||
}
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.InputSystem.EnhancedTouch.EnhancedTouchSupport.Disable();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
[BITCommand]
|
||||
public static async void Exit()
|
||||
{
|
||||
await BITApp.SwitchToMainThread();
|
||||
BITApp.Stop();
|
||||
Data.Clear();
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
[SerializeField, ReadOnly] private bool allowCursor;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
BIT4Log.Log<BITApp>($"已创建{nameof(BITApp)}");
|
||||
@@ -193,6 +202,7 @@ namespace BITKit
|
||||
BITApp.Time.ElapsedTime = Time.time;
|
||||
BITApp.Time.DeltaTime = Time.deltaTime;
|
||||
BITApp.Time.TimeAsDouble = Time.timeAsDouble;
|
||||
allowCursor = AllowCursor.Allow;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
|
Reference in New Issue
Block a user