1
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Pool;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
@@ -17,16 +19,29 @@ namespace BITKit
|
||||
private static VFXService sinleton;
|
||||
public VFX[] vfxs;
|
||||
private readonly Dictionary<string, UnityPool<Transform>> pools = new();
|
||||
|
||||
[SerializeField] private Optional<int> defaultCapacity;
|
||||
private void Awake()
|
||||
{
|
||||
sinleton = this;
|
||||
DI.Register(this);
|
||||
}
|
||||
public Transform Spawn(RaycastHit hit, params string[] keyWords)
|
||||
{
|
||||
return Spawn(new Location()
|
||||
{
|
||||
position = hit.point,
|
||||
rotation = Quaternion.LookRotation(hit.normal),
|
||||
forward = hit.normal,
|
||||
}, keyWords);
|
||||
}
|
||||
public Transform Spawn(Location location, params string[] keyWords)
|
||||
{
|
||||
if (TryMatch(out var prefab, keyWords))
|
||||
{
|
||||
var pool = pools.Get(prefab.name);
|
||||
if (defaultCapacity.Allow)
|
||||
pool.DefaultCapacity = defaultCapacity.Value;
|
||||
var instance = pool.Get(prefab, transform);
|
||||
instance.SetPositionAndRotation(location, location);
|
||||
if (location.forward.sqrMagnitude is not 0)
|
||||
|
Reference in New Issue
Block a user