UMiniGame/Assets/Games/Scripts/GameManager.cs
2025-12-27 15:29:20 +08:00

50 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DG.Tweening;
using MessagePack;
using MessagePack.Resolvers;
using MessagePack.Unity;
using UnityEngine;
using UnityEngine.InputSystem.EnhancedTouch;
public class GameManager : MonoBehaviour
{
//MessagePack.Unity automatically adds UnityResolver to the default options Resolver when the application starts with code like this in the unity package to enable this serialization:
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Init()
{
StaticCompositeResolver.Instance.Register(
UnityResolver.Instance,
MessagePack.Unity.Extension.UnityBlitWithPrimitiveArrayResolver.Instance,
StandardResolver.Instance
);
var options = MessagePackSerializerOptions.Standard.WithResolver(StaticCompositeResolver.Instance);
MessagePackSerializer.DefaultOptions = options;
}
private void Awake()
{
// 必须在Awake/Start中尽早启用EnhancedTouch且只启用一次
if (!EnhancedTouchSupport.enabled)
{
EnhancedTouchSupport.Enable();
}
// 第一个参数最大同时运行的Tween数量根据你的需求调整比如1000
// 第二个参数最大Tween池容量通常设为第一个参数的1/4或1/5即可
DOTween.SetTweensCapacity(1000, 200);
// 可选:开启回收池以优化性能(默认开启,可显式设置)
DOTween.defaultRecyclable = true;
}
// Start is called before the first frame update
void Start()
{
}
//// Update is called once per frame
//void Update()
//{
//}
}