PC-20230316NUNE\Administrator 1953e7c25f 提交
2024-10-23 15:30:22 +08:00

71 lines
1.8 KiB
C#

using System;
using DefaultNamespace;
using GAS.Runtime;
using JNGame.Runtime;
using UnityEngine;
namespace GASSamples.Scripts
{
public class Main : MonoBehaviour
{
public GameObject World;
public GameObject Box;
public AbilitySystemComponentPreset Preset;
public GameplayEffectAsset GE_JisolDemo1;
public TextAsset AbilityAsset;
public TextAsset GEAsset;
public TextAsset ASCAsset;
private JNGASFrameSystem _frameSystem;
private int _totalTime;
private int _frameIndex;
private async void Awake()
{
await JNetGame.Instance.Init(App.AllSystem());
App.Resource.World = World;
App.Resource.Box = Box;
App.Resource.Preset = Preset;
App.Resource.GE_JisolDemo1 = GE_JisolDemo1;
App.Resource.Ability = AbilityAsset.bytes;
App.Resource.GE = GEAsset.bytes;
App.Resource.ASC = ASCAsset.bytes;
_frameSystem = new JNGASFrameSystem();
_frameSystem.Initialize();
_frameSystem.TStartExecute();
}
private void Update()
{
if (_frameSystem is null) return;
_totalTime += (int)(Time.deltaTime * 1000);
//自动推帧
if (_totalTime >= _frameSystem.NSyncTime)
{
_totalTime -= _frameSystem.NSyncTime;
_frameSystem.AddFrame(new JNFrameInfo()
{
Index = _frameIndex++
});
}
}
private void OnApplicationQuit()
{
_frameSystem?.Dispose();
}
protected void OnDisable()
{
_frameSystem?.Dispose();
}
}
}