diff --git a/Attributes.meta b/Attributes.meta new file mode 100644 index 0000000..89b3187 --- /dev/null +++ b/Attributes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 618d1e8b8a58df14e81833e4c4623513 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Attributes/MinMaxRangeAttribute.cs.meta b/Attributes/MinMaxRangeAttribute.cs.meta new file mode 100644 index 0000000..2097143 --- /dev/null +++ b/Attributes/MinMaxRangeAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4996055a108bf1a40825fd570adfb82f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CustomTypes.meta b/CustomTypes.meta new file mode 100644 index 0000000..26dd359 --- /dev/null +++ b/CustomTypes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96bace79d06c3784ca7aad8ca4779faa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CustomTypes/RangedFloat.cs b/CustomTypes/RangedFloat.cs index d4e44ec..4e66fe0 100644 --- a/CustomTypes/RangedFloat.cs +++ b/CustomTypes/RangedFloat.cs @@ -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; } \ No newline at end of file diff --git a/CustomTypes/RangedFloat.cs.meta b/CustomTypes/RangedFloat.cs.meta new file mode 100644 index 0000000..1975ba2 --- /dev/null +++ b/CustomTypes/RangedFloat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c4aefb8a410bcae4a88de6f72ae1c873 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor.meta b/Editor.meta new file mode 100644 index 0000000..791e002 --- /dev/null +++ b/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d1f2b5d5f1ea2d4ba6ac94a6adedf10 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/CustomInspectors.meta b/Editor/CustomInspectors.meta new file mode 100644 index 0000000..53c90a9 --- /dev/null +++ b/Editor/CustomInspectors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcaa3a57881b3d14fa27f5f5a72f5277 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/CustomInspectors/AudioEventInspector.cs b/Editor/CustomInspectors/AudioEventInspector.cs index be48d99..4ff5c52 100644 --- a/Editor/CustomInspectors/AudioEventInspector.cs +++ b/Editor/CustomInspectors/AudioEventInspector.cs @@ -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(); + } - 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(); + ((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(); } } \ No newline at end of file diff --git a/Editor/CustomInspectors/AudioEventInspector.cs.meta b/Editor/CustomInspectors/AudioEventInspector.cs.meta new file mode 100644 index 0000000..f4ee843 --- /dev/null +++ b/Editor/CustomInspectors/AudioEventInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2bc328582b298304f957056327d58af5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/PropertyDrawers.meta b/Editor/PropertyDrawers.meta new file mode 100644 index 0000000..983a554 --- /dev/null +++ b/Editor/PropertyDrawers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 80c222b09cde6a24aa82c866ad1e378a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/PropertyDrawers/RangedFloatDrawer.cs b/Editor/PropertyDrawers/RangedFloatDrawer.cs index 78f1511..df8573e 100644 --- a/Editor/PropertyDrawers/RangedFloatDrawer.cs +++ b/Editor/PropertyDrawers/RangedFloatDrawer.cs @@ -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(); } } \ No newline at end of file diff --git a/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta b/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta new file mode 100644 index 0000000..8381132 --- /dev/null +++ b/Editor/PropertyDrawers/RangedFloatDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a5716b352e7c6fb48898f9a0f4e70e7e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects.meta b/ScriptableObjects.meta new file mode 100644 index 0000000..2b43a13 --- /dev/null +++ b/ScriptableObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6055e6a38ee2e14d96512a8d53b25c5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/Audio.meta b/ScriptableObjects/Audio.meta new file mode 100644 index 0000000..53dc1b1 --- /dev/null +++ b/ScriptableObjects/Audio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f03ec7c8000ddc74c9884e0365fcd76a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/Audio/AudioEvent.cs b/ScriptableObjects/Audio/AudioEvent.cs index b67cf1a..034a246 100644 --- a/ScriptableObjects/Audio/AudioEvent.cs +++ b/ScriptableObjects/Audio/AudioEvent.cs @@ -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); } \ No newline at end of file diff --git a/ScriptableObjects/Audio/AudioEvent.cs.meta b/ScriptableObjects/Audio/AudioEvent.cs.meta new file mode 100644 index 0000000..d1c72de --- /dev/null +++ b/ScriptableObjects/Audio/AudioEvent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 44f3003e434a4ee45b919288a52a9091 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ScriptableObjects/Audio/SimpleAudioEvent.cs b/ScriptableObjects/Audio/SimpleAudioEvent.cs index 519d35f..d634304 100644 --- a/ScriptableObjects/Audio/SimpleAudioEvent.cs +++ b/ScriptableObjects/Audio/SimpleAudioEvent.cs @@ -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(); } } \ No newline at end of file diff --git a/ScriptableObjects/Audio/SimpleAudioEvent.cs.meta b/ScriptableObjects/Audio/SimpleAudioEvent.cs.meta new file mode 100644 index 0000000..27fd342 --- /dev/null +++ b/ScriptableObjects/Audio/SimpleAudioEvent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a516b45b8d44414186cecdcb04aa13c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UI.meta b/UI.meta new file mode 100644 index 0000000..a336b1b --- /dev/null +++ b/UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 06ceabc78e09fb1449cafe1c18edc376 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UI/Components.meta b/UI/Components.meta new file mode 100644 index 0000000..2c2f693 --- /dev/null +++ b/UI/Components.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 81610042ba9649c478290c75afdd4aa6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UI/Components/ComponentBase.cs.meta b/UI/Components/ComponentBase.cs.meta new file mode 100644 index 0000000..a1a99af --- /dev/null +++ b/UI/Components/ComponentBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 05f1837e06532924aae74834640813db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UI/Components/SliderComponent.cs.meta b/UI/Components/SliderComponent.cs.meta new file mode 100644 index 0000000..827ea05 --- /dev/null +++ b/UI/Components/SliderComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87e3dcb517633be41a50388dccb8453e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UI/Components/TextComponent.cs.meta b/UI/Components/TextComponent.cs.meta new file mode 100644 index 0000000..bbbcef0 --- /dev/null +++ b/UI/Components/TextComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f98198e52cc782f419cbdc72e5da0149 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Utils.meta b/Utils.meta new file mode 100644 index 0000000..37cc2c7 --- /dev/null +++ b/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5edd6f06f0aa9d24fb11166e78450390 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Utils/ObjectPool.cs b/Utils/ObjectPool.cs index 71e69cc..fe6f722 100644 --- a/Utils/ObjectPool.cs +++ b/Utils/ObjectPool.cs @@ -1,48 +1,45 @@ using System.Collections.Generic; using UnityEngine; -namespace Util +public class ObjectPool where T : Object { - public class ObjectPool where T : Object + private readonly Queue _pool; + private readonly List _prefab; + + public ObjectPool(IEnumerable poolPrefab) { - private readonly Queue _pool; - private readonly List _prefab; + _pool = new Queue(); + _prefab = new List(); + _prefab.AddRange(poolPrefab); + } - public ObjectPool(IEnumerable poolPrefab) + /*public ObjectPool(IEnumerable prefabs) + { + _pool = new Queue(); + _prefab.AddRange(prefabs); + }*/ + + public void Pool(T objectToPool) + { + _pool.Enqueue(objectToPool); + } + + public T DePool() + { + if (_pool.Count > 0) { - _pool = new Queue(); - _prefab = new List(); - _prefab.AddRange(poolPrefab); + return _pool.Dequeue(); } - /*public ObjectPool(IEnumerable prefabs) - { - _pool = new Queue(); - _prefab.AddRange(prefabs); - }*/ + var randomNumber = Random.Range(0, _prefab.Count); + return Object.Instantiate(_prefab[randomNumber]); + } - public void Pool(T objectToPool) + public void PoolAll(IEnumerable 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 listOfObject) - { - foreach (var obj in listOfObject) - { - Pool(obj); - } + Pool(obj); } } } \ No newline at end of file diff --git a/Utils/ObjectPool.cs.meta b/Utils/ObjectPool.cs.meta new file mode 100644 index 0000000..7e0c926 --- /dev/null +++ b/Utils/ObjectPool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0279835920dc21e4bb18443d24dbcd81 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: