mirror of
https://github.com/ConjureETS/Unity_Utils.git
synced 2026-03-24 04:50:58 +00:00
Added meta files and remove bad namespaces
Will add better namespaces later
This commit is contained in:
parent
ddd8e232a7
commit
49d2952bf8
8
Attributes.meta
Normal file
8
Attributes.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 618d1e8b8a58df14e81833e4c4623513
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
11
Attributes/MinMaxRangeAttribute.cs.meta
Normal file
11
Attributes/MinMaxRangeAttribute.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4996055a108bf1a40825fd570adfb82f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
CustomTypes.meta
Normal file
8
CustomTypes.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 96bace79d06c3784ca7aad8ca4779faa
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,11 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Util.CustomTypes
|
[Serializable]
|
||||||
|
public struct RangedFloat
|
||||||
{
|
{
|
||||||
[Serializable]
|
public float minValue;
|
||||||
public struct RangedFloat
|
public float maxValue;
|
||||||
{
|
|
||||||
public float minValue;
|
|
||||||
public float maxValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
11
CustomTypes/RangedFloat.cs.meta
Normal file
11
CustomTypes/RangedFloat.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c4aefb8a410bcae4a88de6f72ae1c873
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Editor.meta
Normal file
8
Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1d1f2b5d5f1ea2d4ba6ac94a6adedf10
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Editor/CustomInspectors.meta
Normal file
8
Editor/CustomInspectors.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bcaa3a57881b3d14fa27f5f5a72f5277
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,38 +1,34 @@
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Util.ScriptableObjects.Audio;
|
|
||||||
|
|
||||||
namespace Editor.customInspector
|
[CustomEditor(typeof(AudioEvent), true)]
|
||||||
|
public class AudioEventInspector : Editor
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(AudioEvent), true)]
|
[SerializeField] private AudioSource audioSource;
|
||||||
public class AudioEventInspector : UnityEditor.Editor
|
|
||||||
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
[SerializeField] private AudioSource audioSource;
|
audioSource =
|
||||||
|
EditorUtility.CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave,
|
||||||
|
typeof(AudioSource)).GetComponent<AudioSource>();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
DestroyImmediate(audioSource.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
DrawDefaultInspector();
|
||||||
|
|
||||||
|
EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
|
||||||
|
if (GUILayout.Button("Preview"))
|
||||||
{
|
{
|
||||||
audioSource =
|
((AudioEvent) target).Play(audioSource);
|
||||||
EditorUtility.CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave,
|
|
||||||
typeof(AudioSource)).GetComponent<AudioSource>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
EditorGUI.EndDisabledGroup();
|
||||||
{
|
|
||||||
DestroyImmediate(audioSource.gameObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void OnInspectorGUI()
|
|
||||||
{
|
|
||||||
DrawDefaultInspector();
|
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
|
|
||||||
if (GUILayout.Button("Preview"))
|
|
||||||
{
|
|
||||||
((AudioEvent) target).Play(audioSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.EndDisabledGroup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
Editor/CustomInspectors/AudioEventInspector.cs.meta
Normal file
11
Editor/CustomInspectors/AudioEventInspector.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bc328582b298304f957056327d58af5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Editor/PropertyDrawers.meta
Normal file
8
Editor/PropertyDrawers.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 80c222b09cde6a24aa82c866ad1e378a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,54 +1,50 @@
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Util.CustomTypes;
|
|
||||||
|
|
||||||
namespace Editor.PropertyDrawer
|
[CustomPropertyDrawer(typeof(RangedFloat), true)]
|
||||||
|
public class RangedFloatDrawer : PropertyDrawer
|
||||||
{
|
{
|
||||||
[CustomPropertyDrawer(typeof(RangedFloat), true)]
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||||
public class RangedFloatDrawer : UnityEditor.PropertyDrawer
|
|
||||||
{
|
{
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
label = EditorGUI.BeginProperty(position, label, property);
|
||||||
|
position = EditorGUI.PrefixLabel(position, label);
|
||||||
|
|
||||||
|
var minProp = property.FindPropertyRelative("minValue");
|
||||||
|
var maxProp = property.FindPropertyRelative("maxValue");
|
||||||
|
|
||||||
|
var minValue = minProp.floatValue;
|
||||||
|
var maxValue = maxProp.floatValue;
|
||||||
|
|
||||||
|
float rangeMin = 0;
|
||||||
|
float rangeMax = 1;
|
||||||
|
|
||||||
|
var ranges = (MinMaxRangeAttribute[]) fieldInfo.GetCustomAttributes(typeof(MinMaxRangeAttribute), true);
|
||||||
|
|
||||||
|
if (ranges.Length > 0)
|
||||||
{
|
{
|
||||||
label = EditorGUI.BeginProperty(position, label, property);
|
rangeMin = ranges[0].Min;
|
||||||
position = EditorGUI.PrefixLabel(position, label);
|
rangeMax = ranges[0].Max;
|
||||||
|
|
||||||
var minProp = property.FindPropertyRelative("minValue");
|
|
||||||
var maxProp = property.FindPropertyRelative("maxValue");
|
|
||||||
|
|
||||||
var minValue = minProp.floatValue;
|
|
||||||
var maxValue = maxProp.floatValue;
|
|
||||||
|
|
||||||
float rangeMin = 0;
|
|
||||||
float rangeMax = 1;
|
|
||||||
|
|
||||||
var ranges = (MinMaxRangeAttribute[]) fieldInfo.GetCustomAttributes(typeof(MinMaxRangeAttribute), true);
|
|
||||||
|
|
||||||
if (ranges.Length > 0)
|
|
||||||
{
|
|
||||||
rangeMin = ranges[0].Min;
|
|
||||||
rangeMax = ranges[0].Max;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float rangeBoundsLabelWidth = 40f;
|
|
||||||
|
|
||||||
var rangeBoundsLabel1Rect = new Rect(position) {width = rangeBoundsLabelWidth};
|
|
||||||
GUI.Label(rangeBoundsLabel1Rect, new GUIContent(minValue.ToString("F2")));
|
|
||||||
position.xMin += rangeBoundsLabelWidth;
|
|
||||||
|
|
||||||
var rangeBoundsLabel2Rect = new Rect(position);
|
|
||||||
rangeBoundsLabel2Rect.xMin = rangeBoundsLabel2Rect.xMax - rangeBoundsLabelWidth + 5;
|
|
||||||
GUI.Label(rangeBoundsLabel2Rect, new GUIContent(maxValue.ToString("F2")));
|
|
||||||
position.xMax -= rangeBoundsLabelWidth;
|
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
|
||||||
EditorGUI.MinMaxSlider(position, ref minValue, ref maxValue, rangeMin, rangeMax);
|
|
||||||
if (EditorGUI.EndChangeCheck())
|
|
||||||
{
|
|
||||||
minProp.floatValue = minValue;
|
|
||||||
maxProp.floatValue = maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.EndProperty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float rangeBoundsLabelWidth = 40f;
|
||||||
|
|
||||||
|
var rangeBoundsLabel1Rect = new Rect(position) {width = rangeBoundsLabelWidth};
|
||||||
|
GUI.Label(rangeBoundsLabel1Rect, new GUIContent(minValue.ToString("F2")));
|
||||||
|
position.xMin += rangeBoundsLabelWidth;
|
||||||
|
|
||||||
|
var rangeBoundsLabel2Rect = new Rect(position);
|
||||||
|
rangeBoundsLabel2Rect.xMin = rangeBoundsLabel2Rect.xMax - rangeBoundsLabelWidth + 5;
|
||||||
|
GUI.Label(rangeBoundsLabel2Rect, new GUIContent(maxValue.ToString("F2")));
|
||||||
|
position.xMax -= rangeBoundsLabelWidth;
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
EditorGUI.MinMaxSlider(position, ref minValue, ref maxValue, rangeMin, rangeMax);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
minProp.floatValue = minValue;
|
||||||
|
maxProp.floatValue = maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.EndProperty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
Editor/PropertyDrawers/RangedFloatDrawer.cs.meta
Normal file
11
Editor/PropertyDrawers/RangedFloatDrawer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a5716b352e7c6fb48898f9a0f4e70e7e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
ScriptableObjects.meta
Normal file
8
ScriptableObjects.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6055e6a38ee2e14d96512a8d53b25c5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
ScriptableObjects/Audio.meta
Normal file
8
ScriptableObjects/Audio.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f03ec7c8000ddc74c9884e0365fcd76a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,9 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Util.ScriptableObjects.Audio
|
public abstract class AudioEvent : ScriptableObject
|
||||||
{
|
{
|
||||||
public abstract class AudioEvent : ScriptableObject
|
public abstract void Play(AudioSource source);
|
||||||
{
|
|
||||||
public abstract void Play(AudioSource source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
11
ScriptableObjects/Audio/AudioEvent.cs.meta
Normal file
11
ScriptableObjects/Audio/AudioEvent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 44f3003e434a4ee45b919288a52a9091
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,24 +1,20 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Util.CustomTypes;
|
|
||||||
|
|
||||||
namespace Util.ScriptableObjects.Audio
|
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
|
||||||
|
public class SimpleAudioEvent : AudioEvent
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
|
public AudioClip[] clips;
|
||||||
public class SimpleAudioEvent : AudioEvent
|
public RangedFloat volume;
|
||||||
|
|
||||||
|
[MinMaxRange(0, 2)] public RangedFloat pitch;
|
||||||
|
|
||||||
|
public override void Play(AudioSource source)
|
||||||
{
|
{
|
||||||
public AudioClip[] clips;
|
if (clips.Length == 0) return;
|
||||||
public RangedFloat volume;
|
|
||||||
|
|
||||||
[MinMaxRange(0, 2)] public RangedFloat pitch;
|
source.clip = clips[Random.Range(0, clips.Length)];
|
||||||
|
source.volume = Random.Range(volume.minValue, volume.maxValue);
|
||||||
public override void Play(AudioSource source)
|
source.pitch = Random.Range(pitch.minValue, pitch.maxValue);
|
||||||
{
|
source.Play();
|
||||||
if (clips.Length == 0) return;
|
|
||||||
|
|
||||||
source.clip = clips[Random.Range(0, clips.Length)];
|
|
||||||
source.volume = Random.Range(volume.minValue, volume.maxValue);
|
|
||||||
source.pitch = Random.Range(pitch.minValue, pitch.maxValue);
|
|
||||||
source.Play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
ScriptableObjects/Audio/SimpleAudioEvent.cs.meta
Normal file
11
ScriptableObjects/Audio/SimpleAudioEvent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a516b45b8d44414186cecdcb04aa13c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
UI.meta
Normal file
8
UI.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06ceabc78e09fb1449cafe1c18edc376
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
UI/Components.meta
Normal file
8
UI/Components.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 81610042ba9649c478290c75afdd4aa6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
11
UI/Components/ComponentBase.cs.meta
Normal file
11
UI/Components/ComponentBase.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 05f1837e06532924aae74834640813db
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
11
UI/Components/SliderComponent.cs.meta
Normal file
11
UI/Components/SliderComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 87e3dcb517633be41a50388dccb8453e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
11
UI/Components/TextComponent.cs.meta
Normal file
11
UI/Components/TextComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f98198e52cc782f419cbdc72e5da0149
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Utils.meta
Normal file
8
Utils.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5edd6f06f0aa9d24fb11166e78450390
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,48 +1,45 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Util
|
public class ObjectPool<T> where T : Object
|
||||||
{
|
{
|
||||||
public class ObjectPool<T> where T : Object
|
private readonly Queue<T> _pool;
|
||||||
|
private readonly List<T> _prefab;
|
||||||
|
|
||||||
|
public ObjectPool(IEnumerable<T> poolPrefab)
|
||||||
{
|
{
|
||||||
private readonly Queue<T> _pool;
|
_pool = new Queue<T>();
|
||||||
private readonly List<T> _prefab;
|
_prefab = new List<T>();
|
||||||
|
_prefab.AddRange(poolPrefab);
|
||||||
|
}
|
||||||
|
|
||||||
public ObjectPool(IEnumerable<T> poolPrefab)
|
/*public ObjectPool(IEnumerable<T> prefabs)
|
||||||
|
{
|
||||||
|
_pool = new Queue<T>();
|
||||||
|
_prefab.AddRange(prefabs);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void Pool(T objectToPool)
|
||||||
|
{
|
||||||
|
_pool.Enqueue(objectToPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T DePool()
|
||||||
|
{
|
||||||
|
if (_pool.Count > 0)
|
||||||
{
|
{
|
||||||
_pool = new Queue<T>();
|
return _pool.Dequeue();
|
||||||
_prefab = new List<T>();
|
|
||||||
_prefab.AddRange(poolPrefab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public ObjectPool(IEnumerable<T> prefabs)
|
var randomNumber = Random.Range(0, _prefab.Count);
|
||||||
{
|
return Object.Instantiate(_prefab[randomNumber]);
|
||||||
_pool = new Queue<T>();
|
}
|
||||||
_prefab.AddRange(prefabs);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void Pool(T objectToPool)
|
public void PoolAll(IEnumerable<T> listOfObject)
|
||||||
|
{
|
||||||
|
foreach (var obj in listOfObject)
|
||||||
{
|
{
|
||||||
_pool.Enqueue(objectToPool);
|
Pool(obj);
|
||||||
}
|
|
||||||
|
|
||||||
public T DePool()
|
|
||||||
{
|
|
||||||
if (_pool.Count > 0)
|
|
||||||
{
|
|
||||||
return _pool.Dequeue();
|
|
||||||
}
|
|
||||||
|
|
||||||
var randomNumber = Random.Range(0, _prefab.Count);
|
|
||||||
return Object.Instantiate(_prefab[randomNumber]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PoolAll(IEnumerable<T> listOfObject)
|
|
||||||
{
|
|
||||||
foreach (var obj in listOfObject)
|
|
||||||
{
|
|
||||||
Pool(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
Utils/ObjectPool.cs.meta
Normal file
11
Utils/ObjectPool.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0279835920dc21e4bb18443d24dbcd81
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user