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

@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using BITKit;
using UnityEngine.Events;
@@ -19,7 +20,8 @@ namespace BITKit
private static VFXService sinleton;
public VFX[] vfxs;
private readonly Dictionary<string, UnityPool<Transform>> pools = new();
[SerializeField] private bool debug;
[SerializeField] private Optional<int> defaultCapacity;
private void Awake()
{
@@ -37,8 +39,11 @@ namespace BITKit
}
public Transform Spawn(Location location, params string[] keyWords)
{
StringBuilder reportBuilder = debug ? new() : null;
reportBuilder?.AppendLine(JsonHelper.Get(keyWords));
if (TryMatch(out var prefab, keyWords))
{
var pool = pools.Get(prefab.name);
if (defaultCapacity.Allow)
pool.DefaultCapacity = defaultCapacity.Value;
@@ -46,6 +51,12 @@ namespace BITKit
instance.SetPositionAndRotation(location, location);
if (location.forward.sqrMagnitude is not 0)
instance.forward = location.forward;
reportBuilder?.AppendLine($"生成:{prefab.name}");
if(reportBuilder is not null)
BIT4Log.Log<VFXService>(reportBuilder.ToString());
return instance;
}
else