50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
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()
|
||
//{
|
||
|
||
//}
|
||
}
|