Added meta files and remove bad namespaces

Will add better namespaces later
This commit is contained in:
Martin 2020-04-29 23:10:02 -04:00
parent ddd8e232a7
commit 49d2952bf8
26 changed files with 304 additions and 135 deletions

8
Attributes.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 618d1e8b8a58df14e81833e4c4623513
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 96bace79d06c3784ca7aad8ca4779faa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,11 +1,8 @@
using System;
namespace Util.CustomTypes
[Serializable]
public struct RangedFloat
{
[Serializable]
public struct RangedFloat
{
public float minValue;
public float maxValue;
}
public float minValue;
public float maxValue;
}

View 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
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d1f2b5d5f1ea2d4ba6ac94a6adedf10
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bcaa3a57881b3d14fa27f5f5a72f5277
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,38 +1,34 @@
using UnityEditor;
using UnityEngine;
using Util.ScriptableObjects.Audio;
namespace Editor.customInspector
[CustomEditor(typeof(AudioEvent), true)]
public class AudioEventInspector : Editor
{
[CustomEditor(typeof(AudioEvent), true)]
public class AudioEventInspector : UnityEditor.Editor
[SerializeField] private AudioSource audioSource;
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 =
EditorUtility.CreateGameObjectWithHideFlags("Audio preview", HideFlags.HideAndDontSave,
typeof(AudioSource)).GetComponent<AudioSource>();
((AudioEvent) target).Play(audioSource);
}
private void OnDisable()
{
DestroyImmediate(audioSource.gameObject);
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
if (GUILayout.Button("Preview"))
{
((AudioEvent) target).Play(audioSource);
}
EditorGUI.EndDisabledGroup();
}
EditorGUI.EndDisabledGroup();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2bc328582b298304f957056327d58af5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 80c222b09cde6a24aa82c866ad1e378a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,54 +1,50 @@
using UnityEditor;
using UnityEngine;
using Util.CustomTypes;
namespace Editor.PropertyDrawer
[CustomPropertyDrawer(typeof(RangedFloat), true)]
public class RangedFloatDrawer : PropertyDrawer
{
[CustomPropertyDrawer(typeof(RangedFloat), true)]
public class RangedFloatDrawer : UnityEditor.PropertyDrawer
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
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);
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)
{
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();
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();
}
}

View 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
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f6055e6a38ee2e14d96512a8d53b25c5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f03ec7c8000ddc74c9884e0365fcd76a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +1,6 @@
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);
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44f3003e434a4ee45b919288a52a9091
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,24 +1,20 @@
using UnityEngine;
using Util.CustomTypes;
namespace Util.ScriptableObjects.Audio
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
public class SimpleAudioEvent : AudioEvent
{
[CreateAssetMenu(menuName = "ScriptableObject/SimpleAudioEvent")]
public class SimpleAudioEvent : AudioEvent
public AudioClip[] clips;
public RangedFloat volume;
[MinMaxRange(0, 2)] public RangedFloat pitch;
public override void Play(AudioSource source)
{
public AudioClip[] clips;
public RangedFloat volume;
if (clips.Length == 0) return;
[MinMaxRange(0, 2)] public RangedFloat pitch;
public override void Play(AudioSource source)
{
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();
}
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();
}
}

View 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
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 06ceabc78e09fb1449cafe1c18edc376
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
UI/Components.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81610042ba9649c478290c75afdd4aa6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 05f1837e06532924aae74834640813db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87e3dcb517633be41a50388dccb8453e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5edd6f06f0aa9d24fb11166e78450390
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,48 +1,45 @@
using System.Collections.Generic;
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;
private readonly List<T> _prefab;
_pool = new Queue<T>();
_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>();
_prefab = new List<T>();
_prefab.AddRange(poolPrefab);
return _pool.Dequeue();
}
/*public ObjectPool(IEnumerable<T> prefabs)
{
_pool = new Queue<T>();
_prefab.AddRange(prefabs);
}*/
var randomNumber = Random.Range(0, _prefab.Count);
return Object.Instantiate(_prefab[randomNumber]);
}
public void Pool(T objectToPool)
public void PoolAll(IEnumerable<T> listOfObject)
{
foreach (var obj in listOfObject)
{
_pool.Enqueue(objectToPool);
}
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);
}
Pool(obj);
}
}
}

11
Utils/ObjectPool.cs.meta Normal file
View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0279835920dc21e4bb18443d24dbcd81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: