├── .github └── workflows │ └── publish_upm.yml ├── .gitignore ├── Assets ├── com.beardphantom.unitycommonlibrary.meta └── com.beardphantom.unitycommonlibrary │ ├── Editor.meta │ ├── Editor │ ├── ComponentEditorUtility.cs │ ├── ComponentEditorUtility.cs.meta │ ├── EditorAudioUtility.cs │ ├── EditorAudioUtility.cs.meta │ ├── EditorGUILayoutControls.cs │ ├── EditorGUILayoutControls.cs.meta │ ├── EditorGUIUtility.cs │ ├── EditorGUIUtility.cs.meta │ ├── EditorTagGenerator.cs │ ├── EditorTagGenerator.cs.meta │ ├── EditorUtility.cs │ ├── EditorUtility.cs.meta │ ├── GameObjectEditorUtility.cs │ ├── GameObjectEditorUtility.cs.meta │ ├── IndentScope.cs │ ├── IndentScope.cs.meta │ ├── Inspectors.meta │ ├── Inspectors │ │ ├── AudioCueAssetEditor.cs │ │ ├── AudioCueAssetEditor.cs.meta │ │ ├── NoteAttributeDrawer.cs │ │ ├── NoteAttributeDrawer.cs.meta │ │ ├── RelativesOnlyAttributeDrawer.cs │ │ ├── RelativesOnlyAttributeDrawer.cs.meta │ │ ├── SceneReferenceInspector.cs │ │ ├── SceneReferenceInspector.cs.meta │ │ ├── TagAttributeInspector.cs │ │ ├── TagAttributeInspector.cs.meta │ │ ├── TypeReferenceDrawer.cs │ │ ├── TypeReferenceDrawer.cs.meta │ │ ├── UIHitboxEditor.cs │ │ └── UIHitboxEditor.cs.meta │ ├── SearchField.cs │ ├── SearchField.cs.meta │ ├── SpriteUtility.cs │ ├── SpriteUtility.cs.meta │ ├── TestMaterialGenerator.cs │ ├── TestMaterialGenerator.cs.meta │ ├── UIElementsUtility.cs │ ├── UIElementsUtility.cs.meta │ ├── UnityCommonLibrary.Editor.asmdef │ └── UnityCommonLibrary.Editor.asmdef.meta │ ├── Gizmos.meta │ ├── Gizmos │ ├── AudioCue.png │ └── AudioCue.png.meta │ ├── README.md │ ├── README.md.meta │ ├── Runtime.meta │ ├── Runtime │ ├── Assets.meta │ ├── Assets │ │ ├── AnimationCurveValueAsset.cs │ │ ├── AnimationCurveValueAsset.cs.meta │ │ ├── AudioCueAsset.cs │ │ ├── AudioCueAsset.cs.meta │ │ ├── ColorValueAsset.cs │ │ ├── ColorValueAsset.cs.meta │ │ ├── FloatValueAsset.cs │ │ ├── FloatValueAsset.cs.meta │ │ ├── IntValueAsset.cs │ │ ├── IntValueAsset.cs.meta │ │ ├── ValueAsset.cs │ │ ├── ValueAsset.cs.meta │ │ ├── ValueAssetGeneric.cs │ │ └── ValueAssetGeneric.cs.meta │ ├── Attributes.meta │ ├── Attributes │ │ ├── InjectAttribute.cs │ │ ├── InjectAttribute.cs.meta │ │ ├── NoteAttribute.cs │ │ ├── NoteAttribute.cs.meta │ │ ├── RelativesOnlyAttribute.cs │ │ ├── RelativesOnlyAttribute.cs.meta │ │ ├── TagAttribute.cs │ │ ├── TagAttribute.cs.meta │ │ ├── TypeReferenceFilter.cs │ │ └── TypeReferenceFilter.cs.meta │ ├── AudioSourceSettings.cs │ ├── AudioSourceSettings.cs.meta │ ├── CollectionSelector.cs │ ├── CollectionSelector.cs.meta │ ├── Development.meta │ ├── Development │ │ ├── Mover.cs │ │ └── Mover.cs.meta │ ├── DontDestroyOnLoad.cs │ ├── DontDestroyOnLoad.cs.meta │ ├── EmptyMonoBehaviour.cs │ ├── EmptyMonoBehaviour.cs.meta │ ├── EnumData.cs │ ├── EnumData.cs.meta │ ├── EventBus.meta │ ├── EventBus │ │ ├── EventBus.cs │ │ ├── EventBus.cs.meta │ │ ├── EventBusObserver.cs │ │ ├── EventBusObserver.cs.meta │ │ ├── EventBusProcessLimit.cs │ │ ├── EventBusProcessLimit.cs.meta │ │ ├── ListenerCollection.cs │ │ ├── ListenerCollection.cs.meta │ │ ├── ParameterizedProcessLimit.cs │ │ ├── ParameterizedProcessLimit.cs.meta │ │ ├── UnlimitedProcessLimit.cs │ │ └── UnlimitedProcessLimit.cs.meta │ ├── FilterValue.cs │ ├── FilterValue.cs.meta │ ├── Flags32.cs │ ├── Flags32.cs.meta │ ├── FloatTrailingValue.cs │ ├── FloatTrailingValue.cs.meta │ ├── IWeightedChoice.cs │ ├── IWeightedChoice.cs.meta │ ├── LookAtTarget.cs │ ├── LookAtTarget.cs.meta │ ├── NullLogHandler.cs │ ├── NullLogHandler.cs.meta │ ├── NullLogger.cs │ ├── NullLogger.cs.meta │ ├── ObservedValue.cs │ ├── ObservedValue.cs.meta │ ├── PanTexture.cs │ ├── PanTexture.cs.meta │ ├── Pooling.meta │ ├── Pooling │ │ ├── CollectionPool.cs │ │ ├── CollectionPool.cs.meta │ │ ├── DictionaryPool.cs │ │ ├── DictionaryPool.cs.meta │ │ ├── HashSetPool.cs │ │ ├── HashSetPool.cs.meta │ │ ├── ListPool.cs │ │ ├── ListPool.cs.meta │ │ ├── ObjectPoolAsset.cs │ │ ├── ObjectPoolAsset.cs.meta │ │ ├── PocoPool.cs │ │ ├── PocoPool.cs.meta │ │ ├── QueuePool.cs │ │ ├── QueuePool.cs.meta │ │ ├── StackPool.cs │ │ ├── StackPool.cs.meta │ │ ├── UnityObjectPool.cs │ │ └── UnityObjectPool.cs.meta │ ├── RenderProxy.meta │ ├── RenderProxy │ │ ├── MeshRendererSubObject.cs │ │ ├── MeshRendererSubObject.cs.meta │ │ ├── RenderProxy.cs │ │ ├── RenderProxy.cs.meta │ │ ├── RenderProxyOptions.cs │ │ ├── RenderProxyOptions.cs.meta │ │ ├── RenderProxySubObject.cs │ │ └── RenderProxySubObject.cs.meta │ ├── SceneReference.cs │ ├── SceneReference.cs.meta │ ├── SetGameObjectActiveScope.cs │ ├── SetGameObjectActiveScope.cs.meta │ ├── Time.meta │ ├── Time │ │ ├── TimeMode.cs │ │ ├── TimeMode.cs.meta │ │ ├── TimeSlice.cs │ │ └── TimeSlice.cs.meta │ ├── TrailingValue.cs │ ├── TrailingValue.cs.meta │ ├── TransformElement.cs │ ├── TransformElement.cs.meta │ ├── TransformSettings.cs │ ├── TransformSettings.cs.meta │ ├── TypeReference.cs │ ├── TypeReference.cs.meta │ ├── UCLCore.cs │ ├── UCLCore.cs.meta │ ├── UI.meta │ ├── UI │ │ ├── InferSize.cs │ │ ├── InferSize.cs.meta │ │ ├── UIHitbox.cs │ │ ├── UIHitbox.cs.meta │ │ ├── WorldCanvasSizer.cs │ │ └── WorldCanvasSizer.cs.meta │ ├── UnityCommonLibrary.asmdef │ ├── UnityCommonLibrary.asmdef.meta │ ├── Utilities.meta │ ├── Utilities │ │ ├── BoundsUtility.cs │ │ ├── BoundsUtility.cs.meta │ │ ├── CameraUtility.cs │ │ ├── CameraUtility.cs.meta │ │ ├── CollectionUtility.cs │ │ ├── CollectionUtility.cs.meta │ │ ├── ComponentUtility.cs │ │ ├── ComponentUtility.cs.meta │ │ ├── CoroutineUtility.cs │ │ ├── CoroutineUtility.cs.meta │ │ ├── DebugUtility.cs │ │ ├── DebugUtility.cs.meta │ │ ├── EnumUtility.cs │ │ ├── EnumUtility.cs.meta │ │ ├── GameObjectUtility.cs │ │ ├── GameObjectUtility.cs.meta │ │ ├── GizmosUtility.cs │ │ ├── GizmosUtility.cs.meta │ │ ├── GradientUtility.cs │ │ ├── GradientUtility.cs.meta │ │ ├── HashCodeUtility.cs │ │ ├── HashCodeUtility.cs.meta │ │ ├── Math2DUtility.cs │ │ ├── Math2DUtility.cs.meta │ │ ├── MathUtility.cs │ │ ├── MathUtility.cs.meta │ │ ├── ObjectUtility.cs │ │ ├── ObjectUtility.cs.meta │ │ ├── PathUtility.cs │ │ ├── PathUtility.cs.meta │ │ ├── RandomUtility.cs │ │ ├── RandomUtility.cs.meta │ │ ├── RectUtility.cs │ │ ├── RectUtility.cs.meta │ │ ├── ReflectionUtility.cs │ │ ├── ReflectionUtility.cs.meta │ │ ├── RichTextUtility.cs │ │ ├── RichTextUtility.cs.meta │ │ ├── StringUtility.cs │ │ ├── StringUtility.cs.meta │ │ ├── StructUtility.cs │ │ ├── StructUtility.cs.meta │ │ ├── TextAssetUtils.cs │ │ ├── TextAssetUtils.cs.meta │ │ ├── TextureUtility.cs │ │ ├── TextureUtility.cs.meta │ │ ├── TimeUtility.cs │ │ ├── TimeUtility.cs.meta │ │ ├── TransformUtility.cs │ │ ├── TransformUtility.cs.meta │ │ ├── TrigUtility.cs │ │ ├── TrigUtility.cs.meta │ │ ├── TypeUtility.cs │ │ ├── TypeUtility.cs.meta │ │ ├── UIUtility.cs │ │ ├── UIUtility.cs.meta │ │ ├── WeightedChoiceUtility.cs │ │ └── WeightedChoiceUtility.cs.meta │ ├── Vector2TrailingValue.cs │ ├── Vector2TrailingValue.cs.meta │ ├── Vector3TrailingValue.cs │ └── Vector3TrailingValue.cs.meta │ ├── package.json │ └── package.json.meta ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset └── UserSettings └── EditorUserSettings.asset /.github/workflows/publish_upm.yml: -------------------------------------------------------------------------------- 1 | name: Publish_UPM 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | split-upm: 8 | name: split upm branch 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | fetch-depth: 0 14 | - name: split upm branch 15 | run: | 16 | git subtree split -P "$PKG_ROOT" -b upm 17 | git push -u origin upm 18 | env: 19 | PKG_ROOT: Assets/com.beardphantom.unitycommonlibrary 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | _Ignored/ 38 | _Ignored.meta 39 | csc.rsp* 40 | Logs/ 41 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81beda22f7c78d041a5b4e6810e037c2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e18cb25425911c4c8b5d5cc69b0f9be 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/ComponentEditorUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a71ea16e4780900429335b94966c1aa4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorAudioUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BeardPhantom.UCL.Assets; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace BeardPhantom.UCL.Editor 7 | { 8 | [InitializeOnLoad] 9 | public static class EditorAudioUtility 10 | { 11 | #region Fields 12 | 13 | private static readonly List _playingSources = new List(); 14 | 15 | #endregion 16 | 17 | #region Constructors 18 | 19 | static EditorAudioUtility() 20 | { 21 | EditorApplication.update -= EditorUpdate; 22 | EditorApplication.update += EditorUpdate; 23 | 24 | EditorApplication.playModeStateChanged += OnPlaymodeStateChanged; 25 | } 26 | 27 | #endregion 28 | 29 | #region Methods 30 | 31 | public static AudioSource Play(AudioCueAsset cue) 32 | { 33 | if (cue == null) 34 | { 35 | return null; 36 | } 37 | var source = GetAudioSource(); 38 | cue.Play(source); 39 | return source; 40 | } 41 | 42 | private static void OnPlaymodeStateChanged(PlayModeStateChange obj) 43 | { 44 | for (var i = _playingSources.Count - 1; i >= 0; i--) 45 | { 46 | var source = _playingSources[i]; 47 | if (source != null) 48 | { 49 | Object.DestroyImmediate(source.gameObject); 50 | } 51 | 52 | _playingSources.RemoveAt(i); 53 | } 54 | } 55 | 56 | private static AudioSource GetAudioSource() 57 | { 58 | var audioSource = UnityEditor.EditorUtility.CreateGameObjectWithHideFlags( 59 | "AUDIOSOURCE", 60 | HideFlags.HideAndDontSave, 61 | typeof(AudioSource)) 62 | .GetComponent(); 63 | _playingSources.Add(audioSource); 64 | return audioSource; 65 | } 66 | 67 | private static void EditorUpdate() 68 | { 69 | for (var i = _playingSources.Count - 1; i >= 0; i--) 70 | { 71 | var source = _playingSources[i]; 72 | var nullSource = source == null; 73 | if (!nullSource && source.isPlaying) 74 | { 75 | continue; 76 | } 77 | 78 | if (!nullSource) 79 | { 80 | Object.DestroyImmediate(source.gameObject); 81 | } 82 | 83 | _playingSources.RemoveAt(i); 84 | } 85 | } 86 | 87 | #endregion 88 | } 89 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorAudioUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3833e952e3598e49be897ebc19f1479 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorGUILayoutControls.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Editor 5 | { 6 | public static class EditorGUILayoutControls 7 | { 8 | #region Methods 9 | 10 | public static void HorizontalLine() 11 | { 12 | EditorGUILayout.LabelField( 13 | GUIContent.none, 14 | GUI.skin.horizontalSlider); 15 | } 16 | 17 | #endregion 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorGUILayoutControls.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0a73449e6b0e8f4b910856dad4c0aec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorGUIUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | 4 | namespace BeardPhantom.UCL.Editor 5 | { 6 | public class EditorGUIUtility 7 | { 8 | #region Fields 9 | 10 | private static readonly Dictionary _foldouts = 11 | new Dictionary(); 12 | 13 | #endregion 14 | 15 | #region Methods 16 | 17 | public static bool Foldout(string key, string display) 18 | { 19 | if (!_foldouts.ContainsKey(key)) 20 | { 21 | _foldouts.Add(key, true); 22 | } 23 | 24 | _foldouts[key] = EditorGUILayout.Foldout(_foldouts[key], display); 25 | 26 | return _foldouts[key]; 27 | } 28 | 29 | #endregion 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorGUIUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58d843ec01c23214791db793ef294fb8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorTagGenerator.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Utility; 2 | using System.IO; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEditor.Compilation; 6 | using UnityEditorInternal; 7 | using UnityEngine; 8 | 9 | namespace BeardPhantom.UCL.Editor 10 | { 11 | [InitializeOnLoad] 12 | public static class EditorTagGenerator 13 | { 14 | #region Fields 15 | 16 | public const string AUTO_TAG_CS_GENERATION_KEY = "{0}_AUTO_TAG_CS_GENERATION"; 17 | 18 | private const string TAG_CLASS_FORMAT = @" 19 | namespace SpaceTech.Game 20 | {{ 21 | public static class Tags 22 | {{ 23 | {0} 24 | }} 25 | }}"; 26 | 27 | private const string TAG_FORMAT = " public const string {0} = \"{1}\";"; 28 | 29 | #endregion 30 | 31 | #region Constructors 32 | 33 | static EditorTagGenerator() 34 | { 35 | void CheckThenGenerate(object arg) 36 | { 37 | var key = GetAutoGenerateEditorPrefsKey(); 38 | if (EditorPrefs.GetBool(key, false)) 39 | { 40 | GenerateTagList(); 41 | } 42 | } 43 | 44 | CompilationPipeline.compilationStarted -= CheckThenGenerate; 45 | CompilationPipeline.compilationStarted += CheckThenGenerate; 46 | 47 | CheckThenGenerate(null); 48 | } 49 | 50 | #endregion 51 | 52 | #region Methods 53 | 54 | public static void SetAutoGenerateTagCSFile(bool allow) 55 | { 56 | var key = GetAutoGenerateEditorPrefsKey(); 57 | EditorPrefs.SetBool(key, allow); 58 | } 59 | 60 | public static string GetAutoGenerateEditorPrefsKey() 61 | { 62 | return AUTO_TAG_CS_GENERATION_KEY.FormatStr(Application.productName); 63 | } 64 | 65 | [MenuItem("Assets/Generate Tag List")] 66 | private static void GenerateTagList() 67 | { 68 | if (Application.isPlaying) 69 | { 70 | return; 71 | } 72 | 73 | var tags = InternalEditorUtility.tags; 74 | var tagList = tags.Select( 75 | tag => 76 | { 77 | var varName = GetVarName(tag); 78 | return string.Format(TAG_FORMAT, varName, tag); 79 | }) 80 | .ToArray(); 81 | var contents = string.Format(TAG_CLASS_FORMAT, string.Join("\n\n", tagList)); 82 | 83 | contents = contents.Replace("\r\n", "\n"); 84 | var path = Path.Combine(Application.dataPath, "Scripts", "Game"); 85 | Directory.CreateDirectory(path); 86 | path = Path.Combine(path, "Tags.cs"); 87 | File.WriteAllText(path, contents); 88 | AssetDatabase.Refresh(); 89 | } 90 | 91 | private static string GetVarName(string tag) 92 | { 93 | return string.Concat( 94 | tag.Select( 95 | (x, i) => i > 0 && char.IsUpper(x) 96 | ? $"_{x.ToString().ToUpper()}" 97 | : x.ToString().ToUpper())); 98 | } 99 | 100 | #endregion 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorTagGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc4f3c547aee4dbab44e556830980068 3 | timeCreated: 1568792184 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/EditorUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38644c60e22a70742a345bf3bfa1fb4f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/GameObjectEditorUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Editor 5 | { 6 | public static class GameObjectEditorUtility 7 | { 8 | #region Methods 9 | 10 | public static GameObject GetPrefab(GameObject obj) 11 | { 12 | if (PrefabUtility.IsPartOfPrefabAsset(obj)) 13 | { 14 | return obj.transform.root.gameObject; 15 | } 16 | 17 | if (PrefabUtility.IsPartOfPrefabInstance(obj)) 18 | { 19 | return PrefabUtility.GetOutermostPrefabInstanceRoot(obj); 20 | } 21 | 22 | return null; 23 | } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/GameObjectEditorUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9c5a11c91ab3134c9a75a4271ad7568 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/IndentScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | 4 | namespace BeardPhantom.UCL.Editor 5 | { 6 | public struct IndentScope : IDisposable 7 | { 8 | #region Fields 9 | 10 | private readonly int _indentOffset; 11 | 12 | #endregion 13 | 14 | #region Constructors 15 | 16 | public IndentScope(int indentOffset) 17 | { 18 | _indentOffset = indentOffset; 19 | EditorGUI.indentLevel += _indentOffset; 20 | } 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | /// 27 | public void Dispose() 28 | { 29 | EditorGUI.indentLevel -= _indentOffset; 30 | } 31 | 32 | #endregion 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/IndentScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc1b3f47c2384e6bbb7021cff67de3c0 3 | timeCreated: 1558951050 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44f89e09054a8b247998d8ed1800d041 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/AudioCueAssetEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using BeardPhantom.UCL.Assets; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace BeardPhantom.UCL.Editor.Inspectors 7 | { 8 | [CustomEditor(typeof(AudioCueAsset))] 9 | public class AudioCueAssetEditor : UnityEditor.Editor 10 | { 11 | #region Fields 12 | 13 | private AudioSource _lastPlayingSource; 14 | 15 | #endregion 16 | 17 | #region Methods 18 | 19 | /// 20 | public override void OnInspectorGUI() 21 | { 22 | serializedObject.Update(); 23 | var cueAsset = (AudioCueAsset) target; 24 | var cachedEnabled = GUI.enabled; 25 | GUI.enabled = cueAsset.Audio != null && cueAsset.Audio.Any(a => a.Clip != null); 26 | var cachedColor = GUI.color; 27 | if (_lastPlayingSource == null) 28 | { 29 | GUI.color = Color.green; 30 | if (GUILayout.Button("Play")) 31 | { 32 | _lastPlayingSource = EditorAudioUtility.Play(cueAsset); 33 | } 34 | } 35 | else 36 | { 37 | GUI.color = Color.red; 38 | if (GUILayout.Button("Stop")) 39 | { 40 | _lastPlayingSource.Stop(); 41 | } 42 | } 43 | 44 | GUI.color = cachedColor; 45 | GUI.enabled = cachedEnabled; 46 | 47 | DrawPropertiesExcluding(serializedObject, "m_Script"); 48 | serializedObject.ApplyModifiedProperties(); 49 | if (_lastPlayingSource != null) 50 | { 51 | Repaint(); 52 | } 53 | } 54 | 55 | private void OnDisable() 56 | { 57 | if (_lastPlayingSource != null) 58 | { 59 | _lastPlayingSource.Stop(); 60 | } 61 | } 62 | 63 | #endregion 64 | } 65 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/AudioCueAssetEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cd90bdd7afc78c4fbe2eade775a3131 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/NoteAttributeDrawer.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Attributes; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL.Editor.Inspectors 6 | { 7 | [CustomPropertyDrawer(typeof(NoteAttribute))] 8 | public class NoteAttributeDrawer : DecoratorDrawer 9 | { 10 | #region Fields 11 | 12 | private float _height; 13 | 14 | private NoteAttribute _note; 15 | 16 | private MessageType _type; 17 | 18 | #endregion 19 | 20 | #region Methods 21 | 22 | public override float GetHeight() 23 | { 24 | EnsureNoteData(); 25 | 26 | return _height; 27 | } 28 | 29 | public override void OnGUI(Rect position) 30 | { 31 | EnsureNoteData(); 32 | EditorGUI.HelpBox(position, _note.Text, _type); 33 | } 34 | 35 | private void EnsureNoteData() 36 | { 37 | if (_note == null) 38 | { 39 | _note = attribute as NoteAttribute; 40 | _type = (MessageType) (int) _note.Type; 41 | 42 | _height = EditorStyles 43 | .helpBox.CalcSize(new GUIContent(_note.Text)) 44 | .y; 45 | } 46 | } 47 | 48 | #endregion 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/NoteAttributeDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70caad98c0681604497f7aebc57b2bc9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/RelativesOnlyAttributeDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9dadaecabee688646a39e46566718993 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/SceneReferenceInspector.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Editor.Inspectors 5 | { 6 | /// 7 | /// Drawer for 8 | /// 9 | [CustomPropertyDrawer(typeof(SceneReference))] 10 | public class SceneReferenceInspector : PropertyDrawer 11 | { 12 | #region Methods 13 | 14 | public override float GetPropertyHeight( 15 | SerializedProperty property, 16 | GUIContent label) 17 | { 18 | return UnityEditor.EditorGUIUtility.singleLineHeight; 19 | } 20 | 21 | public override void OnGUI( 22 | Rect position, 23 | SerializedProperty property, 24 | GUIContent label) 25 | { 26 | var pathProperty = property.FindPropertyRelative("_rawPath"); 27 | var currentScene = AssetDatabase.LoadAssetAtPath(pathProperty.stringValue); 28 | using (var changeCheck = new EditorGUI.ChangeCheckScope()) 29 | { 30 | var newScene = (SceneAsset) EditorGUI.ObjectField( 31 | position, 32 | label, 33 | currentScene, 34 | typeof(SceneAsset), 35 | false); 36 | 37 | if (changeCheck.changed) 38 | { 39 | pathProperty.stringValue = AssetDatabase.GetAssetOrScenePath(newScene); 40 | } 41 | } 42 | } 43 | 44 | #endregion 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/SceneReferenceInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 376825deb9ad83842a8ebdec515ade7a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/TagAttributeInspector.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Attributes; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL.Editor.Inspectors 6 | { 7 | [CustomPropertyDrawer(typeof(TagAttribute))] 8 | public class TagAttributeInspector : PropertyDrawer 9 | { 10 | #region Methods 11 | 12 | public override float GetPropertyHeight( 13 | SerializedProperty property, 14 | GUIContent label) 15 | { 16 | return UnityEditor.EditorGUIUtility.singleLineHeight; 17 | } 18 | 19 | public override void OnGUI( 20 | Rect position, 21 | SerializedProperty property, 22 | GUIContent label) 23 | { 24 | property.stringValue = EditorGUI.TagField( 25 | position, 26 | label, 27 | property.stringValue); 28 | } 29 | 30 | #endregion 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/TagAttributeInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64418e10931897c40994685ad4f39fe1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/TypeReferenceDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using BeardPhantom.UCL.Attributes; 5 | using BeardPhantom.UCL.Utility; 6 | using UnityEditor; 7 | using UnityEngine; 8 | 9 | namespace BeardPhantom.UCL.Editor.Inspectors 10 | { 11 | [CustomPropertyDrawer(typeof(TypeReference))] 12 | public class TypeReferenceDrawer : PropertyDrawer 13 | { 14 | #region Fields 15 | 16 | private Type[] _types; 17 | 18 | private string[] _fullyQualifiedNames; 19 | 20 | private GUIContent[] _names; 21 | 22 | private bool _setup; 23 | 24 | #endregion 25 | 26 | #region Methods 27 | 28 | public override float GetPropertyHeight( 29 | SerializedProperty property, 30 | GUIContent label) 31 | { 32 | return UnityEditor.EditorGUIUtility.singleLineHeight; 33 | } 34 | 35 | public override void OnGUI( 36 | Rect position, 37 | SerializedProperty property, 38 | GUIContent label) 39 | { 40 | if (!_setup) 41 | { 42 | Setup(property); 43 | } 44 | 45 | var subprop = property.FindPropertyRelative("_typeString"); 46 | 47 | var index = Array.IndexOf( 48 | _fullyQualifiedNames, 49 | subprop.stringValue); 50 | 51 | index = Mathf.Max(0, index); 52 | index = EditorGUI.Popup(position, label, index, _names); 53 | subprop.stringValue = _types[index].AssemblyQualifiedName; 54 | } 55 | 56 | private void Setup(SerializedProperty property) 57 | { 58 | _setup = true; 59 | var targetObject = property.serializedObject.targetObject; 60 | var targetObjectClassType = targetObject.GetType(); 61 | 62 | var field = targetObjectClassType.GetField( 63 | property.propertyPath, 64 | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); 65 | 66 | var attributes = field.GetCustomAttributes( 67 | typeof(TypeReferenceFilterAttribute), 68 | true); 69 | 70 | if (attributes == null || attributes.Length == 0) 71 | { 72 | return; 73 | } 74 | 75 | var filter = (attributes[0] as TypeReferenceFilterAttribute).Type; 76 | 77 | _types = AppDomain.CurrentDomain.GetAssemblies() 78 | .SelectMany(a => a.GetTypes()) 79 | .Where(t => t.InheritsFrom(filter)) 80 | .OrderBy(t => t.Name) 81 | .ToArray(); 82 | 83 | _fullyQualifiedNames = 84 | _types.Select(t => t.AssemblyQualifiedName).ToArray(); 85 | 86 | _names = _types.Select(t => new GUIContent(t.Name)).ToArray(); 87 | } 88 | 89 | #endregion 90 | } 91 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/TypeReferenceDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8c57cb5d6f261f4bba1268f23e6878b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/UIHitboxEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace BeardPhantom.UCL.Editor.Inspectors 4 | { 5 | [CustomEditor(typeof(UIHitbox))] 6 | public class UIHitboxEditor : UnityEditor.Editor 7 | { 8 | #region Methods 9 | 10 | public override void OnInspectorGUI() { } 11 | 12 | #endregion 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/Inspectors/UIHitboxEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2c95c4564e66104cb64dd3577206a9a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/SearchField.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Editor 4 | { 5 | public class SearchField 6 | { 7 | #region Fields 8 | 9 | public readonly FilterValue FilterValue = new FilterValue(); 10 | 11 | private readonly UnityEditor.IMGUI.Controls.SearchField _searchField 12 | = new UnityEditor.IMGUI.Controls.SearchField(); 13 | 14 | #endregion 15 | 16 | #region Methods 17 | 18 | public bool OnGUI(bool toolbar, params GUILayoutOption[] options) 19 | { 20 | return FilterValue.Update( 21 | toolbar 22 | ? _searchField.OnToolbarGUI(FilterValue.RawValue) 23 | : _searchField.OnGUI(FilterValue.RawValue)); 24 | } 25 | 26 | public void Focus() 27 | { 28 | _searchField.SetFocus(); 29 | } 30 | 31 | #endregion 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/SearchField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c74fc23164d0b8418dc34989c2e327b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/SpriteUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Editor 5 | { 6 | public class SpriteUtility : MonoBehaviour 7 | { 8 | #region Methods 9 | 10 | [MenuItem("CONTEXT/Rigidbody2D/Ground Sprite")] 11 | public static void GroundSprite(MenuCommand command) 12 | { 13 | var rb2D = command.context as Rigidbody2D; 14 | var p2D = rb2D.gameObject.AddComponent(); 15 | 16 | var hits2D = Physics2D.RaycastAll( 17 | rb2D.transform.position, 18 | Vector2.down, 19 | float.MaxValue); 20 | 21 | foreach (var h2D in hits2D) 22 | { 23 | if (h2D.collider.gameObject != rb2D.gameObject) 24 | { 25 | var diff = h2D.distance - p2D.bounds.extents.y; 26 | diff *= -1f; 27 | rb2D.transform.position += Vector3.up * diff; 28 | } 29 | } 30 | 31 | DestroyImmediate(p2D); 32 | } 33 | 34 | #endregion 35 | } 36 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/SpriteUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 933dca4a7a602804fb68d4dcb53e0d1c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/TestMaterialGenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53b485b31bf3fc448a5aca14ee777222 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/UIElementsUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.UIElements; 4 | using UnityEngine.UIElements; 5 | 6 | namespace BeardPhantom.UCL.Editor 7 | { 8 | public static class UIElementsUtility 9 | { 10 | #region Methods 11 | 12 | public static void CreateSerializedPropertyFields( 13 | SerializedObject serializedObject, 14 | VisualElement parent, 15 | params string[] ignoredProperties) 16 | { 17 | var propIter = serializedObject.GetIterator(); 18 | propIter.NextVisible(true); 19 | do 20 | { 21 | if (Array.IndexOf(ignoredProperties, propIter.name) >= 0) 22 | { 23 | continue; 24 | } 25 | 26 | parent.Add(new PropertyField(propIter)); 27 | } 28 | while (propIter.NextVisible(false)); 29 | } 30 | 31 | #endregion 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/UIElementsUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80a2655d5a57496eaabd9dd1b95ae672 3 | timeCreated: 1559183351 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/UnityCommonLibrary.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityCommonLibrary.Editor", 3 | "references": [ 4 | "GUID:be2dec62855e20043aafc6e0ea552e7e" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [] 17 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Editor/UnityCommonLibrary.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2284f6e7fc4b0c04599e904467618032 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Gizmos.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c52b5b1cb2f698444a3473390c46a1e5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Gizmos/AudioCue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thebeardphantom/UnityCommonLibrary/efb0497fa31104d5aa597e561dc7b86266e3c7d0/Assets/com.beardphantom.unitycommonlibrary/Gizmos/AudioCue.png -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Gizmos/AudioCue.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efbcc2716f8d12645985158672a9f81a 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 10 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: 1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: -1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 2 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 2048 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 1 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 2048 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 1 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | internalID: 0 91 | vertices: [] 92 | indices: 93 | edges: [] 94 | weights: [] 95 | secondaryTextures: [] 96 | spritePackingTag: 97 | pSDRemoveMatte: 0 98 | pSDShowRemoveMatteOption: 0 99 | userData: 100 | assetBundleName: 101 | assetBundleVariant: 102 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/README.md: -------------------------------------------------------------------------------- 1 | # UnityCommonLibrary 2 | 3 | # DEPRECATED 4 | Most of the functionality of this repo will be moved to other libraries, mainly [Fabric.*](https://github.com/thebeardphantom/Fabric.Core) 5 | 6 | A collection of useful scripts for Unity. 7 | 8 | Rebuilt to work for UPM. 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8df7e9e0584221347b07d2a353992dd7 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97af15af9031ee74d9a7652aa3e90968 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81270704a89e2004abe8efde8671a1fa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/AnimationCurveValueAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Assets 4 | { 5 | /// 6 | /// Value asset representing an animation curve. 7 | /// 8 | public class AnimationCurveValueAsset : ValueAsset { } 9 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/AnimationCurveValueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dae57f3f42862c04788d1d8bcb60b399 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/AudioCueAsset.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Utility; 2 | using System; 3 | using UnityEngine; 4 | using UnityEngine.Assertions; 5 | 6 | namespace BeardPhantom.UCL.Assets 7 | { 8 | /// 9 | /// Represents an audio event. A clip will be randomly selected on playback, using the specified AudioSourceSettings 10 | /// 11 | public class AudioCueAsset : ScriptableObject 12 | { 13 | #region Types 14 | 15 | [Serializable] 16 | public class AudioData : IWeightedChoice 17 | { 18 | #region Fields 19 | 20 | public AudioClip Clip; 21 | 22 | public float VolumeOffset; 23 | 24 | [SerializeField] 25 | private int _weight = 1; 26 | 27 | #endregion 28 | 29 | #region Properties 30 | 31 | /// 32 | public int Weight => _weight; 33 | 34 | #endregion 35 | } 36 | 37 | #endregion 38 | 39 | #region Fields 40 | 41 | [SerializeField] 42 | private AudioSourceSettings _settings; 43 | 44 | [SerializeField] 45 | private AudioData[] _audio; 46 | 47 | #endregion 48 | 49 | #region Properties 50 | 51 | public AudioData[] Audio => _audio; 52 | 53 | #endregion 54 | 55 | #region Methods 56 | 57 | /// 58 | /// Play cue using source. 59 | /// 60 | public AudioClip Play(AudioSource source, bool loop = false) 61 | { 62 | Assert.IsTrue(Audio.Length > 0, $"No assigned audio for {name}"); 63 | _settings.ApplyTo(source); 64 | var index = Audio.ChooseIndexFromWeighted(); 65 | Assert.IsFalse(index < 0, "index < 0"); 66 | 67 | var audio = Audio[index]; 68 | Assert.IsNotNull(audio.Clip, $"Audio entry {index} for {name} has no assigned clip"); 69 | 70 | source.volume += audio.VolumeOffset; 71 | source.loop = loop; 72 | source.clip = audio.Clip; 73 | 74 | source.Play(); 75 | return source.clip; 76 | } 77 | 78 | #endregion 79 | } 80 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/AudioCueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ea4eb27ce314064398df997147abbcf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {fileID: 2800000, guid: efbcc2716f8d12645985158672a9f81a, type: 3} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ColorValueAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Assets 4 | { 5 | /// 6 | /// Value asset representing a color. 7 | /// 8 | public class ColorValueAsset : ValueAsset { } 9 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ColorValueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47518899a6703c043a81059cd644f016 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/FloatValueAsset.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL.Assets 2 | { 3 | /// 4 | /// Value asset representing a floating point number. 5 | /// 6 | public class FloatValueAsset : ValueAsset { } 7 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/FloatValueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f171c812e569a84c81dbf2b06e05871 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/IntValueAsset.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL.Assets 2 | { 3 | /// 4 | /// Value asset representing an integer. 5 | /// 6 | public class IntValueAsset : ValueAsset { } 7 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/IntValueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23a682cfe08a6ce458af8d851e6ebb91 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ValueAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Assets 4 | { 5 | /// 6 | /// Base class for all ValueAssets. Mainly exists for referencing all ValueAssets by type. 7 | /// 8 | public abstract class ValueAsset : ScriptableObject { } 9 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ValueAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e82131eec82e49f4fa17e190a2fc237a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ValueAssetGeneric.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Attributes; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Assets 5 | { 6 | /// 7 | /// A value asset that represents a single value. 8 | /// 9 | public abstract class ValueAsset : ValueAsset 10 | { 11 | [SerializeField] 12 | private T _value; 13 | 14 | #region Fields 15 | 16 | #endregion 17 | 18 | #region Properties 19 | 20 | 21 | public virtual T Value => _value; 22 | 23 | #endregion 24 | 25 | #region Methods 26 | 27 | /// 28 | /// Implicitly converts to the asset's value. 29 | /// 30 | public static implicit operator T(ValueAsset asset) 31 | { 32 | return asset.Value; 33 | } 34 | 35 | #endregion 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Assets/ValueAssetGeneric.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cb0dcd5c8b47624bb447c6f0514ae05 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 381d118a3ea5ee94ca417b9bcfe34c74 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/InjectAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL.Attributes 4 | { 5 | /// 6 | /// For marking a field to be injected automatically 7 | /// 8 | [AttributeUsage(AttributeTargets.Property)] 9 | public sealed class InjectAttribute : Attribute { } 10 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/InjectAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc559e5911100cb49ab204bdbc39eb6d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/NoteAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Attributes 5 | { 6 | /// 7 | /// Displays a HelpBox in the Inspector. 8 | /// 9 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] 10 | public class NoteAttribute : PropertyAttribute 11 | { 12 | #region Types 13 | 14 | /// 15 | /// The type of message to display. 16 | /// 17 | public enum MessageType 18 | { 19 | #pragma warning disable 1591 20 | None, 21 | Info, 22 | Warning, 23 | Error 24 | #pragma warning restore 1591 25 | } 26 | 27 | #endregion 28 | 29 | #region Fields 30 | 31 | /// 32 | /// The text of the message. 33 | /// 34 | public readonly string Text; 35 | 36 | /// 37 | /// What type of message is displayed. 38 | /// 39 | public readonly MessageType Type; 40 | 41 | #endregion 42 | 43 | #region Constructors 44 | 45 | /// 46 | /// Display a note with no message type. 47 | /// 48 | public NoteAttribute(string note) : this(note, MessageType.None) { } 49 | 50 | /// 51 | /// Display a note with given message type. 52 | /// 53 | public NoteAttribute(string text, MessageType type) 54 | { 55 | Text = text.Replace("\n", Environment.NewLine); 56 | Type = type; 57 | } 58 | 59 | #endregion 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/NoteAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28ee5ffd3d431024ea791f4ca49e29eb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/RelativesOnlyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Attributes 5 | { 6 | /// 7 | /// Determines the source location of a valid component assignment. 8 | /// 9 | [Flags] 10 | public enum ValidRelatives 11 | { 12 | /// 13 | /// Only allow Objects on the same GameObject to be assigned. 14 | /// 15 | SameGameObject = 1 << 0, 16 | 17 | /// 18 | /// Only allow Objects that are children to be assigned. 19 | /// 20 | Children = 1 << 1, 21 | 22 | /// 23 | /// Only allow Objects that are parents to be assigned. 24 | /// 25 | Parents = 1 << 2, 26 | 27 | /// 28 | /// Allow any Object that is on the same GameObject, 29 | /// a child or a parent to be assigned. 30 | /// 31 | SameHierarchyPath = SameGameObject | Children | Parents 32 | } 33 | 34 | /// 35 | /// Restricts what can be assigned to an Object field in Unity's inspector. 36 | /// 37 | [AttributeUsage(AttributeTargets.Field)] 38 | public sealed class RelativesOnlyAttribute : PropertyAttribute 39 | { 40 | #region Properties 41 | 42 | public ValidRelatives ValidRelatives { get; } 43 | 44 | #endregion 45 | 46 | #region Constructors 47 | 48 | /// 49 | /// Restricts this field to only accept Objects that are in the same 50 | /// path in the Hierarchy as GameObject that owns this field. 51 | /// 52 | public RelativesOnlyAttribute() 53 | { 54 | ValidRelatives = ValidRelatives.SameHierarchyPath; 55 | } 56 | 57 | /// 58 | /// Restricts this field to only accept Objects that follow the rules 59 | /// set by 60 | /// 61 | public RelativesOnlyAttribute(ValidRelatives validRelatives) 62 | { 63 | ValidRelatives = validRelatives; 64 | } 65 | 66 | #endregion 67 | 68 | #region Methods 69 | 70 | /// 71 | /// Check if a rule flag is the ONLY flag set. 72 | /// 73 | /// The rule to check. 74 | /// True if only flag set, false otherwise. 75 | public bool IsOnlyRuleSet(ValidRelatives rule) 76 | { 77 | return ValidRelatives == rule; 78 | } 79 | 80 | /// 81 | /// Check if a rule flag is set. 82 | /// 83 | /// The rule to check. 84 | /// True if set, false otherwise. 85 | public bool IsRuleSet(ValidRelatives rule) 86 | { 87 | return (ValidRelatives & rule) != 0; 88 | } 89 | 90 | #endregion 91 | } 92 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/RelativesOnlyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d055ba8b70ffcd4ca46d2ae0afba3e2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/TagAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Attributes 5 | { 6 | [AttributeUsage(AttributeTargets.Field)] 7 | public sealed class TagAttribute : PropertyAttribute { } 8 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/TagAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dfaf1007b728be4aa4b422a43ce96c1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/TypeReferenceFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Field)] 6 | public sealed class TypeReferenceFilterAttribute : Attribute 7 | { 8 | #region Fields 9 | 10 | public readonly Type Type; 11 | 12 | #endregion 13 | 14 | #region Constructors 15 | 16 | public TypeReferenceFilterAttribute(Type type) 17 | { 18 | Type = type; 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Attributes/TypeReferenceFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94b4dba03265cdc4dbfcd9461bfd81e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/AudioSourceSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 876f351285dde9a4f88b945bce3191f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/CollectionSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acde1fa5fe287574e938adaea10c04b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Development.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b8c19086195ac1418b877f1802d3abb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Development/Mover.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | public class Mover : MonoBehaviour 6 | { 7 | #region Fields 8 | 9 | public Vector3 Movement; 10 | 11 | public Space MovementSpace; 12 | 13 | public Vector3 Rotation; 14 | 15 | public Space RotationSpace; 16 | 17 | public bool UseRigidbody; 18 | 19 | private Rigidbody _rigidbody; 20 | 21 | #endregion 22 | 23 | #region Methods 24 | 25 | private void Awake() 26 | { 27 | _rigidbody = GetComponent(); 28 | } 29 | 30 | private void Update() 31 | { 32 | if (UseRigidbody && _rigidbody != null) 33 | { 34 | if (MovementSpace == Space.Self) 35 | { 36 | _rigidbody.velocity = transform.TransformVector(Movement); 37 | 38 | _rigidbody.angularVelocity = 39 | transform.TransformVector(Rotation); 40 | } 41 | else 42 | { 43 | _rigidbody.velocity = Movement; 44 | _rigidbody.angularVelocity = Rotation; 45 | } 46 | } 47 | else 48 | { 49 | transform.Translate(Movement * UnityEngine.Time.deltaTime, MovementSpace); 50 | transform.Rotate(Rotation * UnityEngine.Time.deltaTime, RotationSpace); 51 | } 52 | } 53 | 54 | #endregion 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Development/Mover.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38457da766304d34daf96a2c88125814 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/DontDestroyOnLoad.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | /// 6 | /// Utility component to DontDestroyOnLoad an object on Awake 7 | /// 8 | [DisallowMultipleComponent] 9 | public class DontDestroyOnLoad : MonoBehaviour 10 | { 11 | #region Methods 12 | 13 | private void Awake() 14 | { 15 | DontDestroyOnLoad(gameObject); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/DontDestroyOnLoad.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 742a03d1ae6911f4e8803a510eb5a9de 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EmptyMonoBehaviour.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | /// 6 | /// A blank MonoBehaviour for editor utility purposes 7 | /// 8 | public sealed class EmptyMonoBehaviour : MonoBehaviour { } 9 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EmptyMonoBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81ddb8d40870e0f46a5108f9d1d3a835 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EnumData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | /// 6 | /// Statically and lazily stores information about an enum type. 7 | /// 8 | /// 9 | public static class EnumData where T : Enum 10 | { 11 | #region Fields 12 | 13 | /// 14 | /// All valid values in this type 15 | /// 16 | public static readonly T[] Values; 17 | 18 | /// 19 | /// Names of all values in the type 20 | /// 21 | public static readonly string[] Names; 22 | 23 | /// 24 | /// The actual type of this enum 25 | /// 26 | public static readonly Type Type; 27 | 28 | /// 29 | /// The actual type of this enum 30 | /// 31 | public static readonly Type UnderlyingType; 32 | 33 | /// 34 | /// Whether this enum represents a bitmask 35 | /// 36 | public static readonly bool AreFlags; 37 | 38 | #endregion 39 | 40 | #region Properties 41 | 42 | /// 43 | /// The length of valid values of this type 44 | /// 45 | public static int Count => Values.Length; 46 | 47 | #endregion 48 | 49 | #region Constructors 50 | 51 | /// 52 | /// Typechecks T and creates information about this enum type 53 | /// 54 | static EnumData() 55 | { 56 | Type = typeof(T); 57 | 58 | Values = (T[]) Enum.GetValues(Type); 59 | UnderlyingType = Enum.GetUnderlyingType(Type); 60 | Names = Enum.GetNames(Type); 61 | AreFlags = CheckIfFlags(); 62 | } 63 | 64 | #endregion 65 | 66 | #region Methods 67 | 68 | /// 69 | /// Retrieves the name for a value 70 | /// 71 | /// 72 | /// 73 | public static string GetName(T value) 74 | { 75 | return Names[Array.IndexOf(Values, value)]; 76 | } 77 | 78 | /// 79 | /// Retrieves a value by name 80 | /// 81 | /// 82 | /// 83 | public static T GetValue(string name) 84 | { 85 | return Values[Array.IndexOf(Names, name)]; 86 | } 87 | 88 | /// 89 | /// 90 | /// 91 | private static bool CheckIfFlags() 92 | { 93 | foreach (var value in Values) 94 | { 95 | if (!IsPowerOfTwo(Convert.ToInt64(value))) 96 | { 97 | return false; 98 | } 99 | } 100 | 101 | return true; 102 | } 103 | 104 | private static bool IsPowerOfTwo(long value) 105 | { 106 | return (value & (value - 1)) == 0; 107 | } 108 | 109 | #endregion 110 | } 111 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EnumData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 322cf26c5b160f74dae042bbf505bae1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28d8490fb842d554787ac4b7b8ef690d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/EventBus.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5e8d3734219d6745b957a69fd4e25ac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/EventBusObserver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | public delegate void OnEventPosted(T evtData); 6 | 7 | internal class EventBusObserver 8 | { 9 | #region Fields 10 | 11 | private readonly OnEventPosted _handler; 12 | 13 | public bool Once; 14 | 15 | protected Predicate Predicate; 16 | 17 | #endregion 18 | 19 | #region Constructors 20 | 21 | public EventBusObserver(OnEventPosted handler, Predicate predicate, bool once) 22 | { 23 | _handler = handler; 24 | Predicate = predicate; 25 | Once = once; 26 | } 27 | 28 | #endregion 29 | 30 | #region Methods 31 | 32 | public void Publish(T evtData) 33 | { 34 | if (Predicate == null || Predicate(evtData)) 35 | { 36 | _handler(evtData); 37 | } 38 | } 39 | 40 | public bool HasTarget(object target) 41 | { 42 | return _handler.Target == target; 43 | } 44 | 45 | public bool CallbackEquals(Delegate callback) 46 | { 47 | return callback.Equals(_handler); 48 | } 49 | 50 | #endregion 51 | } 52 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/EventBusObserver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d815b42c87b9404aabd682033c73c31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/EventBusProcessLimit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | [Serializable] 6 | public abstract class EventBusProcessLimit 7 | { 8 | #region Methods 9 | 10 | public abstract bool CanContinue(int processedEventCount, TimeSpan timeSpentProcessing); 11 | 12 | #endregion 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/EventBusProcessLimit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f861e63647b78fc479596c67e86831f4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/ListenerCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | internal interface IListenerCollection 7 | { 8 | #region Methods 9 | 10 | void RemoveTarget(object target); 11 | 12 | void NotifyListeners(object data); 13 | 14 | #endregion 15 | } 16 | 17 | internal class ListenerCollection : IListenerCollection 18 | { 19 | #region Fields 20 | 21 | private readonly List> _observers = 22 | new List>(); 23 | 24 | #endregion 25 | 26 | #region Methods 27 | 28 | public void Add(EventBusObserver observer) 29 | { 30 | lock (_observers) 31 | { 32 | _observers.Add(observer); 33 | } 34 | } 35 | 36 | public void Remove(Delegate callback) 37 | { 38 | RemoveWhere(observer => observer.CallbackEquals(callback)); 39 | } 40 | 41 | /// 42 | public void RemoveTarget(object target) 43 | { 44 | RemoveWhere(o => o.HasTarget(target)); 45 | } 46 | 47 | /// 48 | public void NotifyListeners(object data) 49 | { 50 | var typedData = (T) data; 51 | NotifyListeners(typedData); 52 | } 53 | 54 | private void RemoveWhere(Predicate> predicate) 55 | { 56 | for (var i = _observers.Count - 1; i >= 0; i--) 57 | { 58 | var observer = _observers[i]; 59 | if (predicate(observer)) 60 | { 61 | _observers.RemoveAt(i); 62 | } 63 | } 64 | } 65 | 66 | private void NotifyListeners(T evtData) 67 | { 68 | for (var i = _observers.Count - 1; i >= 0; i--) 69 | { 70 | var observer = _observers[i]; 71 | observer.Publish(evtData); 72 | if (observer.Once) 73 | { 74 | _observers.RemoveAt(i); 75 | } 76 | } 77 | } 78 | 79 | #endregion 80 | } 81 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/ListenerCollection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a50925f82709aab4d86929a36dd8bce1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/ParameterizedProcessLimit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | [Serializable] 6 | public class ParameterizedProcessLimit : EventBusProcessLimit 7 | { 8 | #region Fields 9 | 10 | public int MaxEventCount; 11 | 12 | public double MaxProcessingTimeMs; 13 | 14 | #endregion 15 | 16 | #region Methods 17 | 18 | /// 19 | public override bool CanContinue(int processedEventCount, TimeSpan timeSpentProcessing) 20 | { 21 | return (MaxEventCount <= 0 || processedEventCount <= MaxEventCount) 22 | && timeSpentProcessing.TotalMilliseconds <= MaxProcessingTimeMs; 23 | } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/ParameterizedProcessLimit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5de63bcee2e0b4b4cb70c189f1642fb9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/UnlimitedProcessLimit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | public class UnlimitedProcessLimit : EventBusProcessLimit 6 | { 7 | #region Methods 8 | 9 | /// 10 | public override bool CanContinue(int processedEventCount, TimeSpan timeSpentProcessing) 11 | { 12 | return true; 13 | } 14 | 15 | #endregion 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/EventBus/UnlimitedProcessLimit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e94bd702d07d3f24cb3d4f1d14c0e71a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/FilterValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | /// 7 | /// A string wrapper class for managing a search value 8 | /// 9 | public class FilterValue 10 | { 11 | #region Types 12 | 13 | public delegate void OnValueChanged(FilterValue src); 14 | 15 | #endregion 16 | 17 | #region Events 18 | 19 | public event OnValueChanged ValueChanged; 20 | 21 | #endregion 22 | 23 | #region Properties 24 | 25 | /// 26 | /// Raw input string 27 | /// 28 | public string RawValue { get; private set; } 29 | 30 | /// 31 | /// Cleaned and trimmed value string 32 | /// 33 | public string Value { get; private set; } 34 | 35 | /// 36 | /// Whitespace delimited keywords 37 | /// 38 | public string[] Keywords { get; private set; } 39 | 40 | /// 41 | /// Whether there is any filter active 42 | /// 43 | public bool HasFilter => !string.IsNullOrWhiteSpace(Value); 44 | 45 | #endregion 46 | 47 | #region Methods 48 | 49 | /// 50 | /// Does input match the current Value 51 | /// 52 | /// 53 | /// 54 | public bool MatchesValue(string input) 55 | { 56 | return !HasFilter || input.IndexOf(Value, StringComparison.OrdinalIgnoreCase) >= 0; 57 | } 58 | 59 | /// 60 | /// Does input match any or all of the whitespace delimited keywords 61 | /// 62 | /// 63 | /// 64 | /// 65 | public bool MatchesKeywords(string input, bool all) 66 | { 67 | if (!HasFilter) 68 | { 69 | return true; 70 | } 71 | 72 | foreach (var keyword in Keywords) 73 | { 74 | var isMatch = input.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) >= 0; 75 | if (all && !isMatch) 76 | { 77 | // Early out if not all match 78 | return false; 79 | } 80 | 81 | if (!all && isMatch) 82 | { 83 | // Early out if any match 84 | return true; 85 | } 86 | } 87 | 88 | // Match found if early out didn't happen 89 | return all; 90 | } 91 | 92 | /// 93 | /// Updates underlying values 94 | /// 95 | /// 96 | /// True if there was an update, false if nothing has changed 97 | public bool Update(string value) 98 | { 99 | if (RawValue != value) 100 | { 101 | RawValue = value; 102 | Value = RawValue.Trim(); 103 | Keywords = Regex.Split(Value, @"\s"); 104 | ValueChanged?.Invoke(this); 105 | return true; 106 | } 107 | 108 | return false; 109 | } 110 | 111 | #endregion 112 | } 113 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/FilterValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b01189e03bf4ed4fa4b9616968415a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Flags32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using BeardPhantom.UCL.Pooling; 4 | 5 | namespace BeardPhantom.UCL.Utility 6 | { 7 | public struct Flags32 8 | { 9 | #region Properties 10 | 11 | public int Data { get; private set; } 12 | 13 | #endregion 14 | 15 | #region Constructors 16 | 17 | public Flags32(int data) 18 | { 19 | Data = data; 20 | } 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | public bool this[int index] 27 | { 28 | get 29 | { 30 | var mask = 1 << index; 31 | return (Data & mask) == mask; 32 | } 33 | set 34 | { 35 | var mask = 1 << index; 36 | if (value) 37 | { 38 | Data |= mask; 39 | } 40 | else 41 | { 42 | Data &= ~mask; 43 | } 44 | } 45 | } 46 | 47 | public Flags32 GetRandomFlag() 48 | { 49 | var result = new Flags32(Data); 50 | var enabledFlagCount = 0; 51 | for (var i = 0; i < 32; i++) 52 | { 53 | if (result[i]) 54 | { 55 | enabledFlagCount++; 56 | } 57 | } 58 | 59 | int rng; 60 | using (var randomHandle = PocoPool.Obtain()) 61 | { 62 | rng = randomHandle.Object.Next(enabledFlagCount + 1); 63 | } 64 | 65 | for (var i = 0; i < 32; i++) 66 | { 67 | if (result[i]) 68 | { 69 | rng--; 70 | if (rng <= 0) 71 | { 72 | result.Data = 1 << i; 73 | break; 74 | } 75 | } 76 | } 77 | 78 | return result; 79 | } 80 | 81 | /// 82 | public override string ToString() 83 | { 84 | using (var stringBuilderHandle = PocoPool.Obtain()) 85 | { 86 | var stringBuilder = stringBuilderHandle.Object; 87 | for (var i = 31; i >= 0; i--) 88 | { 89 | stringBuilder.Append( 90 | this[i] 91 | ? '1' 92 | : '0'); 93 | } 94 | 95 | return stringBuilder.ToString(); 96 | } 97 | } 98 | 99 | #endregion 100 | } 101 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Flags32.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 393d158dbadcaf84eb86dfde1f5dde36 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/FloatTrailingValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | [Serializable] 8 | public sealed class FloatTrailingValue : TrailingValue 9 | { 10 | #region Types 11 | 12 | [Serializable] 13 | public struct Level 14 | { 15 | #region Fields 16 | 17 | [NonSerialized] 18 | public float Value; 19 | 20 | public float Speed; 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | public (float Value, float Speed) ToTuple() 27 | { 28 | return (Value, Speed); 29 | } 30 | 31 | #endregion 32 | } 33 | 34 | #endregion 35 | 36 | #region Fields 37 | 38 | [SerializeField] 39 | private List _levels = new List(); 40 | 41 | #endregion 42 | 43 | #region Properties 44 | 45 | /// 46 | public override int LevelCount => _levels.Count; 47 | 48 | #endregion 49 | 50 | #region Methods 51 | 52 | /// 53 | public override (float Value, float Speed) GetLevelAt(int levelIndex) 54 | { 55 | return _levels[levelIndex].ToTuple(); 56 | } 57 | 58 | /// 59 | public override void SetValueAt(int levelIndex, float value) 60 | { 61 | var level = _levels[levelIndex]; 62 | level.Value = value; 63 | _levels[levelIndex] = level; 64 | } 65 | 66 | /// 67 | public override void SetSpeedAt(int levelIndex, float speed) 68 | { 69 | var level = _levels[levelIndex]; 70 | level.Speed = speed; 71 | _levels[levelIndex] = level; 72 | } 73 | 74 | /// 75 | public override float DefaultAnimateCallback( 76 | (float Value, float Speed) level, 77 | float targetValue, 78 | float deltaTime) 79 | { 80 | (var currentValue, var speed) = level; 81 | return Mathf.Lerp(currentValue, targetValue, speed * deltaTime); 82 | } 83 | 84 | /// 85 | protected override void RemoveLevelAt(int levelIndex) 86 | { 87 | _levels.RemoveAt(levelIndex); 88 | } 89 | 90 | /// 91 | protected override void InsertNewLevel(int levelIndex) 92 | { 93 | _levels.Insert(levelIndex, new Level()); 94 | } 95 | 96 | #endregion 97 | } 98 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/FloatTrailingValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5353ed61d25c8ad4abe3c4e022161c35 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/IWeightedChoice.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL 2 | { 3 | public interface IWeightedChoice 4 | { 5 | int Weight { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/IWeightedChoice.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8f7311501ea47ccb1e2dce20ed00724 3 | timeCreated: 1571533683 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/LookAtTarget.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Serialization; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | /// 7 | /// Utility behaviour for looking at a given transform every frame. 8 | /// 9 | [ExecuteInEditMode] 10 | public class LookAtTarget : MonoBehaviour 11 | { 12 | #region Fields 13 | 14 | /// 15 | /// Target to look at. 16 | /// 17 | [SerializeField] 18 | [FormerlySerializedAs("_target")] 19 | public Transform Target; 20 | 21 | /// 22 | /// Scaler for final rotation after looking at target. 23 | /// 24 | [SerializeField] 25 | private Vector3 _amount = Vector3.one; 26 | 27 | #endregion 28 | 29 | #region Methods 30 | 31 | private void LateUpdate() 32 | { 33 | if (Target == null) 34 | { 35 | return; 36 | } 37 | 38 | transform.LookAt(Target); 39 | 40 | transform.eulerAngles = Vector3.Scale( 41 | transform.eulerAngles, 42 | _amount); 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/LookAtTarget.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b785b838ddf0d2f4a9e7f67ff6fcb1a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/NullLogHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Object = UnityEngine.Object; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | /// 8 | /// Null Object Pattern implementation of Unity's log handler. 9 | /// 10 | public class NullLogHandler : ILogHandler 11 | { 12 | #region Methods 13 | 14 | /// 15 | public void LogException(Exception exception, Object context) { } 16 | 17 | /// 18 | public void LogFormat( 19 | LogType logType, 20 | Object context, 21 | string format, 22 | params object[] args) { } 23 | 24 | #endregion 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/NullLogHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a0d28767758f41e47a5b12d86a0d0ef8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/NullLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Object = UnityEngine.Object; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | /// 8 | /// Null Object Pattern implementation of Unity's ILogger interface. 9 | /// 10 | public class NullLogger : ILogger 11 | { 12 | #region Properties 13 | 14 | /// 15 | public LogType filterLogType { get; set; } 16 | 17 | /// 18 | public bool logEnabled { get; set; } 19 | 20 | /// 21 | public ILogHandler logHandler { get; set; } 22 | 23 | #endregion 24 | 25 | #region Methods 26 | 27 | /// 28 | public bool IsLogTypeAllowed(LogType logType) 29 | { 30 | return false; 31 | } 32 | 33 | /// 34 | public void Log(LogType logType, object message) { } 35 | 36 | /// 37 | public void Log(LogType logType, object message, Object context) { } 38 | 39 | /// 40 | public void Log(LogType logType, string tag, object message) { } 41 | 42 | /// 43 | public void Log( 44 | LogType logType, 45 | string tag, 46 | object message, 47 | Object context) { } 48 | 49 | /// 50 | public void Log(object message) { } 51 | 52 | /// 53 | public void Log(string tag, object message) { } 54 | 55 | /// 56 | public void Log(string tag, object message, Object context) { } 57 | 58 | /// 59 | public void LogError(string tag, object message) { } 60 | 61 | /// 62 | public void LogError(string tag, object message, Object context) { } 63 | 64 | /// 65 | public void LogException(Exception exception, Object context) { } 66 | 67 | /// 68 | public void LogException(Exception exception) { } 69 | 70 | /// 71 | public void LogFormat( 72 | LogType logType, 73 | Object context, 74 | string format, 75 | params object[] args) { } 76 | 77 | /// 78 | public void LogFormat( 79 | LogType logType, 80 | string format, 81 | params object[] args) { } 82 | 83 | /// 84 | public void LogWarning(string tag, object message) { } 85 | 86 | /// 87 | public void LogWarning(string tag, object message, Object context) { } 88 | 89 | #endregion 90 | } 91 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/NullLogger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c7613ae0ed707e047a54d392ace90971 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/ObservedValue.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL 2 | { 3 | /// 4 | /// A value that fires a signal when its value changes. 5 | /// 6 | public class ObservedValue 7 | { 8 | #region Types 9 | 10 | public readonly struct ChangedEventArgs 11 | { 12 | #region Fields 13 | 14 | public readonly T PreviousValue; 15 | 16 | public readonly T Value; 17 | 18 | #endregion 19 | 20 | #region Constructors 21 | 22 | public ChangedEventArgs(T previousValue, T value) 23 | { 24 | PreviousValue = previousValue; 25 | Value = value; 26 | } 27 | 28 | #endregion 29 | } 30 | 31 | #endregion 32 | 33 | #region Events 34 | 35 | public event ValueEventHandler ValueChanged; 36 | 37 | #endregion 38 | 39 | #region Fields 40 | 41 | private T _value; 42 | 43 | #endregion 44 | 45 | #region Properties 46 | 47 | public T Value 48 | { 49 | get => _value; 50 | set 51 | { 52 | if (Equals(_value, value)) 53 | { 54 | return; 55 | } 56 | 57 | var previousValue = _value; 58 | _value = value; 59 | ValueChanged?.Invoke(new ChangedEventArgs(previousValue, _value)); 60 | } 61 | } 62 | 63 | #endregion 64 | 65 | #region Constructors 66 | 67 | public ObservedValue(T value = default) 68 | { 69 | _value = value; 70 | } 71 | 72 | #endregion 73 | 74 | #region Methods 75 | 76 | /// 77 | /// Implicity convert to T 78 | /// 79 | public static implicit operator T(ObservedValue t) 80 | { 81 | return t.Value; 82 | } 83 | 84 | #endregion 85 | } 86 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/ObservedValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f1fd09b5ffd07d47ac0bdd1ff1b41bb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/PanTexture.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Time; 2 | using BeardPhantom.UCL.Utility; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace BeardPhantom.UCL 7 | { 8 | /// 9 | /// Utility behaviour for panning a texture's UVs. 10 | /// 11 | public class PanTexture : MonoBehaviour 12 | { 13 | #region Fields 14 | 15 | public Vector2 Speed; 16 | 17 | public TimeMode TimeMode; 18 | 19 | private Material _material; 20 | 21 | private Vector2 _offset; 22 | 23 | #endregion 24 | 25 | #region Methods 26 | 27 | private void Awake() 28 | { 29 | var renderer = GetComponent(); 30 | if (renderer) 31 | { 32 | _material = renderer.material; 33 | return; 34 | } 35 | 36 | var rawImage = GetComponent(); 37 | if (rawImage) 38 | { 39 | _material = Instantiate(rawImage.material); 40 | rawImage.material = _material; 41 | return; 42 | } 43 | 44 | var image = GetComponent(); 45 | if (image) 46 | { 47 | _material = Instantiate(image.material); 48 | image.material = _material; 49 | } 50 | } 51 | 52 | private void OnDestroy() 53 | { 54 | Destroy(_material); 55 | } 56 | 57 | private void Update() 58 | { 59 | _offset += Speed * TimeUtility.GetCurrentTime(TimeMode); 60 | _offset.x %= 1f; 61 | _offset.y %= 1f; 62 | _material.SetTextureOffset("_MainTex", _offset); 63 | } 64 | 65 | #endregion 66 | } 67 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/PanTexture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ee74b59dc8455b4985b6e350554f158 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 812a09e8451cd2944b74082ef321ba72 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/CollectionPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Concurrent; 4 | using System.Collections.Generic; 5 | 6 | namespace BeardPhantom.UCL.Pooling 7 | { 8 | /// 9 | /// Base class for any pool of collections of type T1 10 | /// 11 | /// The collection element type 12 | /// The collection type 13 | /// The collection pool class type 14 | public abstract class CollectionPool : IDisposable, IEnumerable 15 | where T2 : IEnumerable, new() 16 | where T3 : CollectionPool, new() 17 | { 18 | #region Fields 19 | 20 | /// 21 | /// Pool of available collections 22 | /// 23 | protected static readonly ConcurrentQueue Pool = new ConcurrentQueue(); 24 | 25 | /// 26 | /// Collection resource 27 | /// 28 | public readonly T2 Collection = new T2(); 29 | 30 | #endregion 31 | 32 | #region Methods 33 | 34 | /// 35 | /// Obtain collection wrapper from pool 36 | /// 37 | public static T3 Obtain() 38 | { 39 | if (Pool.Count == 0 || Pool.TryDequeue(out var pool)) 40 | { 41 | pool = new T3(); 42 | } 43 | 44 | return pool; 45 | } 46 | 47 | /// 48 | /// Prepare collection to be returned to pool 49 | /// 50 | protected abstract void Return(); 51 | 52 | /// 53 | public void Dispose() 54 | { 55 | lock (Pool) 56 | { 57 | Return(); 58 | Pool.Enqueue((T3) this); 59 | } 60 | } 61 | 62 | /// 63 | public IEnumerator GetEnumerator() 64 | { 65 | return Collection.GetEnumerator(); 66 | } 67 | 68 | /// 69 | IEnumerator IEnumerable.GetEnumerator() 70 | { 71 | return GetEnumerator(); 72 | } 73 | 74 | /// 75 | /// 76 | public static implicit operator T2(CollectionPool pool) 77 | { 78 | return pool.Collection; 79 | } 80 | 81 | #endregion 82 | } 83 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/CollectionPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0b5722816058f3a4da946d8cc5f99171 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/DictionaryPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | /// 6 | /// Pool of Dictionaries 7 | /// 8 | public sealed class 9 | DictionaryPool : CollectionPool, Dictionary, DictionaryPool> 10 | { 11 | #region Methods 12 | 13 | /// 14 | protected override void Return() 15 | { 16 | Collection.Clear(); 17 | } 18 | 19 | #endregion 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/DictionaryPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68375b339028ee448a4590d4141d6de6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/HashSetPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | /// 6 | /// Pool of HashSets 7 | /// 8 | public class HashSetPool : CollectionPool, HashSetPool> 9 | { 10 | #region Methods 11 | 12 | /// 13 | protected override void Return() 14 | { 15 | Collection.Clear(); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/HashSetPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2880b17b426046c498892e9a14e43ff0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/ListPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | /// 6 | /// Pool of Lists 7 | /// 8 | public sealed class ListPool : CollectionPool, ListPool> 9 | { 10 | #region Methods 11 | 12 | /// 13 | protected override void Return() 14 | { 15 | Collection.Clear(); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/ListPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63302e370858d2948b28a63a94813920 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/ObjectPoolAsset.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | public class ObjectPoolAsset : ScriptableObject 6 | { 7 | #region Fields 8 | 9 | [SerializeField] 10 | private GameObject _prefab; 11 | 12 | [SerializeField] 13 | private int _initCapacity; 14 | 15 | private UnityObjectPool _pool; 16 | 17 | #endregion 18 | 19 | #region Properties 20 | 21 | public UnityObjectPool Pool 22 | { 23 | get 24 | { 25 | if (!Application.isPlaying) 26 | { 27 | return null; 28 | } 29 | 30 | if (_pool == null) 31 | { 32 | _pool = new UnityObjectPool(_prefab); 33 | _pool.EnsurePoolCount(_initCapacity); 34 | } 35 | 36 | return _pool; 37 | } 38 | } 39 | 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/ObjectPoolAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a56a54a8804890498891d2832f90efc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/PocoPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | 4 | namespace BeardPhantom.UCL.Pooling 5 | { 6 | public abstract class BasePocoPool : IDisposable 7 | where T1 : new() 8 | where T2 : BasePocoPool, new() 9 | { 10 | #region Fields 11 | 12 | /// 13 | /// Pool of available collections 14 | /// 15 | protected static readonly ConcurrentQueue Pool = new ConcurrentQueue(); 16 | 17 | /// 18 | /// Collection resource 19 | /// 20 | public readonly T1 Object = new T1(); 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | /// 27 | /// Obtain collection wrapper from pool 28 | /// 29 | public static T2 Obtain() 30 | { 31 | if (Pool.Count == 0 || Pool.TryDequeue(out var pool)) 32 | { 33 | pool = new T2(); 34 | } 35 | 36 | return pool; 37 | } 38 | 39 | /// 40 | public void Dispose() 41 | { 42 | lock (Pool) 43 | { 44 | Pool.Enqueue((T2) this); 45 | } 46 | } 47 | 48 | /// 49 | /// 50 | public static implicit operator T1(BasePocoPool pool) 51 | { 52 | return pool.Object; 53 | } 54 | 55 | #endregion 56 | } 57 | 58 | public sealed class PocoPool : BasePocoPool> where T1 : new() { } 59 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/PocoPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2ce131d84b04a541b0fd79658fbe25f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/QueuePool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | /// 6 | /// Pool of Queues 7 | /// 8 | public sealed class QueuePool : CollectionPool, QueuePool> 9 | { 10 | #region Methods 11 | 12 | /// 13 | protected override void Return() 14 | { 15 | Collection.Clear(); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/QueuePool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6c164a17c5a24c48928a544ee2d4deb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/StackPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace BeardPhantom.UCL.Pooling 4 | { 5 | /// 6 | /// Pool of Stacks 7 | /// 8 | public sealed class StackPool : CollectionPool, StackPool> 9 | { 10 | #region Methods 11 | 12 | /// 13 | protected override void Return() 14 | { 15 | Collection.Clear(); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/StackPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a30fba1715e454438ef942e2755770d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Pooling/UnityObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98f0adc42d7b6e24297878226e0e637a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f39a314648bda44c923e0161221868d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/MeshRendererSubObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | public class MeshRendererSubObject : RenderProxySubObject 7 | { 8 | #region Fields 9 | 10 | private static readonly List _sharedMaterialsBuildList = new List(); 11 | 12 | public readonly Mesh Mesh; 13 | 14 | public readonly Material[] Materials; 15 | 16 | public readonly int SubMeshCount; 17 | 18 | private readonly RenderProxyOptions _options; 19 | 20 | #endregion 21 | 22 | #region Constructors 23 | 24 | public MeshRendererSubObject(MeshRenderer renderer, RenderProxyOptions options) 25 | { 26 | _options = options; 27 | 28 | var meshFilter = renderer.GetComponent(); 29 | 30 | LocalToWorld = renderer.transform.localToWorldMatrix; 31 | 32 | Mesh = options.HasFlagFast(RenderProxyOptions.UseUniqueMeshInstance) 33 | ? Object.Instantiate(meshFilter.sharedMesh) 34 | : meshFilter.sharedMesh; 35 | 36 | try 37 | { 38 | // Copy shared materials 39 | _sharedMaterialsBuildList.Clear(); 40 | renderer.GetSharedMaterials(_sharedMaterialsBuildList); 41 | Materials = new Material[_sharedMaterialsBuildList.Count]; 42 | var useUniqueMaterials = options.HasFlagFast(RenderProxyOptions.UseUniqueMaterialInstance); 43 | for (var i = 0; i < _sharedMaterialsBuildList.Count; i++) 44 | { 45 | Materials[i] = useUniqueMaterials 46 | ? Object.Instantiate(_sharedMaterialsBuildList[i]) 47 | : _sharedMaterialsBuildList[i]; 48 | } 49 | } 50 | finally 51 | { 52 | _sharedMaterialsBuildList.Clear(); 53 | } 54 | 55 | SubMeshCount = Mesh.subMeshCount; 56 | } 57 | 58 | #endregion 59 | 60 | #region Methods 61 | 62 | /// 63 | public override void Render(Matrix4x4 transformation, int layer, Camera camera, Material overrideMaterial) 64 | { 65 | var hasOverrideMaterial = overrideMaterial != null; 66 | var finalTransformation = transformation * LocalToWorld; 67 | for (var i = 0; i < SubMeshCount; i++) 68 | { 69 | var material = hasOverrideMaterial 70 | ? overrideMaterial 71 | : Materials[i]; 72 | Graphics.DrawMesh(Mesh, finalTransformation, material, layer, camera, i); 73 | } 74 | } 75 | 76 | /// 77 | public override void Dispose() 78 | { 79 | if (_options.HasFlagFast(RenderProxyOptions.UseUniqueMaterialInstance)) 80 | { 81 | for (var i = 0; i < Materials.Length; i++) 82 | { 83 | Object.Destroy(Materials[i]); 84 | } 85 | } 86 | 87 | if (_options.HasFlagFast(RenderProxyOptions.UseUniqueMeshInstance)) 88 | { 89 | Object.Destroy(Mesh); 90 | } 91 | } 92 | 93 | #endregion 94 | } 95 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/MeshRendererSubObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63410a3df524402a86d48b92938811d2 3 | timeCreated: 1582498010 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/RenderProxy.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6400e37efb44955b4369eb8d1fc3176 3 | timeCreated: 1582496421 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/RenderProxyOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | [Flags] 6 | public enum RenderProxyOptions 7 | { 8 | UseUniqueMeshInstance = 1 << 0, 9 | UseUniqueMaterialInstance = 1 << 1, 10 | LogUnsupportedRendererTypes = 1 << 2, 11 | FindInactiveRenderers = 1 << 3, 12 | } 13 | 14 | public static class RenderProxyOptionsExtensions 15 | { 16 | #region Methods 17 | 18 | public static bool HasFlagFast(this RenderProxyOptions value, RenderProxyOptions flag) 19 | { 20 | return (value & flag) != 0; 21 | } 22 | 23 | #endregion 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/RenderProxyOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f169fe7719344f1bb47d9b0565e6876 3 | timeCreated: 1582498043 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/RenderProxySubObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | public abstract class RenderProxySubObject : IDisposable 7 | { 8 | #region Fields 9 | 10 | public Matrix4x4 LocalToWorld; 11 | 12 | #endregion 13 | 14 | #region Methods 15 | 16 | public abstract void Render(Matrix4x4 transformation, int layer, Camera camera, Material overrideMaterial); 17 | 18 | /// 19 | public abstract void Dispose(); 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/RenderProxy/RenderProxySubObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a28c290c6844e63833671fa9bd4d20c 3 | timeCreated: 1582498014 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/SceneReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using UnityEngine; 4 | using UnityEngine.SceneManagement; 5 | 6 | namespace BeardPhantom.UCL 7 | { 8 | /// 9 | /// Reference to a scene asset. 10 | /// 11 | [Serializable] 12 | public class SceneReference 13 | { 14 | #region Fields 15 | 16 | [SerializeField] 17 | [HideInInspector] 18 | private string _rawPath; 19 | 20 | #endregion 21 | 22 | #region Properties 23 | 24 | /// 25 | /// Path provided at build time. 26 | /// 27 | 28 | public string RawPath => _rawPath; 29 | 30 | #endregion 31 | 32 | #region Methods 33 | 34 | /// 35 | /// Create a scene reference from a scene struct. 36 | /// 37 | public static SceneReference Create(Scene scene) 38 | { 39 | return Create(scene.path); 40 | } 41 | 42 | /// 43 | /// Create a scene reference from a full scene path. 44 | /// 45 | public static SceneReference Create(string scenePath) 46 | { 47 | return new SceneReference 48 | { 49 | _rawPath = scenePath 50 | }; 51 | } 52 | 53 | /// 54 | /// Get a path string that can be used by SceneManager.LoadScene 55 | /// 56 | public string GetLoadablePath() 57 | { 58 | var extensionIndex = _rawPath.LastIndexOf(".unity"); 59 | var prefixLength = "Assets/".Length; 60 | return RawPath.Substring(prefixLength, extensionIndex - prefixLength); 61 | } 62 | 63 | /// 64 | /// Get just the name of the scene 65 | /// 66 | public string GetSceneName() 67 | { 68 | return Path.GetFileNameWithoutExtension(RawPath); 69 | } 70 | 71 | /// 72 | /// Get the scene build index for the scene. 73 | /// 74 | public int GetSceneBuildIndex() 75 | { 76 | return SceneUtility.GetBuildIndexByScenePath(RawPath); 77 | } 78 | 79 | /// 80 | /// Implicity get raw path 81 | /// 82 | public static implicit operator string(SceneReference scene) 83 | { 84 | return scene.RawPath; 85 | } 86 | 87 | /// 88 | /// Implicity get build index 89 | /// 90 | public static implicit operator int(SceneReference scene) 91 | { 92 | return scene.GetSceneBuildIndex(); 93 | } 94 | 95 | #endregion 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/SceneReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 748e9ddc72d30ec44b6d34b30161f232 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/SetGameObjectActiveScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | public struct SetGameObjectActiveScope : IDisposable 7 | { 8 | #region Fields 9 | 10 | private readonly GameObject _prefab; 11 | 12 | private readonly bool _desiredState; 13 | 14 | private readonly bool _wasActive; 15 | 16 | #endregion 17 | 18 | #region Constructors 19 | 20 | public SetGameObjectActiveScope(GameObject prefab, bool desiredState) 21 | { 22 | _prefab = prefab; 23 | _desiredState = desiredState; 24 | _wasActive = _prefab.activeSelf; 25 | if (_prefab.activeSelf != desiredState) 26 | { 27 | _prefab.SetActive(_desiredState); 28 | } 29 | } 30 | 31 | #endregion 32 | 33 | #region Methods 34 | 35 | /// 36 | public void Dispose() 37 | { 38 | if (_wasActive != _desiredState) 39 | { 40 | _prefab.SetActive(_wasActive); 41 | } 42 | } 43 | 44 | #endregion 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/SetGameObjectActiveScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5133d5d0d8e815e47af9d5c3e2507c68 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Time.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b26ce235866f4e4bb482fa45101e0bd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Time/TimeMode.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL.Time 2 | { 3 | /// 4 | /// An enumeration for describing how time should be measured. 5 | /// 6 | public enum TimeMode 7 | { 8 | Time, 9 | UnscaledTime, 10 | RealtimeSinceStartup, 11 | FixedTime, 12 | DeltaTime, 13 | UnscaledDeltaTime, 14 | SmoothDeltaTime, 15 | FixedDeltaTime, 16 | TimeSinceLevelLoad, 17 | One 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Time/TimeMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfaceef7521a50f4b801e36730dd9d36 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Time/TimeSlice.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL.Time 2 | { 3 | public struct TimeSlice 4 | { 5 | #region Properties 6 | 7 | public int FrameCount { get; private set; } 8 | 9 | public float RealtimeSinceStartup { get; private set; } 10 | 11 | public float Time { get; private set; } 12 | 13 | public float UnscaledTime { get; private set; } 14 | 15 | #endregion 16 | 17 | #region Methods 18 | 19 | public static TimeSlice Create() 20 | { 21 | return new TimeSlice 22 | { 23 | Time = UnityEngine.Time.time, 24 | UnscaledTime = UnityEngine.Time.unscaledTime, 25 | RealtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup, 26 | FrameCount = UnityEngine.Time.frameCount 27 | }; 28 | } 29 | 30 | #endregion 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Time/TimeSlice.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8319a08c0b97b674c935ebb5ed3c3857 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TrailingValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72244f85daf77d246bc9af93f86aeaa9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TransformElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | /// 6 | /// Used to dynamically reference properties of a transform. 7 | /// 8 | [Flags] 9 | public enum TransformElement 10 | { 11 | None = 0, 12 | Position = 1 << 0, 13 | Rotation = 1 << 1, 14 | Scale = 1 << 2, 15 | All = Position | Rotation | Scale 16 | } 17 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TransformElement.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33a828661876eec4a8f341a1f3e9f830 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TransformSettings.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | /// 6 | /// Stores the configuration of a Transform. 7 | /// 8 | public class TransformSettings 9 | { 10 | #region Properties 11 | 12 | public Vector3 LocalScale { get; } 13 | 14 | public Transform Parent { get; } 15 | 16 | public Vector3 LocalPosition { get; } 17 | 18 | public Quaternion LocalRotation { get; } 19 | 20 | public int SiblingIndex { get; } 21 | 22 | #endregion 23 | 24 | #region Constructors 25 | 26 | public TransformSettings(Transform transform) 27 | { 28 | Parent = transform.parent; 29 | SiblingIndex = transform.GetSiblingIndex(); 30 | LocalPosition = transform.localPosition; 31 | LocalRotation = transform.localRotation; 32 | LocalScale = transform.localScale; 33 | } 34 | 35 | #endregion 36 | 37 | #region Methods 38 | 39 | /// 40 | /// Apply settings to a Transform. 41 | /// 42 | public void ApplyTo(Transform transform) 43 | { 44 | transform.parent = Parent; 45 | transform.SetSiblingIndex(SiblingIndex); 46 | transform.localPosition = LocalPosition; 47 | transform.localRotation = LocalRotation; 48 | transform.localScale = LocalScale; 49 | } 50 | 51 | #endregion 52 | } 53 | 54 | /// 55 | /// Stores the configuration of a RectTransform. 56 | /// 57 | public class RectTransformSettings : TransformSettings 58 | { 59 | #region Properties 60 | 61 | public Vector3 AnchoredPosition3D { get; } 62 | 63 | public Vector2 AnchorMax { get; } 64 | 65 | public Vector2 AnchorMin { get; } 66 | 67 | public Vector2 Pivot { get; } 68 | 69 | public Vector2 SizeDelta { get; } 70 | 71 | #endregion 72 | 73 | #region Constructors 74 | 75 | public RectTransformSettings(RectTransform rect) : base(rect) 76 | { 77 | AnchoredPosition3D = rect.anchoredPosition3D; 78 | AnchorMin = rect.anchorMin; 79 | AnchorMax = rect.anchorMax; 80 | SizeDelta = rect.sizeDelta; 81 | Pivot = rect.pivot; 82 | } 83 | 84 | #endregion 85 | 86 | #region Methods 87 | 88 | /// 89 | /// Apply settings to another RectTransform 90 | /// 91 | public void ApplyTo(RectTransform rect) 92 | { 93 | base.ApplyTo(rect); 94 | rect.anchorMin = AnchorMin; 95 | rect.anchorMax = AnchorMax; 96 | rect.pivot = Pivot; 97 | rect.anchoredPosition3D = AnchoredPosition3D; 98 | rect.sizeDelta = SizeDelta; 99 | } 100 | 101 | #endregion 102 | } 103 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TransformSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7448c234f5b87b44aa3a022300887ea9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TypeReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL 5 | { 6 | /// 7 | /// A reference to a System.Type 8 | /// 9 | [Serializable] 10 | public class TypeReference 11 | { 12 | #region Fields 13 | 14 | [SerializeField] 15 | private string _typeString; 16 | 17 | private Type _type; 18 | 19 | #endregion 20 | 21 | #region Properties 22 | 23 | public Type Type 24 | { 25 | get 26 | { 27 | if (_type == null) 28 | { 29 | _type = Type.GetType(_typeString); 30 | } 31 | 32 | return _type; 33 | } 34 | } 35 | 36 | #endregion 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/TypeReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f577229e3da1b642934094e548c2080 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UCLCore.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | public delegate TResult ValueEventArgs(TArgs args) where TArgs : struct; 6 | 7 | public delegate void ValueEventHandler(TArgs args) where TArgs : struct; 8 | 9 | /// 10 | /// Centralizes logging for UCL. 11 | /// 12 | public static class UCLCore 13 | { 14 | #region Events 15 | 16 | public static event ValueEventArgs ObjectCreated = 17 | DefaultInstantiatePrefabEventHandler; 18 | 19 | #endregion 20 | 21 | #region Fields 22 | 23 | /// 24 | /// How to log from UCL classes 25 | /// 26 | public static ILogger Logger = Debug.unityLogger; 27 | 28 | #endregion 29 | 30 | #region Methods 31 | 32 | internal static GameObject Instantiate(InstantiatePrefabEventArgs args) 33 | { 34 | return ObjectCreated.Invoke(args); 35 | } 36 | 37 | private static GameObject DefaultInstantiatePrefabEventHandler(InstantiatePrefabEventArgs args) 38 | { 39 | return Object.Instantiate(args.Prefab, args.Position, args.Rotation, args.Parent); 40 | } 41 | 42 | #endregion 43 | } 44 | 45 | public struct InstantiatePrefabEventArgs 46 | { 47 | #region Fields 48 | 49 | public GameObject Prefab; 50 | 51 | public Quaternion Rotation; 52 | 53 | public Vector3 Position; 54 | 55 | public Transform Parent; 56 | 57 | #endregion 58 | 59 | #region Constructors 60 | 61 | public InstantiatePrefabEventArgs(GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) 62 | { 63 | Prefab = prefab; 64 | Position = position; 65 | Rotation = rotation; 66 | Parent = parent; 67 | } 68 | 69 | #endregion 70 | } 71 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UCLCore.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83bd8fb218c705d47bd43d10e49239c1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ab8826863dea9d44abfa3372b150709 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/InferSize.cs: -------------------------------------------------------------------------------- 1 | using BeardPhantom.UCL.Attributes; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | [ExecuteInEditMode] 8 | [RequireComponent(typeof(LayoutElement))] 9 | public class InferSize : MonoBehaviour 10 | { 11 | #region Fields 12 | 13 | public Vector2 FlexibleSizeOffset; 14 | 15 | public Vector2 MinSizeOffset; 16 | 17 | public Vector2 PreferredSizeOffset; 18 | 19 | public Vector2 RectSizeOffset; 20 | 21 | public Graphic TargetGraphic; 22 | 23 | public bool UseFlexibleSize; 24 | 25 | public bool UseMinSize; 26 | 27 | public bool UsePreferredSize; 28 | 29 | public bool UseRectSize; 30 | 31 | private LayoutElement _layout; 32 | 33 | private RectTransform _rt; 34 | 35 | #endregion 36 | 37 | #region Methods 38 | 39 | private void Awake() 40 | { 41 | _rt = GetComponent(); 42 | _layout = GetComponent(); 43 | } 44 | 45 | private void Update() 46 | { 47 | if (TargetGraphic != null) 48 | { 49 | if (UseRectSize) 50 | { 51 | _rt.SetSizeWithCurrentAnchors( 52 | RectTransform.Axis.Horizontal, 53 | TargetGraphic.rectTransform.rect.width + RectSizeOffset.x); 54 | 55 | _rt.SetSizeWithCurrentAnchors( 56 | RectTransform.Axis.Vertical, 57 | TargetGraphic.rectTransform.rect.height + RectSizeOffset.y); 58 | } 59 | 60 | if (UseMinSize) 61 | { 62 | _layout.minWidth = 63 | LayoutUtility.GetMinWidth(TargetGraphic.rectTransform) + MinSizeOffset.x; 64 | 65 | _layout.minHeight = 66 | LayoutUtility.GetMinHeight(TargetGraphic.rectTransform) + MinSizeOffset.y; 67 | } 68 | 69 | if (UsePreferredSize) 70 | { 71 | _layout.preferredWidth = 72 | LayoutUtility.GetPreferredWidth(TargetGraphic.rectTransform) + PreferredSizeOffset.x; 73 | 74 | _layout.preferredHeight = 75 | LayoutUtility.GetPreferredHeight(TargetGraphic.rectTransform) + PreferredSizeOffset.y; 76 | } 77 | 78 | if (UseFlexibleSize) 79 | { 80 | _layout.flexibleWidth = 81 | LayoutUtility.GetFlexibleWidth(TargetGraphic.rectTransform) + FlexibleSizeOffset.x; 82 | 83 | _layout.flexibleHeight = 84 | LayoutUtility.GetFlexibleHeight(TargetGraphic.rectTransform) + FlexibleSizeOffset.y; 85 | } 86 | } 87 | } 88 | 89 | #endregion 90 | } 91 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/InferSize.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a89135e207e65e0408e0357e0f69f6a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/UIHitbox.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.UI; 2 | 3 | namespace BeardPhantom.UCL 4 | { 5 | public class UIHitbox : Graphic 6 | { 7 | #region Methods 8 | 9 | protected override void OnPopulateMesh(VertexHelper vh) 10 | { 11 | vh.Clear(); 12 | } 13 | 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/UIHitbox.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76d81e220e278d74b8701a6cae61d9ba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/WorldCanvasSizer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.UI 4 | { 5 | [ExecuteInEditMode] 6 | public class WorldCanvasSizer : MonoBehaviour 7 | { 8 | #region Fields 9 | 10 | public float Meters; 11 | 12 | public Vector2 Resolution; 13 | 14 | private RectTransform _rect; 15 | 16 | #endregion 17 | 18 | #region Methods 19 | 20 | public void RefreshCanvasSize() 21 | { 22 | if (_rect != null) 23 | { 24 | _rect.sizeDelta = Resolution; 25 | var scale = Meters / Resolution.x; 26 | _rect.localScale = new Vector3(scale, scale, 1f); 27 | } 28 | } 29 | 30 | private void Awake() 31 | { 32 | _rect = GetComponent(); 33 | RefreshCanvasSize(); 34 | } 35 | 36 | private void OnValidate() 37 | { 38 | RefreshCanvasSize(); 39 | } 40 | 41 | private void Reset() 42 | { 43 | Resolution = new Vector2(1920f, 1080f); 44 | Meters = 3f; 45 | RefreshCanvasSize(); 46 | } 47 | 48 | #endregion 49 | } 50 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UI/WorldCanvasSizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da704fc9791066b4c8acef3e6a356c7b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UnityCommonLibrary.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityCommonLibrary", 3 | "references": [ 4 | "GUID:d8b63aba1907145bea998dd612889d6b" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [] 15 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/UnityCommonLibrary.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be2dec62855e20043aafc6e0ea552e7e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8608264d42a24ee42b4ca7b6e54d6e3d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/BoundsUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class BoundsUtility 6 | { 7 | #region Methods 8 | 9 | /// 10 | /// Returns true if this bounds.size >= target.size in all axes. 11 | /// 12 | /// 13 | /// 14 | /// 15 | public static bool CouldContain(this Bounds bounds, Bounds target) 16 | { 17 | var bSize = bounds.size; 18 | var tSize = target.size; 19 | 20 | return bSize.x >= tSize.x && bSize.y >= tSize.y && bSize.z >= tSize.z; 21 | } 22 | 23 | public static Vector3 RandomPointInside(this Bounds bounds) 24 | { 25 | return new Vector3 26 | { 27 | x = Random.Range(bounds.min.x, bounds.max.x), 28 | y = Random.Range(bounds.min.y, bounds.max.y), 29 | z = Random.Range(bounds.min.z, bounds.max.z) 30 | }; 31 | } 32 | 33 | #endregion 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/BoundsUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bb9856a1310fcd4d9159ec7e4552cb9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CameraUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class CameraUtility 6 | { 7 | #region Methods 8 | 9 | public static Bounds OrthographicBounds(this Camera camera) 10 | { 11 | var camHeight = camera.orthographicSize * 2f; 12 | 13 | return new Bounds( 14 | camera.transform.position, 15 | new Vector3(camHeight * camera.aspect, camHeight, 0)); 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CameraUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed85b91d40d1eb34c9688a3a28ebca13 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CollectionUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using URandom = UnityEngine.Random; 5 | 6 | namespace BeardPhantom.UCL.Utility 7 | { 8 | public static class CollectionUtility 9 | { 10 | #region Methods 11 | 12 | public static void Shuffle(this IList list) 13 | { 14 | var n = list.Count; 15 | 16 | while (n > 1) 17 | { 18 | n--; 19 | var k = URandom.Range(0, n + 1); 20 | var value = list[k]; 21 | list[k] = list[n]; 22 | list[n] = value; 23 | } 24 | } 25 | 26 | public static T Random(this IEnumerable enumerable) 27 | { 28 | if (enumerable == null) 29 | { 30 | throw new ArgumentNullException(nameof(enumerable)); 31 | } 32 | 33 | var list = enumerable as IList; 34 | 35 | if (list == null) 36 | { 37 | list = enumerable.ToList(); 38 | } 39 | 40 | return list.Count == 0 41 | ? default 42 | : list[URandom.Range(0, list.Count)]; 43 | } 44 | 45 | public static T[] Random(this IEnumerable enumerable, int count) 46 | { 47 | if (enumerable == null) 48 | { 49 | throw new ArgumentNullException(nameof(enumerable)); 50 | } 51 | 52 | var array = new T[count]; 53 | 54 | for (var i = 0; i < count; i++) 55 | { 56 | array[i] = enumerable.Random(); 57 | } 58 | 59 | return array; 60 | } 61 | 62 | public static void AddOrSet( 63 | this IDictionary dictionary, 64 | TKey key, 65 | TValue value) 66 | { 67 | if (dictionary.ContainsKey(key)) 68 | { 69 | dictionary[key] = value; 70 | } 71 | else 72 | { 73 | dictionary.Add(key, value); 74 | } 75 | } 76 | 77 | public static IEnumerable Append( 78 | this IEnumerable source, 79 | T item) 80 | { 81 | foreach (var i in source) 82 | { 83 | yield return i; 84 | } 85 | 86 | yield return item; 87 | } 88 | 89 | public static IEnumerable Prepend( 90 | this IEnumerable source, 91 | T item) 92 | { 93 | yield return item; 94 | 95 | foreach (var i in source) 96 | { 97 | yield return i; 98 | } 99 | } 100 | 101 | #endregion 102 | } 103 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CollectionUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35dfa0f9d2a08124a8bee2a16b054834 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/ComponentUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0b903e008eb4bd4bbc759cd2289b89c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CoroutineUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL.Utility 6 | { 7 | public static class CoroutineUtility 8 | { 9 | #region Fields 10 | 11 | private static readonly Dictionary _keyedRoutines = 12 | new Dictionary(); 13 | 14 | private static EmptyMonoBehaviour _surrogate; 15 | 16 | #endregion 17 | 18 | #region Properties 19 | 20 | private static EmptyMonoBehaviour Surrogate 21 | { 22 | get 23 | { 24 | EnsureSurrogate(); 25 | 26 | return _surrogate; 27 | } 28 | } 29 | 30 | #endregion 31 | 32 | #region Methods 33 | 34 | public static Coroutine StartCoroutine(IEnumerator routine) 35 | { 36 | return Surrogate.StartCoroutine(routine); 37 | } 38 | 39 | public static Coroutine StartCoroutine(string key, IEnumerator routine) 40 | { 41 | var coroutine = Surrogate.StartCoroutine(routine); 42 | _keyedRoutines.Add(key, coroutine); 43 | 44 | return coroutine; 45 | } 46 | 47 | public static void StopAllCoroutines() 48 | { 49 | Surrogate.StopAllCoroutines(); 50 | _keyedRoutines.Clear(); 51 | } 52 | 53 | public static void StopKeyedCoroutines() 54 | { 55 | foreach (var coroutine in _keyedRoutines.Values) 56 | { 57 | StopCoroutine(coroutine); 58 | } 59 | 60 | _keyedRoutines.Clear(); 61 | } 62 | 63 | public static void StopCoroutine(IEnumerator routine) 64 | { 65 | Surrogate.StopCoroutine(routine); 66 | } 67 | 68 | public static void StopCoroutine(Coroutine routine) 69 | { 70 | Surrogate.StopCoroutine(routine); 71 | } 72 | 73 | public static void StopCoroutine(string key) 74 | { 75 | Coroutine routine; 76 | 77 | if (_keyedRoutines.TryGetValue(key, out routine)) 78 | { 79 | Surrogate.StopCoroutine(routine); 80 | } 81 | } 82 | 83 | private static void EnsureSurrogate() 84 | { 85 | if (!_surrogate) 86 | { 87 | _surrogate = 88 | ComponentUtility.Create("CoroutineUtilitySurrogate"); 89 | 90 | _surrogate.hideFlags = HideFlags.NotEditable; 91 | Object.DontDestroyOnLoad(_surrogate); 92 | } 93 | } 94 | 95 | #endregion 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/CoroutineUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34f49a87d6fe8cf41854f50a8a84d7e0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/DebugUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 106a98b6591ac654bbbd98b69a572225 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/EnumUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /// 4 | /// Utility functions for enums 5 | /// 6 | public static class EnumUtility 7 | { 8 | #region Methods 9 | 10 | /// 11 | /// Returns true if all bits in B are set in A 12 | /// 13 | public static bool HasAllBits(this T a, T b) where T : Enum 14 | { 15 | var aLong = Convert.ToInt64(a); 16 | var bLong = Convert.ToInt64(b); 17 | return (aLong & bLong) == bLong; 18 | } 19 | 20 | /// 21 | /// Returns true if any bits in B are set in A 22 | /// 23 | public static bool HasAnyBits(this T a, T b) where T : Enum 24 | { 25 | var aLong = Convert.ToInt64(a); 26 | var bLong = Convert.ToInt64(b); 27 | 28 | return (aLong & bLong) != 0; 29 | } 30 | 31 | #endregion 32 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/EnumUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd4a2d1e56955c448a50887c9f46ffc6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/GameObjectUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e4a07d3aa9dcc140bcf142bc27e6a0b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/GizmosUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Utility 5 | { 6 | public static class GizmosUtility 7 | { 8 | #region Fields 9 | 10 | private static readonly Stack _gizmosColorStack = 11 | new Stack(); 12 | 13 | #endregion 14 | 15 | #region Methods 16 | 17 | public static void DrawBounds(Bounds b) 18 | { 19 | Gizmos.DrawWireCube(b.center, b.size); 20 | } 21 | 22 | public static void PushGizmosColor(Color color) 23 | { 24 | _gizmosColorStack.Push(Gizmos.color); 25 | Gizmos.color = color; 26 | } 27 | 28 | public static void PopGizmosColor() 29 | { 30 | if (_gizmosColorStack.Count > 0) 31 | { 32 | Gizmos.color = _gizmosColorStack.Pop(); 33 | } 34 | } 35 | 36 | public static void DrawArrow( 37 | Vector3 pos, 38 | Vector3 direction, 39 | float scale = 1f, 40 | float arrowHeadLength = 0.25f, 41 | float arrowHeadAngle = 20.0f) 42 | { 43 | Gizmos.DrawRay(pos, direction * scale); 44 | 45 | var right = Quaternion.LookRotation(direction) 46 | * Quaternion.Euler(0, 180 + arrowHeadAngle, 0) 47 | * new Vector3(0, 0, 1); 48 | 49 | var left = Quaternion.LookRotation(direction) 50 | * Quaternion.Euler(0, 180 - arrowHeadAngle, 0) 51 | * new Vector3(0, 0, 1); 52 | 53 | Gizmos.DrawRay(pos + direction * scale, right * arrowHeadLength * scale); 54 | Gizmos.DrawRay(pos + direction * scale, left * arrowHeadLength * scale); 55 | } 56 | 57 | #endregion 58 | } 59 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/GizmosUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 533e53cdb1c06fb4aa193b6aa3b53106 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/GradientUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class GradientUtility 6 | { 7 | #region Methods 8 | 9 | public static Gradient MakeRainbow(this Gradient g) 10 | { 11 | g.SetColors( 12 | new Color(1f, 0f, 0f), 13 | new Color(1f, 1f, 0f), 14 | new Color(0f, 1f, 0f), 15 | new Color(0f, 1f, 1f), 16 | new Color(1f, 0f, 1f)); 17 | 18 | g.alphaKeys = new[] 19 | { 20 | new GradientAlphaKey(1f, 0f) 21 | }; 22 | 23 | return g; 24 | } 25 | 26 | public static Gradient MakeMeter(this Gradient g) 27 | { 28 | g.SetColors(Color.red, Color.yellow, Color.green); 29 | 30 | g.alphaKeys = new[] 31 | { 32 | new GradientAlphaKey(1f, 0f) 33 | }; 34 | 35 | return g; 36 | } 37 | 38 | public static Gradient SetColors(this Gradient g, params Color[] colors) 39 | { 40 | var interval = 1f / (colors.Length - 1); 41 | var keys = new GradientColorKey[colors.Length]; 42 | 43 | for (var i = 0; i < colors.Length; i++) 44 | { 45 | var t = Mathf.Clamp01(i * interval); 46 | keys[i] = new GradientColorKey(colors[i], t); 47 | } 48 | 49 | g.colorKeys = keys; 50 | 51 | return g; 52 | } 53 | 54 | public static Gradient SetAlphas(this Gradient g, params float[] alphas) 55 | { 56 | var interval = 1f / (alphas.Length - 1); 57 | var keys = new GradientAlphaKey[alphas.Length]; 58 | 59 | for (var i = 0; i < alphas.Length; i++) 60 | { 61 | var t = Mathf.Clamp01(i * interval); 62 | keys[i] = new GradientAlphaKey(alphas[i], t); 63 | } 64 | 65 | g.alphaKeys = keys; 66 | 67 | return g; 68 | } 69 | 70 | #endregion 71 | } 72 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/GradientUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 309b2305bebd97d46919809caa829421 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/HashCodeUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics.CodeAnalysis; 3 | 4 | namespace BeardPhantom.UCL.Utility 5 | { 6 | /// 7 | /// Utility functions for hashcode operations. 8 | /// 9 | public static class HashCodeUtility 10 | { 11 | #region Methods 12 | 13 | /// 14 | /// Combines two hashcodes to produce a third. 15 | /// 16 | public static int CombineHashes(int hashA, int hashB) 17 | { 18 | unchecked 19 | { 20 | return ((hashA << 5) + hashA) ^ hashB; 21 | } 22 | } 23 | 24 | /// 25 | /// Combines a given hashcode with an object's hashcode to produce a third. 26 | /// 27 | public static int CombineWithObjectHashCode(this int hash, T obj) where T : class 28 | { 29 | return CombineHashes(hash, obj.GetHashCodeSafe()); 30 | } 31 | 32 | /// 33 | /// Combines a given hashcode with an object's hashcode to produce a third. 34 | /// 35 | public static int CombineWithStructHashCode(this int hash, T obj) where T : struct 36 | { 37 | return CombineHashes(hash, obj.GetHashCode()); 38 | } 39 | 40 | /// 41 | /// Combines a given hashcode with a collection of objects' hashcode to produce a new hashcode. 42 | /// 43 | public static int CombineWithObjectHashCodes(this int hash, IEnumerable collection) where T : class 44 | { 45 | foreach (var obj in collection) 46 | { 47 | hash = CombineHashes(hash, obj.GetHashCodeSafe()); 48 | } 49 | 50 | return hash; 51 | } 52 | 53 | /// 54 | /// Combines a given hashcode with a collection of objects' hashcode to produce a new hashcode. 55 | /// 56 | public static int CombineWithStructHashCodes(this int hash, IEnumerable collection) where T : struct 57 | { 58 | foreach (var obj in collection) 59 | { 60 | hash = CombineHashes(hash, obj.GetHashCode()); 61 | } 62 | 63 | return hash; 64 | } 65 | 66 | /// 67 | /// Safely returns a hashcode for a reference type object. 68 | /// 69 | [SuppressMessage("ReSharper", "MergeConditionalExpression")] 70 | public static int GetHashCodeSafe(this T obj) where T : class 71 | { 72 | return obj == null 73 | ? 0 74 | : obj.GetHashCode(); 75 | } 76 | 77 | #endregion 78 | } 79 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/HashCodeUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43a13f7dcb0ba1c41911be6de2b5efa2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/Math2DUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class Math2DUtility 6 | { 7 | #region Methods 8 | 9 | public static float AngleRaw(Transform a, Transform b) 10 | { 11 | return AngleRaw(a.position, b.position); 12 | } 13 | 14 | public static float Angle(Transform a, Transform b) 15 | { 16 | return Angle(a.position, b.position); 17 | } 18 | 19 | public static float AngleRaw(Vector2 a, Vector2 b) 20 | { 21 | var dir = b - a; 22 | 23 | return Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; 24 | } 25 | 26 | public static float Angle(Vector2 a, Vector2 b) 27 | { 28 | var angle = AngleRaw(a, b); 29 | 30 | return ToNormalized(AngleRaw(a, b)); 31 | } 32 | 33 | /// 34 | /// Returns an angle from 0...360 35 | /// 36 | /// 37 | /// 38 | public static float ToNormalized(float angle) 39 | { 40 | if (Mathf.Sign(angle) == -1f) 41 | { 42 | angle = 360f - Mathf.Abs(angle); 43 | } 44 | 45 | return angle; 46 | } 47 | 48 | public static bool IsFacingRight(float angle) 49 | { 50 | angle = ToNormalized(angle); 51 | 52 | return angle > 90 && angle < 270; 53 | } 54 | 55 | public static void LookAt2D(this Transform t, Transform other) 56 | { 57 | LookAt2D(t, other.position); 58 | } 59 | 60 | public static void LookAt2D(this Transform t, Vector2 other) 61 | { 62 | var angle = Angle(t.position, other); 63 | t.rotation = Quaternion.AngleAxis(angle, Vector3.forward); 64 | } 65 | 66 | public static void SetForward2D(this Transform t, Vector2 forward) 67 | { 68 | t.right = forward; 69 | } 70 | 71 | #endregion 72 | } 73 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/Math2DUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83a344338f24d3544a6ad68f1a27b5e6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/MathUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 337673345c3b09246a21351079de4f7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/ObjectUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class ObjectUtility 6 | { 7 | #region Methods 8 | 9 | public static void Destroy(ref Object obj) 10 | { 11 | if (obj != null) 12 | { 13 | Object.Destroy(obj); 14 | obj = null; 15 | } 16 | } 17 | 18 | public static void Destroy(params Object[] objs) 19 | { 20 | foreach (var obj in objs) 21 | { 22 | if (obj != null) 23 | { 24 | Object.Destroy(obj); 25 | } 26 | } 27 | } 28 | 29 | #endregion 30 | } 31 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/ObjectUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fba30aa7a1a876148a4ffd40126726f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/PathUtility.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class PathUtility 6 | { 7 | #region Methods 8 | 9 | public static string Combine(params string[] paths) 10 | { 11 | var path = ""; 12 | 13 | foreach (var p in paths) 14 | { 15 | path = Path.Combine(path, p); 16 | } 17 | 18 | return path; 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/PathUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a5a0e8a66938274e8beac432a8943d1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/RandomUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cd5625302724414982ed851789942cb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/RectUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class RectUtility 6 | { 7 | #region Methods 8 | 9 | public static Vector2 ClosestPointOnRect(this Rect rect, Vector2 point) 10 | { 11 | var adjusted = Vector2.zero; 12 | adjusted.x = Mathf.Clamp(point.x, rect.xMin, rect.xMax); 13 | adjusted.y = Mathf.Clamp(point.y, rect.yMin, rect.yMax); 14 | 15 | return adjusted; 16 | } 17 | 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/RectUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f34d3ed9778624e479ddf11e005d733c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/ReflectionUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | public static class ReflectionUtility 5 | { 6 | #region Methods 7 | 8 | public static FieldInfo GetFirstFieldInTypeChain(string name, Type type, BindingFlags flags) 9 | { 10 | var inspectedType = type; 11 | while (inspectedType != null) 12 | { 13 | var field = inspectedType.GetField(name, flags); 14 | if (field != null) 15 | { 16 | return field; 17 | } 18 | 19 | inspectedType = inspectedType.BaseType; 20 | } 21 | 22 | return null; 23 | } 24 | 25 | #endregion 26 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/ReflectionUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5801023a89316ad4bbbbdc418ec5518b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/RichTextUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class RichTextUtility 6 | { 7 | #region Methods 8 | 9 | public static string MakeColored(this string s, Color c) 10 | { 11 | return $"{s}"; 12 | } 13 | 14 | public static string MakeBold(this string s) 15 | { 16 | return $"{s}"; 17 | } 18 | 19 | public static string MakeItalic(this string s) 20 | { 21 | return $"{s}"; 22 | } 23 | 24 | #endregion 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/RichTextUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbd5d244588ff714882269011e939335 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/StringUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace BeardPhantom.UCL.Utility 5 | { 6 | public static class StringUtility 7 | { 8 | #region Methods 9 | 10 | public static string FormatStr(this string str, params object[] args) 11 | { 12 | return string.Format(str, args); 13 | } 14 | 15 | public static bool IsNullOrWhitespace(this string str) 16 | { 17 | if (str == null) 18 | { 19 | return true; 20 | } 21 | 22 | for (var i = 0; i < str.Length; i++) 23 | { 24 | if (!char.IsWhiteSpace(str[i])) 25 | { 26 | return false; 27 | } 28 | } 29 | 30 | return true; 31 | } 32 | 33 | public static bool ContainsIgnoreCase(this string str, string other) 34 | { 35 | return str.IndexOf(other, StringComparison.OrdinalIgnoreCase) >= 0; 36 | } 37 | 38 | public static StringBuilder AppendLineFormat( 39 | this StringBuilder builder, 40 | string format, 41 | params object[] args) 42 | { 43 | return builder.AppendLine(string.Format(format, args)); 44 | } 45 | 46 | public static StringBuilder TrimEnd(this StringBuilder sb) 47 | { 48 | if (sb == null || sb.Length == 0) 49 | { 50 | return sb; 51 | } 52 | 53 | var i = sb.Length - 1; 54 | 55 | for (; i >= 0; i--) 56 | { 57 | if (!char.IsWhiteSpace(sb[i])) 58 | { 59 | break; 60 | } 61 | } 62 | 63 | if (i < sb.Length - 1) 64 | { 65 | sb.Length = i + 1; 66 | } 67 | 68 | return sb; 69 | } 70 | 71 | #endregion 72 | } 73 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/StringUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a71e640afdeca064ebb58bb51b763f8b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/StructUtility.cs: -------------------------------------------------------------------------------- 1 | namespace BeardPhantom.UCL.Utility 2 | { 3 | public static class StructUtility 4 | { 5 | #region Methods 6 | 7 | public static bool IsDefaultValue(this T value) where T : struct 8 | { 9 | return default(T).Equals(value); 10 | } 11 | 12 | #endregion 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/StructUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2db71af49ebc0f45afce9fbf68b8681 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TextAssetUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace BeardPhantom.UCL.Utility 5 | { 6 | public static class TextAssetUtility 7 | { 8 | #region Fields 9 | 10 | private static readonly string[] _newline = 11 | { 12 | Environment.NewLine 13 | }; 14 | 15 | #endregion 16 | 17 | #region Methods 18 | 19 | public static string[] GetLines(this TextAsset asset) 20 | { 21 | return asset.text.Split( 22 | _newline, 23 | StringSplitOptions.RemoveEmptyEntries); 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TextAssetUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ec63bf16a798e844bcbc7b97e8e8e51 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TextureUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class TextureUtility 6 | { 7 | #region Methods 8 | 9 | public static float GetAspect(this Texture texture) 10 | { 11 | return (float) texture.width / texture.height; 12 | } 13 | 14 | #endregion 15 | } 16 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TextureUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abff85213e5d18141822e32f79874a7f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TimeUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BeardPhantom.UCL.Time; 3 | using UTime = UnityEngine.Time; 4 | 5 | namespace BeardPhantom.UCL.Utility 6 | { 7 | public static class TimeUtility 8 | { 9 | #region Methods 10 | 11 | public static float GetCurrentTime(TimeMode mode) 12 | { 13 | switch (mode) 14 | { 15 | case TimeMode.Time: 16 | 17 | return UTime.time; 18 | case TimeMode.UnscaledTime: 19 | 20 | return UTime.unscaledTime; 21 | case TimeMode.RealtimeSinceStartup: 22 | 23 | return UTime.realtimeSinceStartup; 24 | case TimeMode.FixedTime: 25 | 26 | return UTime.fixedTime; 27 | case TimeMode.DeltaTime: 28 | 29 | return UTime.deltaTime; 30 | case TimeMode.UnscaledDeltaTime: 31 | 32 | return UTime.unscaledDeltaTime; 33 | case TimeMode.SmoothDeltaTime: 34 | 35 | return UTime.smoothDeltaTime; 36 | case TimeMode.FixedDeltaTime: 37 | 38 | return UTime.fixedDeltaTime; 39 | case TimeMode.TimeSinceLevelLoad: 40 | 41 | return UTime.timeSinceLevelLoad; 42 | case TimeMode.One: 43 | 44 | return 1f; 45 | default: 46 | 47 | throw new Exception("Invalid TimeMode"); 48 | } 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TimeUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26714b18c61aa804eb9c9f24245a7c7c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TransformUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class TransformUtility 6 | { 7 | #region Methods 8 | 9 | public static void Reset(this Transform t) 10 | { 11 | Reset(t, TransformElement.All, Space.World); 12 | } 13 | 14 | public static void Reset(this Transform t, TransformElement elements) 15 | { 16 | Reset(t, elements, Space.World); 17 | } 18 | 19 | public static void Reset(this Transform t, Space space) 20 | { 21 | Reset(t, TransformElement.All, space); 22 | } 23 | 24 | public static void Reset( 25 | this Transform t, 26 | TransformElement elements, 27 | Space space) 28 | { 29 | if ((elements & TransformElement.Position) != 0) 30 | { 31 | if (space == Space.World) 32 | { 33 | t.position = Vector3.zero; 34 | } 35 | else 36 | { 37 | t.localPosition = Vector3.zero; 38 | } 39 | } 40 | 41 | if ((elements & TransformElement.Rotation) != 0) 42 | { 43 | if (space == Space.World) 44 | { 45 | t.rotation = Quaternion.identity; 46 | } 47 | else 48 | { 49 | t.localRotation = Quaternion.identity; 50 | } 51 | } 52 | 53 | if ((elements & TransformElement.Scale) != 0) 54 | { 55 | t.localScale = Vector3.one; 56 | } 57 | } 58 | 59 | public static void Match( 60 | this Transform t, 61 | Transform other, 62 | TransformElement elements) 63 | { 64 | if ((elements & TransformElement.Position) != 0) 65 | { 66 | t.position = other.position; 67 | } 68 | 69 | if ((elements & TransformElement.Rotation) != 0) 70 | { 71 | t.rotation = other.rotation; 72 | } 73 | 74 | if ((elements & TransformElement.Scale) != 0) 75 | { 76 | t.localScale = other.localScale; 77 | } 78 | } 79 | 80 | public static Vector3 DirectionTo(this Transform t, Transform other) 81 | { 82 | return (other.position - t.position).normalized; 83 | } 84 | 85 | public static Vector3 DirectionTo(this Transform t, Vector3 other) 86 | { 87 | return (other - t.position).normalized; 88 | } 89 | 90 | public static Vector3 DirectionTo(this Vector3 v, Vector3 other) 91 | { 92 | return (other - v).normalized; 93 | } 94 | 95 | public static Vector3 DirectionTo(this Vector3 v, Transform other) 96 | { 97 | return (other.position - v).normalized; 98 | } 99 | 100 | #endregion 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TransformUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32c2cd8d3e8a916469bd7cb5ef10f207 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TrigUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace BeardPhantom.UCL.Utility 4 | { 5 | public static class TrigUtility 6 | { 7 | #region Methods 8 | 9 | public static float NormalizeAngle(float x, float a, float b) 10 | { 11 | var width = b - a; 12 | var offsetValue = x - a; 13 | 14 | return offsetValue - Mathf.Floor(offsetValue / width) * width + a; 15 | } 16 | 17 | public static float NormalizeAngle(float x) 18 | { 19 | return NormalizeAngle(x, 0f, 360f); 20 | } 21 | 22 | public static bool IsBetweenAngles(float x, float a, float b) 23 | { 24 | a = NormalizeAngle(a); 25 | b = NormalizeAngle(b); 26 | x = NormalizeAngle(x); 27 | 28 | var aB = Mathf.Abs(Mathf.DeltaAngle(a, b)); 29 | 30 | if (aB == 180f) 31 | { 32 | return x <= 180f; 33 | } 34 | 35 | var xA = Mathf.Abs(Mathf.DeltaAngle(x, a)); 36 | var xB = Mathf.Abs(Mathf.DeltaAngle(x, b)); 37 | 38 | return Mathf.Max(xA, xB) <= aB; 39 | } 40 | 41 | public static Vector2 DirectionFromAngle2D(float degrees) 42 | { 43 | return new Vector2( 44 | Mathf.Cos(degrees * Mathf.Deg2Rad), 45 | Mathf.Sin(degrees * Mathf.Deg2Rad)); 46 | } 47 | 48 | public static Vector3 DirectionFromAngle(float degrees) 49 | { 50 | return new Vector3( 51 | Mathf.Sin(degrees * Mathf.Deg2Rad), 52 | 0f, 53 | Mathf.Cos(degrees * Mathf.Deg2Rad)); 54 | } 55 | 56 | #endregion 57 | } 58 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TrigUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0388e2da435f364681d04f869713ad5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TypeUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace BeardPhantom.UCL.Utility 6 | { 7 | public static class TypeUtility 8 | { 9 | #region Methods 10 | 11 | public static Type[] GetTypesSafe(this Assembly asm) 12 | { 13 | Type[] types; 14 | try 15 | { 16 | types = asm.GetTypes(); 17 | } 18 | catch (ReflectionTypeLoadException e) 19 | { 20 | types = e.Types.Where(t => t != null).ToArray(); 21 | } 22 | 23 | return types; 24 | } 25 | 26 | public static bool InheritsFrom(this Type subtype, Type parentType) 27 | { 28 | return parentType.IsAssignableFrom(subtype); 29 | } 30 | 31 | public static T GetCustomAttribute(this Type type, bool inherit) 32 | where T : Attribute 33 | { 34 | var attributes = type.GetCustomAttributes(typeof(T), inherit); 35 | 36 | if (attributes.Length > 0) 37 | { 38 | return (T) attributes[0]; 39 | } 40 | 41 | return null; 42 | } 43 | 44 | public static T[] GetCustomAttributes(this Type type, bool inherit) 45 | where T : Attribute 46 | { 47 | return type.GetCustomAttributes(typeof(T), inherit) 48 | .Cast() 49 | .ToArray(); 50 | } 51 | 52 | #endregion 53 | } 54 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/TypeUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5122fd2ea7d5ed143adfbad84184e74f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/UIUtility.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Events; 3 | using UnityEngine.EventSystems; 4 | 5 | namespace BeardPhantom.UCL.Utility 6 | { 7 | public static class UIUtility 8 | { 9 | #region Methods 10 | 11 | public static void SetVisible(this CanvasGroup group, bool active) 12 | { 13 | if (!group.gameObject.activeSelf && active) 14 | { 15 | group.gameObject.SetActive(true); 16 | } 17 | 18 | group.alpha = active 19 | ? 1f 20 | : 0f; 21 | group.blocksRaycasts = active; 22 | } 23 | 24 | public static void SetPivot(this RectTransform rectTransform, Vector2 pivot) 25 | { 26 | var center = rectTransform.GetWorldCenter(); 27 | rectTransform.pivot = pivot; 28 | Vector3 offset = center - rectTransform.GetWorldCenter(); 29 | rectTransform.position += offset; 30 | } 31 | 32 | public static void SetAnchors(this RectTransform rectTransform, Vector2 anchor) 33 | { 34 | rectTransform.anchorMin = anchor; 35 | rectTransform.anchorMax = anchor; 36 | } 37 | 38 | public static void SetAnchors(this RectTransform rectTransform, Vector2 min, Vector2 max) 39 | { 40 | rectTransform.anchorMin = min; 41 | rectTransform.anchorMax = max; 42 | } 43 | 44 | public static void SetToFill(this RectTransform rectTransform) 45 | { 46 | rectTransform.anchorMin = Vector2.zero; 47 | rectTransform.anchorMax = Vector2.one; 48 | rectTransform.sizeDelta = Vector2.zero; 49 | } 50 | 51 | public static Vector2 GetWorldCenter(this RectTransform rectTransform) 52 | { 53 | return rectTransform.TransformPoint(rectTransform.rect.center); 54 | } 55 | 56 | public static Rect GetWorldRect(this RectTransform rectTransform) 57 | { 58 | return new Rect( 59 | rectTransform.TransformPoint(rectTransform.rect.min), 60 | rectTransform.rect.size); 61 | } 62 | 63 | public static void AddCallback( 64 | this EventTrigger evt, 65 | EventTriggerType eventId, 66 | UnityAction callback) 67 | { 68 | var triggerEvt = new EventTrigger.TriggerEvent(); 69 | triggerEvt.AddListener(callback); 70 | evt.triggers.Add( 71 | new EventTrigger.Entry 72 | { 73 | callback = triggerEvt, 74 | eventID = eventId 75 | }); 76 | } 77 | 78 | #endregion 79 | } 80 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/UIUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a1641d78245ac84eb0ddbf4cdd3aac3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/WeightedChoiceUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BeardPhantom.UCL.Utility 5 | { 6 | public static class WeightedChoiceUtility 7 | { 8 | #region Fields 9 | 10 | public static readonly Random Rng = new Random(); 11 | 12 | #endregion 13 | 14 | #region Methods 15 | 16 | public static T ChooseFromWeighted(this IReadOnlyList choices) where T : IWeightedChoice 17 | { 18 | var index = ChooseIndexFromWeighted(choices); 19 | return index < 0 ? default : choices[index]; 20 | } 21 | 22 | public static int ChooseIndexFromWeighted(this IReadOnlyList choices) where T : IWeightedChoice 23 | { 24 | var weightSum = 0; 25 | for (var i = 0; i < choices.Count; i++) 26 | { 27 | weightSum += choices[i].Weight; 28 | } 29 | 30 | var rng = Rng.Next(0, weightSum); 31 | for (var i = 0; i < choices.Count; i++) 32 | { 33 | var choice = choices[i]; 34 | if (rng < choice.Weight) 35 | { 36 | return i; 37 | } 38 | 39 | rng -= choice.Weight; 40 | } 41 | 42 | return -1; 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Utilities/WeightedChoiceUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c0a5eff44ce45b582aebef58f0d1c98 3 | timeCreated: 1571533931 -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Vector2TrailingValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | [Serializable] 8 | public class Vector2TrailingValue : TrailingValue 9 | { 10 | #region Types 11 | 12 | [Serializable] 13 | public struct Level 14 | { 15 | #region Fields 16 | 17 | [NonSerialized] 18 | public Vector2 Value; 19 | 20 | public Vector2 Speed; 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | public (Vector2 Value, Vector2 Speed) ToTuple() 27 | { 28 | return (Value, Speed); 29 | } 30 | 31 | #endregion 32 | } 33 | 34 | #endregion 35 | 36 | #region Fields 37 | 38 | [SerializeField] 39 | private List _levels = new List(); 40 | 41 | #endregion 42 | 43 | #region Properties 44 | 45 | /// 46 | public override int LevelCount => _levels.Count; 47 | 48 | #endregion 49 | 50 | #region Methods 51 | 52 | /// 53 | public override (Vector2 Value, Vector2 Speed) GetLevelAt(int levelIndex) 54 | { 55 | return _levels[levelIndex].ToTuple(); 56 | } 57 | 58 | /// 59 | public override void SetValueAt(int levelIndex, Vector2 value) 60 | { 61 | var level = _levels[levelIndex]; 62 | level.Value = value; 63 | _levels[levelIndex] = level; 64 | } 65 | 66 | /// 67 | public override void SetSpeedAt(int levelIndex, Vector2 speed) 68 | { 69 | var level = _levels[levelIndex]; 70 | level.Speed = speed; 71 | _levels[levelIndex] = level; 72 | } 73 | 74 | /// 75 | public override Vector2 DefaultAnimateCallback( 76 | (Vector2 Value, Vector2 Speed) level, 77 | Vector2 targetValue, 78 | float deltaTime) 79 | { 80 | (var currentValue, var speed) = level; 81 | return new Vector2 82 | { 83 | x = Mathf.Lerp(currentValue.x, targetValue.x, speed.x * deltaTime), 84 | y = Mathf.Lerp(currentValue.y, targetValue.y, speed.y * deltaTime) 85 | }; 86 | } 87 | 88 | /// 89 | protected override void RemoveLevelAt(int levelIndex) 90 | { 91 | _levels.RemoveAt(levelIndex); 92 | } 93 | 94 | /// 95 | protected override void InsertNewLevel(int levelIndex) 96 | { 97 | _levels.Insert(levelIndex, new Level()); 98 | } 99 | 100 | #endregion 101 | } 102 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Vector2TrailingValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 952eecf7b5d94e942a5fe002f1c0695c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Vector3TrailingValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace BeardPhantom.UCL 6 | { 7 | [Serializable] 8 | public sealed class Vector3TrailingValue : TrailingValue 9 | { 10 | #region Types 11 | 12 | [Serializable] 13 | public struct Level 14 | { 15 | #region Fields 16 | 17 | [NonSerialized] 18 | public Vector3 Value; 19 | 20 | public Vector3 Speed; 21 | 22 | #endregion 23 | 24 | #region Methods 25 | 26 | public (Vector3 Value, Vector3 Speed) ToTuple() 27 | { 28 | return (Value, Speed); 29 | } 30 | 31 | #endregion 32 | } 33 | 34 | #endregion 35 | 36 | #region Fields 37 | 38 | [SerializeField] 39 | private List _levels = new List(); 40 | 41 | #endregion 42 | 43 | #region Properties 44 | 45 | /// 46 | public override int LevelCount => _levels.Count; 47 | 48 | #endregion 49 | 50 | #region Methods 51 | 52 | /// 53 | public override (Vector3 Value, Vector3 Speed) GetLevelAt(int levelIndex) 54 | { 55 | return _levels[levelIndex].ToTuple(); 56 | } 57 | 58 | /// 59 | public override void SetValueAt(int levelIndex, Vector3 value) 60 | { 61 | var level = _levels[levelIndex]; 62 | level.Value = value; 63 | _levels[levelIndex] = level; 64 | } 65 | 66 | /// 67 | public override void SetSpeedAt(int levelIndex, Vector3 speed) 68 | { 69 | var level = _levels[levelIndex]; 70 | level.Speed = speed; 71 | _levels[levelIndex] = level; 72 | } 73 | 74 | /// 75 | public override Vector3 DefaultAnimateCallback( 76 | (Vector3 Value, Vector3 Speed) level, 77 | Vector3 targetValue, 78 | float deltaTime) 79 | { 80 | (var currentValue, var speed) = level; 81 | return new Vector3 82 | { 83 | x = Mathf.Lerp(currentValue.x, targetValue.x, speed.x * deltaTime), 84 | y = Mathf.Lerp(currentValue.y, targetValue.y, speed.y * deltaTime), 85 | z = Mathf.Lerp(currentValue.z, targetValue.z, speed.z * deltaTime) 86 | }; 87 | } 88 | 89 | /// 90 | protected override void RemoveLevelAt(int levelIndex) 91 | { 92 | _levels.RemoveAt(levelIndex); 93 | } 94 | 95 | /// 96 | protected override void InsertNewLevel(int levelIndex) 97 | { 98 | _levels.Insert(levelIndex, new Level()); 99 | } 100 | 101 | #endregion 102 | } 103 | } -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/Runtime/Vector3TrailingValue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2062d48a6fb3b0c46b5eb6c99534c537 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.beardphantom.unitycommonlibrary", 3 | "displayName": "UnityCommonLibrary", 4 | "version": "7.0.1", 5 | "unity": "2019.3", 6 | "description": "", 7 | "keywords": [ 8 | "UnityCommonLibrary", 9 | "UCL" 10 | ], 11 | "category": "Miscellaneous", 12 | "dependencies": 13 | { 14 | "com.unity.ugui": "1.0.0", 15 | "com.unity.mathematics": "1.0.1" 16 | }, 17 | "src": "Assets/", 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/thebeardphantom/UnityCommonLibrary.git#upm" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/com.beardphantom.unitycommonlibrary/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78edd7b55e2bf3747a925388f92ac768 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.ide.visualstudio": "2.0.2", 4 | "com.unity.mathematics": "1.1.0", 5 | "com.unity.test-framework": "1.1.14", 6 | "com.unity.ugui": "1.0.0", 7 | "com.unity.modules.ai": "1.0.0", 8 | "com.unity.modules.androidjni": "1.0.0", 9 | "com.unity.modules.animation": "1.0.0", 10 | "com.unity.modules.assetbundle": "1.0.0", 11 | "com.unity.modules.audio": "1.0.0", 12 | "com.unity.modules.cloth": "1.0.0", 13 | "com.unity.modules.director": "1.0.0", 14 | "com.unity.modules.imageconversion": "1.0.0", 15 | "com.unity.modules.imgui": "1.0.0", 16 | "com.unity.modules.jsonserialize": "1.0.0", 17 | "com.unity.modules.particlesystem": "1.0.0", 18 | "com.unity.modules.physics": "1.0.0", 19 | "com.unity.modules.physics2d": "1.0.0", 20 | "com.unity.modules.screencapture": "1.0.0", 21 | "com.unity.modules.terrain": "1.0.0", 22 | "com.unity.modules.terrainphysics": "1.0.0", 23 | "com.unity.modules.tilemap": "1.0.0", 24 | "com.unity.modules.ui": "1.0.0", 25 | "com.unity.modules.uielements": "1.0.0", 26 | "com.unity.modules.umbra": "1.0.0", 27 | "com.unity.modules.unityanalytics": "1.0.0", 28 | "com.unity.modules.unitywebrequest": "1.0.0", 29 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 30 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 31 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 32 | "com.unity.modules.unitywebrequestwww": "1.0.0", 33 | "com.unity.modules.vehicles": "1.0.0", 34 | "com.unity.modules.video": "1.0.0", 35 | "com.unity.modules.vr": "1.0.0", 36 | "com.unity.modules.wind": "1.0.0", 37 | "com.unity.modules.xr": "1.0.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.1.0b12 2 | m_EditorVersionWithRevision: 2020.1.0b12 (9e6726e6ce12) 3 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | lightmappingDeviceAndPlatform: 9 | value: 53 10 | flags: 0 11 | vcSharedLogLevel: 12 | value: 0d5e400f0650 13 | flags: 0 14 | m_VCAutomaticAdd: 1 15 | m_VCDebugCom: 0 16 | m_VCDebugCmd: 0 17 | m_VCDebugOut: 0 18 | m_SemanticMergeMode: 2 19 | m_VCShowFailedCheckout: 1 20 | m_VCOverwriteFailedCheckoutAssets: 1 21 | m_VCOverlayIcons: 1 22 | m_VCAllowAsyncUpdate: 0 23 | --------------------------------------------------------------------------------