├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .releaserc.json ├── Assets ├── .DS_Store ├── Adrenak.Unex.meta └── Adrenak.Unex │ ├── CHANGELOG.md │ ├── CHANGELOG.md.meta │ ├── Editor.meta │ ├── Editor │ ├── Adrenak.Unex.Editor.asmdef │ ├── Adrenak.Unex.Editor.asmdef.meta │ ├── Hotkeys.cs │ ├── Hotkeys.cs.meta │ ├── LogCatWindow.cs │ └── LogCatWindow.cs.meta │ ├── LICENSE.md │ ├── LICENSE.md.meta │ ├── README.md │ ├── README.md.meta │ ├── Runtime.meta │ ├── Runtime │ ├── Adrenak.Unex.Runtime.asmdef │ ├── Adrenak.Unex.Runtime.asmdef.meta │ ├── Extensions.meta │ ├── Extensions │ │ ├── CSharpExtensions.cs │ │ ├── CSharpExtensions.cs.meta │ │ ├── UnityAPIExtensions.cs │ │ └── UnityAPIExtensions.cs.meta │ ├── UnexInitializer.cs │ ├── UnexInitializer.cs.meta │ ├── Utils.meta │ └── Utils │ │ ├── Dispatcher.cs │ │ ├── Dispatcher.cs.meta │ │ ├── FPSDisplay.cs │ │ ├── FPSDisplay.cs.meta │ │ ├── Monitor.cs │ │ ├── Monitor.cs.meta │ │ ├── MonoSingleton.cs │ │ ├── MonoSingleton.cs.meta │ │ ├── Parallel.cs │ │ ├── Parallel.cs.meta │ │ ├── Pool.cs │ │ ├── Pool.cs.meta │ │ ├── Runnable.cs │ │ ├── Runnable.cs.meta │ │ ├── ScreenX.cs │ │ ├── ScreenX.cs.meta │ │ ├── TaskGroup.cs │ │ ├── TaskGroup.cs.meta │ │ ├── TaskX.cs │ │ ├── TaskX.cs.meta │ │ ├── Texture32.cs │ │ └── Texture32.cs.meta │ ├── Samples.meta │ ├── Samples │ ├── Adrenak.Unex.Samples.asmdef │ ├── Adrenak.Unex.Samples.asmdef.meta │ ├── Materials.meta │ ├── Materials │ │ ├── Blue.mat │ │ ├── Blue.mat.meta │ │ ├── Maroon.mat │ │ └── Maroon.mat.meta │ ├── Monitor.meta │ ├── Monitor │ │ ├── MonitorDemo.cs │ │ ├── MonitorDemo.cs.meta │ │ ├── MonitorDemo.unity │ │ └── MonitorDemo.unity.meta │ ├── Pool.meta │ ├── Pool │ │ ├── PoolDemo.cs │ │ ├── PoolDemo.cs.meta │ │ ├── PoolDemo.unity │ │ └── PoolDemo.unity.meta │ ├── Prefabs.meta │ └── Prefabs │ │ ├── Cube.prefab │ │ └── Cube.prefab.meta │ ├── package.json │ └── package.json.meta ├── Packages └── manifest.json └── ProjectSettings ├── AudioManager.asset ├── AudioManager.asset.meta ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── DynamicsManager.asset.meta ├── EditorBuildSettings.asset ├── EditorBuildSettings.asset.meta ├── EditorSettings.asset ├── EditorSettings.asset.meta ├── GraphicsSettings.asset ├── GraphicsSettings.asset.meta ├── InputManager.asset ├── InputManager.asset.meta ├── NavMeshAreas.asset ├── NavMeshAreas.asset.meta ├── NetworkManager.asset ├── NetworkManager.asset.meta ├── Physics2DSettings.asset ├── Physics2DSettings.asset.meta ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── ProjectVersion.txt.meta ├── QualitySettings.asset ├── QualitySettings.asset.meta ├── TagManager.asset ├── TagManager.asset.meta ├── TimeManager.asset ├── TimeManager.asset.meta ├── UnityConnectSettings.asset └── VFXManager.asset /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | release: 8 | name: Release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | fetch-depth: 0 14 | 15 | 16 | 17 | - name: Semantic Release 18 | id: semantic 19 | uses: cycjimmy/semantic-release-action@v2.1.3 20 | with: 21 | extra_plugins: | 22 | @semantic-release/changelog 23 | @semantic-release/git 24 | branch: master 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | 28 | 29 | - name: Create UPM branch 30 | run: | 31 | git branch -d upm &> /dev/null || echo upm branch not found 32 | git subtree split -P "$PKG_ROOT" -b upm 33 | git checkout upm 34 | if [[ -d "Samples" ]]; then 35 | git mv Samples Samples~ 36 | rm -f Samples.meta 37 | git config --global user.name 'github-bot' 38 | git config --global user.email 'github-bot@users.noreply.github.com' 39 | git commit -am "fix: Samples => Samples~" 40 | fi 41 | git push -f -u origin upm 42 | env: 43 | PKG_ROOT: "Assets/Adrenak.Unex" 44 | 45 | 46 | - name: Create upm git tag 47 | if: steps.semantic.outputs.new_release_published == 'true' 48 | run: | 49 | git tag $TAG upm 50 | git push origin --tags 51 | env: 52 | TAG: upm/v${{ steps.semantic.outputs.new_release_version }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | [Ll]ibrary/ 124 | [Tt]emp/ 125 | [Oo]bj/ 126 | [Bb]uild/ 127 | [Bb]uilds/ 128 | Assets/AssetStoreTools* 129 | 130 | # Visual Studio cache directory 131 | .vs/ 132 | 133 | # Autogenerated VS/MD/Consulo solution and project files 134 | ExportedObj/ 135 | .consulo/ 136 | *.csproj 137 | *.unityproj 138 | *.sln 139 | *.suo 140 | *.tmp 141 | *.user 142 | *.userprefs 143 | *.pidb 144 | *.booproj 145 | *.svd 146 | *.pdb 147 | *.opendb 148 | 149 | # Unity3D generated meta files 150 | *.pidb.meta 151 | *.pdb.meta 152 | 153 | # Unity3D Generated File On Crash Reports 154 | sysinfo.txt 155 | 156 | # Builds 157 | *.apk 158 | *.unitypackage 159 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tagFormat": "v${version}", 3 | "plugins": [ 4 | ["@semantic-release/commit-analyzer", { "preset": "angular" }], 5 | "@semantic-release/release-notes-generator", 6 | ["@semantic-release/changelog", { 7 | "preset": "angular", 8 | "changelogFile":"Assets/Adrenak.Unex/CHANGELOG.md" 9 | }], 10 | ["@semantic-release/npm", { 11 | "npmPublish": false, 12 | "pkgRoot":"Assets/Adrenak.Unex/" 13 | }], 14 | ["@semantic-release/git", { 15 | "assets": ["Assets/Adrenak.Unex/package.json", "Assets/Adrenak.Unex/CHANGELOG.md"], 16 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 17 | }], 18 | "@semantic-release/github" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /Assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/.DS_Store -------------------------------------------------------------------------------- /Assets/Adrenak.Unex.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e90f1de352f565d4280c25d0aeb7e019 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [2.5.0](https://github.com/adrenak/unex/compare/v2.4.0...v2.5.0) (2021-01-04) 2 | 3 | 4 | ### Features 5 | 6 | * Upgrade to Unity 2018.4.30f1 ([73bd2f3](https://github.com/adrenak/unex/commit/73bd2f33c98d0df3b96b046f8e40cf7769844878)) 7 | 8 | # [2.4.0](https://github.com/adrenak/unex/compare/v2.3.0...v2.4.0) (2020-11-21) 9 | 10 | 11 | ### Features 12 | 13 | * Remove Runner and make some minor changes to code ([7d9d71b](https://github.com/adrenak/unex/commit/7d9d71bcc6b74112f8eb386d74303fa9ef54e16e)) 14 | 15 | # [2.3.0](https://github.com/adrenak/unex/compare/v2.2.0...v2.3.0) (2020-08-10) 16 | 17 | 18 | ### Features 19 | 20 | * Add TaskGroup ([c4c4ec4](https://github.com/adrenak/unex/commit/c4c4ec4c5e7470690b059092aef93979bcfd3215)) 21 | 22 | # [2.2.0](https://github.com/adrenak/Unex/compare/v2.1.0...v2.2.0) (2020-04-07) 23 | 24 | 25 | ### Features 26 | 27 | * Add Runnable and ImageAspectRatioFitter ([dd671e7](https://github.com/adrenak/Unex/commit/dd671e79cdc488591ec48b6781d062b7d49ed206)) 28 | 29 | # [2.1.0](https://github.com/adrenak/Unex/compare/v2.0.2...v2.1.0) (2020-04-07) 30 | 31 | 32 | ### Features 33 | 34 | * Add UI Layout rebuild extension method ([963451d](https://github.com/adrenak/Unex/commit/963451d137cf9f955759d47800d6d28925c8a373)) 35 | 36 | ## [2.0.2](https://github.com/adrenak/Unex/compare/v2.0.1...v2.0.2) (2020-04-05) 37 | 38 | 39 | ### Bug Fixes 40 | 41 | * Project reorg ([83893b2](https://github.com/adrenak/Unex/commit/83893b2bc7e6ef92dad2c47375166a2fae971462)) 42 | 43 | ## [2.0.1](https://github.com/adrenak/Unex/compare/v2.0.0...v2.0.1) (2020-03-24) 44 | 45 | 46 | ### Bug Fixes 47 | 48 | * Move editor scripts under a new asmdef ([76ea2c9](https://github.com/adrenak/Unex/commit/76ea2c99b4f338ab82d28620d805778e10af72aa)) 49 | 50 | # [2.0.0](https://github.com/adrenak/Unex/compare/v1.3.0...v2.0.0) (2020-03-12) 51 | 52 | 53 | ### Features 54 | 55 | * Improved Runner.cs ([9a65e02](https://github.com/adrenak/Unex/commit/9a65e02a42fba8d88c2c51cafee174af4665129e)) 56 | 57 | 58 | ### BREAKING CHANGES 59 | 60 | * Runner class has breaking changes 61 | 62 | # [1.3.0](https://github.com/adrenak/Unex/compare/v1.2.0...v1.3.0) (2020-03-12) 63 | 64 | 65 | ### Features 66 | 67 | * Add utils for Task and Screen classes ([b43f593](https://github.com/adrenak/Unex/commit/b43f593079f2fb60e22aa0ca632e87d44a91b2af)) 68 | 69 | # [1.2.0](https://github.com/adrenak/Unex/compare/v1.1.0...v1.2.0) (2020-03-12) 70 | 71 | 72 | ### Features 73 | 74 | * Add some List extension methods to make working with last elements easier ([e31cd24](https://github.com/adrenak/Unex/commit/e31cd24b05739a8d9e073960dfc2ff74ecd5c16b)) 75 | 76 | # [1.1.0](https://github.com/adrenak/Unex/compare/v1.0.1...v1.1.0) (2020-03-10) 77 | 78 | 79 | ### Features 80 | 81 | * Plugins not included any more. Demos moved to Runtime folder ([0de560f](https://github.com/adrenak/Unex/commit/0de560f6fc70ca38682cf690dc7f6cdc13f76fe2)) 82 | 83 | ## [1.0.1](https://github.com/adrenak/Unex/compare/v1.0.0...v1.0.1) (2020-03-10) 84 | 85 | 86 | ### Bug Fixes 87 | 88 | * add changelog file path in .releaserc ([c292565](https://github.com/adrenak/Unex/commit/c292565e569ae1fe422c3e81a1cf607ecf3abc80)) 89 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 633b9a7c871eea94d897a8f67cf55f2b 3 | timeCreated: 1565252728 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65104e5082c7a284184652f698182d29 3 | folderAsset: yes 4 | timeCreated: 1512369600 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/Adrenak.Unex.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Adrenak.Unex.Editor", 3 | "references": [ 4 | "Adrenak.Unex.Runtime" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [] 16 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/Adrenak.Unex.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b251c47cd7f772f4fb13e05c7714921c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/Hotkeys.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEditor; 4 | using System.Reflection; 5 | using Object = System.Object; 6 | 7 | namespace Adrenak.Unex.Ed { 8 | public class Hotkeys { 9 | 10 | // ================================================ 11 | // GLOBAL POSITION 12 | // ================================================ 13 | // Moves transform to global origin 14 | // USE CTRL + SHIFT + O 15 | [MenuItem("Edit/HotKeys/Move To Origin %#o")] 16 | static void MoveToOrigin() { 17 | if (Selection.activeTransform != null) 18 | Selection.activeTransform.position = new Vector3(0, 0, 0); 19 | } 20 | 21 | // Sets transforms global Y position to 0 22 | // USE CTRL + SHIFT + Y 23 | [MenuItem("Edit/HotKeys/Move To Global XZ Plane %#Y")] 24 | static void MoveToXZPlane() { 25 | if (Selection.activeTransform != null) { 26 | Vector3 pos = Selection.activeTransform.position; 27 | Selection.activeTransform.position = new Vector3(pos.x, 0, pos.z); 28 | } 29 | } 30 | 31 | // Sets transforms global Z position to 0 32 | // USE CTRL + SHIFT + Z 33 | [MenuItem("Edit/HotKeys/Move To Global XY Plane %#Z")] 34 | static void MoveToXYPlane() { 35 | if (Selection.activeTransform != null) { 36 | Vector3 pos = Selection.activeTransform.position; 37 | Selection.activeTransform.position = new Vector3(pos.x, pos.y, 0); 38 | } 39 | } 40 | 41 | // Sets transforms global X position to 0 42 | // USE CTRL + SHIFT + X 43 | [MenuItem("Edit/HotKeys/Move To Global YZ Plane %#X")] 44 | static void MoveToYZPlane() { 45 | if (Selection.activeTransform != null) { 46 | Vector3 pos = Selection.activeTransform.position; 47 | Selection.activeTransform.position = new Vector3(0, pos.y, pos.z); 48 | } 49 | } 50 | 51 | // ================================================ 52 | // LOCAL POSITION 53 | // ================================================ 54 | // Moves transform to local 0, 0, 0 position 55 | // USE CTRL + ALT + O 56 | [MenuItem("Edit/HotKeys/Move To Local Origin %&o")] 57 | static void MoveToLocalOrigin() { 58 | if (Selection.activeTransform != null) 59 | Selection.activeTransform.localPosition = new Vector3(0, 0, 0); 60 | } 61 | 62 | // Sets transforms local Y position to 0 63 | // USE CTRL + ALT + Y 64 | [MenuItem("Edit/HotKeys/Move To Local XZ Plane %&Y")] 65 | static void MoveToLocalXZPlane() { 66 | if (Selection.activeTransform != null) { 67 | Vector3 pos = Selection.activeTransform.position; 68 | Selection.activeTransform.localPosition = new Vector3(pos.x, 0, pos.z); 69 | } 70 | } 71 | 72 | // Sets transforms local Z position to 0 73 | // USE CTRL + ALT + Z 74 | [MenuItem("Edit/HotKeys/Move To Local XY Plane %&Z")] 75 | static void MoveToLocalXYPlane() { 76 | if (Selection.activeTransform != null) { 77 | Vector3 pos = Selection.activeTransform.position; 78 | Selection.activeTransform.localPosition = new Vector3(pos.x, pos.y, 0); 79 | } 80 | } 81 | 82 | // Sets transforms local X position to 0 83 | // USE CTRL + ALT + X 84 | [MenuItem("Edit/HotKeys/Move To Local YZ Plane %&X")] 85 | static void MoveToLocalYZPlane() { 86 | if (Selection.activeTransform != null) { 87 | Vector3 pos = Selection.activeTransform.position; 88 | Selection.activeTransform.localPosition = new Vector3(0, pos.y, pos.z); 89 | } 90 | } 91 | 92 | // ================================================ 93 | // TRANSFORMS 94 | // ================================================ 95 | // Groups the selected transforms under a new parent located at the combined center of the selection 96 | // PRESS CTRL + G 97 | [MenuItem("Edit/HotKeys/Group Transforms %G")] 98 | static void GroupTransforms() { 99 | if (Selection.transforms != null && Selection.transforms.Length > 0) { 100 | GameObject grouped = new GameObject("Grouped"); 101 | 102 | // We calculate the center of the objects and move the new root there 103 | Vector3 posSum = new Vector3(0, 0, 0); 104 | foreach (Transform t in Selection.transforms) 105 | posSum += t.position; 106 | posSum /= Selection.transforms.Length; 107 | grouped.transform.position = posSum; 108 | 109 | // Move all transforms into the new root 110 | foreach (Transform t in Selection.transforms) 111 | t.parent = grouped.transform; 112 | Selection.activeTransform = grouped.transform; 113 | } 114 | } 115 | 116 | // Changes the scale of a transform to 1, 1, 1. 117 | // Changing scale may have unintended affects! 118 | // PRESS CTRL + SHIFT+ U 119 | [MenuItem("Edit/HotKeys/Scale To (1, 1, 1) %#U")] 120 | static void ScaleTransformToUnit() { 121 | Transform activeTransform = Selection.activeTransform; 122 | if (activeTransform == null) 123 | return; 124 | 125 | // Create a new gameobject at the position of the transform to be scaled 126 | GameObject createdGO = new GameObject("Unit Scaled Object"); 127 | createdGO.transform.position = activeTransform.position; 128 | 129 | // Move all children of the transform to the new gameobject created above 130 | while (activeTransform.childCount != 0) 131 | activeTransform.GetChild(0).parent = createdGO.transform; 132 | 133 | // Scale the original transform to 1, 1, 1 134 | activeTransform.localScale = new Vector3(1, 1, 1); 135 | 136 | // Move all children back to the object again 137 | while (createdGO.transform.childCount != 0) 138 | createdGO.transform.GetChild(0).parent = activeTransform; 139 | 140 | // Delete the temp object 141 | MonoBehaviour.DestroyImmediate(createdGO); 142 | } 143 | 144 | #if !UNITY_2018 145 | [MenuItem("Edit/HotKeys/Deselect All &A")] 146 | static void DeselectAll() { 147 | Selection.activeGameObject = null; 148 | } 149 | #endif 150 | 151 | // ================================================ 152 | // uGUI 153 | // See uGUITools.cs online 154 | // ================================================ 155 | // Sets the anchors of the RectTransform to it's corner bounds 156 | [MenuItem("Edit/HotKeys/Anchors to Corners %[")] 157 | static void AnchorsToCorners() { 158 | RectTransform t = Selection.activeTransform as RectTransform; 159 | RectTransform pt = Selection.activeTransform.parent as RectTransform; 160 | 161 | if (t == null || pt == null) 162 | return; 163 | 164 | Vector2 newAnchorsMin = new Vector2(t.anchorMin.x + t.offsetMin.x / pt.rect.width, 165 | t.anchorMin.y + t.offsetMin.y / pt.rect.height); 166 | Vector2 newAnchorsMax = new Vector2(t.anchorMax.x + t.offsetMax.x / pt.rect.width, 167 | t.anchorMax.y + t.offsetMax.y / pt.rect.height); 168 | 169 | t.anchorMin = newAnchorsMin; 170 | t.anchorMax = newAnchorsMax; 171 | t.offsetMin = t.offsetMax = new Vector2(0, 0); 172 | } 173 | 174 | // Scale the bo9nds of the RestTransform to the anchors 175 | [MenuItem("Edit/HotKeys/Corners to Anchors %]")] 176 | static void CornersToAnchors() { 177 | RectTransform t = Selection.activeTransform as RectTransform; 178 | 179 | if (t == null) 180 | return; 181 | 182 | t.offsetMin = t.offsetMax = new Vector2(0, 0); 183 | } 184 | 185 | // ================================================ 186 | // EDITOR 187 | // ================================================ 188 | // https://forum.unity.com/threads/shortcut-key-for-lock-inspector.95815/ 189 | private static EditorWindow _mouseOverWindow; 190 | [MenuItem("Edit/HotKeys/Toggle Lock &q")] 191 | static void ToggleInspectorLock() { 192 | if (_mouseOverWindow == null) { 193 | if (!EditorPrefs.HasKey("LockableInspectorIndex")) 194 | EditorPrefs.SetInt("LockableInspectorIndex", 0); 195 | int i = EditorPrefs.GetInt("LockableInspectorIndex"); 196 | 197 | Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); 198 | Object[] findObjectsOfTypeAll = Resources.FindObjectsOfTypeAll(type); 199 | _mouseOverWindow = (EditorWindow)findObjectsOfTypeAll[i]; 200 | } 201 | 202 | if (_mouseOverWindow != null && _mouseOverWindow.GetType().Name == "InspectorWindow") { 203 | Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditor.InspectorWindow"); 204 | PropertyInfo propertyInfo = type.GetProperty("isLocked"); 205 | bool value = (bool)propertyInfo.GetValue(_mouseOverWindow, null); 206 | propertyInfo.SetValue(_mouseOverWindow, !value, null); 207 | _mouseOverWindow.Repaint(); 208 | } 209 | } 210 | 211 | [MenuItem("Edit/HotKeys/Clear Console %&c")] 212 | static void ClearConsole() { 213 | Type type = Assembly.GetAssembly(typeof(UnityEditor.Editor)).GetType("UnityEditorInternal.LogEntries"); 214 | type.GetMethod("Clear").Invoke(null, null); 215 | } 216 | } 217 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/Hotkeys.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2857729c7725fe42a4c15788164d959 3 | timeCreated: 1510314908 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/LogCatWindow.cs: -------------------------------------------------------------------------------- 1 | #if PLATFORM_ANDROID 2 | using UnityEngine; 3 | using System.Collections; 4 | using UnityEditor; 5 | using UnityEditor.Android; 6 | using System.Diagnostics; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System; 10 | using System.Text; 11 | using System.Text.RegularExpressions; 12 | using System.IO; 13 | #if UNITY_2017_3_OR_NEWER 14 | using UnityEditor.Compilation; 15 | #endif 16 | 17 | public class LogCatWindow : EditorWindow 18 | { 19 | // How many log entries to store in memory. Keep it low for better performance. 20 | private const int memoryLimit = 2000; 21 | 22 | // How many log entries to show in unity3D editor. Keep it low for better performance. 23 | private const int showLimit = 200; 24 | 25 | // Filters 26 | private bool prefilterOnlyUnity = true; 27 | private bool filterOnlyError = false; 28 | private bool filterOnlyWarning = false; 29 | private bool filterOnlyDebug = false; 30 | private bool filterOnlyInfo = false; 31 | private bool filterOnlyVerbose = false; 32 | private string filterByString = String.Empty; 33 | 34 | // Android adb logcat process 35 | private Process logCatProcess; 36 | 37 | // Log entries 38 | private List logsList = new List(); 39 | private List filteredList = new List(memoryLimit); 40 | private const string LogcatPattern = @"([0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9]{3}) ([WIEDV])/(.*)"; 41 | private static readonly Regex LogcatRegex = new Regex(LogcatPattern, RegexOptions.Compiled); 42 | 43 | // Filtered GUI list scroll position 44 | private Vector2 scrollPosition = new Vector2(0, 0); 45 | 46 | // Add menu item named "LogCat" to the Window menu 47 | [MenuItem("Window/LogCat - Android Logger")] 48 | public static void ShowWindow() 49 | { 50 | // Show existing window instance. If one doesn't exist, make one. 51 | EditorWindow.GetWindow(typeof(LogCatWindow), false, "Logcat"); 52 | } 53 | 54 | void Update() 55 | { 56 | if (logsList.Count == 0) 57 | return; 58 | 59 | lock (logsList) 60 | { 61 | // Filter 62 | filteredList = logsList.Where(log => (filterByString.Length <= 2 || log.Message.ToLower().Contains(filterByString.ToLower())) && 63 | ((!filterOnlyError && !filterOnlyWarning && !filterOnlyDebug && !filterOnlyInfo && !filterOnlyVerbose) 64 | || filterOnlyError && log.Type == 'E' 65 | || filterOnlyWarning && log.Type == 'W' 66 | || filterOnlyDebug && log.Type == 'D' 67 | || filterOnlyInfo && log.Type == 'I' 68 | || filterOnlyVerbose && log.Type == 'V')).ToList(); 69 | } 70 | 71 | if (logCatProcess != null) 72 | { 73 | Repaint(); 74 | } 75 | } 76 | 77 | void OnGUI() 78 | { 79 | GUILayout.BeginHorizontal(); 80 | 81 | // Enable pre-filter if process is not started 82 | GUI.enabled = logCatProcess == null; 83 | prefilterOnlyUnity = GUILayout.Toggle(prefilterOnlyUnity, "Only Unity", "Button", GUILayout.Width(80)); 84 | 85 | // Enable button if process is not started 86 | GUI.enabled = logCatProcess == null; 87 | if (GUILayout.Button("Start", GUILayout.Width(60))) 88 | { 89 | string adbPath = GetAdbPath(); 90 | 91 | // Start `adb logcat -c` to clear the log buffer 92 | ProcessStartInfo clearProcessInfo = new ProcessStartInfo(); 93 | clearProcessInfo.WindowStyle = ProcessWindowStyle.Hidden; 94 | clearProcessInfo.CreateNoWindow = true; 95 | clearProcessInfo.UseShellExecute = false; 96 | clearProcessInfo.FileName = adbPath; 97 | clearProcessInfo.Arguments = @"logcat -c"; 98 | Process.Start(clearProcessInfo); 99 | 100 | // Start `adb logcat` (with additional optional arguments) process for filtering 101 | ProcessStartInfo logProcessInfo = new ProcessStartInfo(); 102 | logProcessInfo.CreateNoWindow = true; 103 | logProcessInfo.UseShellExecute = false; 104 | logProcessInfo.RedirectStandardOutput = true; 105 | logProcessInfo.RedirectStandardError = true; 106 | logProcessInfo.StandardOutputEncoding = Encoding.UTF8; 107 | logProcessInfo.FileName = adbPath; 108 | logProcessInfo.WindowStyle = ProcessWindowStyle.Hidden; 109 | 110 | // Add additional -s argument for filtering by Unity tag. 111 | logProcessInfo.Arguments = "logcat -v time"+(prefilterOnlyUnity ? " -s \"Unity\"": ""); 112 | 113 | logCatProcess = Process.Start(logProcessInfo); 114 | 115 | logCatProcess.ErrorDataReceived += (sender, errorLine) => { 116 | if (errorLine.Data != null && errorLine.Data.Length > 2) 117 | AddLog(new LogCatLog(errorLine.Data)); 118 | }; 119 | logCatProcess.OutputDataReceived += (sender, outputLine) => { 120 | if (outputLine.Data != null && outputLine.Data.Length > 2) 121 | AddLog(new LogCatLog(outputLine.Data)); 122 | }; 123 | logCatProcess.BeginErrorReadLine(); 124 | logCatProcess.BeginOutputReadLine(); 125 | } 126 | 127 | // Disable button if process is already started 128 | GUI.enabled = logCatProcess != null; 129 | if (GUILayout.Button("Stop", GUILayout.Width(60))) 130 | { 131 | StopLogCatProcess(); 132 | } 133 | 134 | GUI.enabled = true; 135 | if (GUILayout.Button("Clear", GUILayout.Width(60))) 136 | { 137 | lock (logsList) 138 | { 139 | logsList.Clear(); 140 | filteredList.Clear(); 141 | } 142 | } 143 | 144 | GUILayout.Label(filteredList.Count + " matching logs", GUILayout.Height(20)); 145 | 146 | // Create filters 147 | filterByString = GUILayout.TextField(filterByString, GUILayout.Height(20)); 148 | GUI.color = new Color(0.75f, 0.5f, 0.5f, 1f); 149 | filterOnlyError = GUILayout.Toggle(filterOnlyError, "Error", "Button", GUILayout.Width(80)); 150 | GUI.color = new Color(0.95f, 0.95f, 0.3f, 1f); 151 | filterOnlyWarning = GUILayout.Toggle(filterOnlyWarning, "Warning", "Button", GUILayout.Width(80)); 152 | GUI.color = new Color(0.5f, 0.5f, 0.75f, 1f); 153 | filterOnlyDebug = GUILayout.Toggle(filterOnlyDebug, "Debug", "Button", GUILayout.Width(80)); 154 | GUI.color = new Color(0.5f, 0.75f, 0.5f, 1f); 155 | filterOnlyInfo = GUILayout.Toggle(filterOnlyInfo, "Info", "Button", GUILayout.Width(80)); 156 | GUI.color = Color.white; 157 | filterOnlyVerbose = GUILayout.Toggle(filterOnlyVerbose, "Verbose", "Button", GUILayout.Width(80)); 158 | 159 | GUILayout.EndHorizontal(); 160 | 161 | GUIStyle lineStyle = new GUIStyle(); 162 | lineStyle.normal.background = MakeTexture(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f)); 163 | 164 | scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(Screen.height - 45)); 165 | 166 | // Show only top `showingLimit` log entries 167 | int fromIndex = filteredList.Count - showLimit; 168 | if (fromIndex < 0) 169 | fromIndex = 0; 170 | 171 | for (int i = fromIndex; i < filteredList.Count; i++) 172 | { 173 | LogCatLog log = filteredList[i]; 174 | GUI.backgroundColor = log.GetBgColor(); 175 | GUILayout.BeginHorizontal(lineStyle); 176 | GUILayout.Label(log.CreationDate + " | " + log.Message); 177 | GUILayout.EndHorizontal(); 178 | } 179 | 180 | GUILayout.EndScrollView(); 181 | } 182 | 183 | private Texture2D MakeTexture(int width, int height, Color col) 184 | { 185 | Color[] pix = new Color[width * height]; 186 | 187 | for (int i = 0; i < pix.Length; i++) 188 | pix [i] = col; 189 | 190 | Texture2D result = new Texture2D(width, height); 191 | result.SetPixels(pix); 192 | result.Apply(); 193 | 194 | return result; 195 | } 196 | 197 | private void AddLog(LogCatLog log) 198 | { 199 | lock (logsList) 200 | { 201 | if (logsList.Count > memoryLimit + 1) 202 | logsList.RemoveRange(0, logsList.Count - memoryLimit + 1); 203 | 204 | logsList.Add(log); 205 | } 206 | } 207 | 208 | void OnEnable() 209 | { 210 | #if UNITY_2017_3_OR_NEWER 211 | CompilationPipeline.assemblyCompilationStarted += OnAssemblyCompilationStarted; 212 | #endif 213 | } 214 | 215 | void OnDisable() 216 | { 217 | #if UNITY_2017_3_OR_NEWER 218 | CompilationPipeline.assemblyCompilationStarted -= OnAssemblyCompilationStarted; 219 | #endif 220 | } 221 | 222 | void OnDestroy() 223 | { 224 | StopLogCatProcess(); 225 | } 226 | 227 | private void StopLogCatProcess() 228 | { 229 | if (logCatProcess == null) 230 | { 231 | return; 232 | } 233 | try 234 | { 235 | if (!logCatProcess.HasExited) 236 | { 237 | logCatProcess.Kill(); 238 | } 239 | } 240 | catch(InvalidOperationException) 241 | { 242 | // Just ignore it. 243 | } 244 | finally 245 | { 246 | logCatProcess.Dispose(); 247 | logCatProcess = null; 248 | } 249 | } 250 | 251 | private void OnAssemblyCompilationStarted(string _) 252 | { 253 | StopLogCatProcess(); 254 | } 255 | 256 | private class LogCatLog 257 | { 258 | public LogCatLog(string data) 259 | { 260 | // First char indicates error type: 261 | // W - warning 262 | // E - error 263 | // D - debug 264 | // I - info 265 | // V - verbose 266 | Match match = LogcatRegex.Match(data); 267 | if (match.Success) 268 | { 269 | Type = match.Groups[2].Value[0]; 270 | 271 | Message = match.Groups[3].Value; 272 | CreationDate = match.Groups[1].Value; 273 | } 274 | else 275 | { 276 | Type = 'V'; 277 | 278 | Message = data; 279 | CreationDate = DateTime.Now.ToString("MM-dd HH:mm:ss.fff"); 280 | } 281 | } 282 | 283 | public string CreationDate 284 | { 285 | get; 286 | set; 287 | } 288 | 289 | public char Type 290 | { 291 | get; 292 | set; 293 | } 294 | 295 | public string Message 296 | { 297 | get; 298 | set; 299 | } 300 | 301 | public Color GetBgColor() 302 | { 303 | switch (Type) 304 | { 305 | case 'W': 306 | return Color.yellow; 307 | 308 | case 'I': 309 | return Color.green; 310 | 311 | case 'E': 312 | return Color.red; 313 | 314 | case 'D': 315 | return Color.blue; 316 | 317 | case 'V': 318 | default: 319 | return Color.grey; 320 | } 321 | } 322 | } 323 | 324 | private static string GetAdbPath() 325 | { 326 | #if UNITY_2019_1_OR_NEWER 327 | ADB adb = ADB.GetInstance(); 328 | return adb == null ? string.Empty : adb.GetADBPath(); 329 | #else 330 | string androidSdkRoot = EditorPrefs.GetString("AndroidSdkRoot"); 331 | if (string.IsNullOrEmpty(androidSdkRoot)) 332 | { 333 | return string.Empty; 334 | } 335 | return Path.Combine(androidSdkRoot, Path.Combine("platform-tools", "adb")); 336 | #endif 337 | } 338 | } 339 | #endif -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Editor/LogCatWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ea70e65f50ae7f43bfd45598714be09 3 | timeCreated: 1515403036 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2020 Vatsal Ambastha 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbe46120bdf118241962819efad5f885 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/README.md: -------------------------------------------------------------------------------- 1 | ## Unex 2 | Get your Unity project off the ground quickly with editor shortcuts, utility scripts and C# extensions. 3 | 4 | ## Intro 5 | Unex is a growing collection of tools which are the first things I add to my Unity projects. Included are: 6 | - C# language and Unity API extension methods 7 | - Unity Editor Hotkeys 8 | - Runner.cs 9 | - Pool.cs 10 | - Monitor.cs 11 | - Texture32.cs 12 | - [Json.NET](https://github.com/JamesNK/Newtonsoft.Json) 13 | - [WebSocketSharp](https://github.com/adrenak/websocket-sharp) 14 | - [Parallel.cs by Stewart Adcock](https://github.com/stewartadcock/Uk.Org.Adcock.Parallel/blob/master/Parallel/Properties/AssemblyInfo.cs) 15 | - [LogCatWindow.cs by Rokas Brazdžionis](https://github.com/dzonatan/Unity3D-LogCat-extension) 16 | - [ImmediateWindow.cs by Nick Gravelyn](http://wiki.unity3d.com/index.php?title=ImmediateWindow) 17 | - [uGUITools.cs by Senshi](https://forum.unity.com/members/senshi.25677/) 18 | - [FPSDisplay.cs by Dave Hampson](http://wiki.unity3d.com/index.php?title=FramesPerSecond) 19 | - [NaughtyAttributes by Denis Rizov](https://github.com/dbrizov/NaughtyAttributes) 20 | 21 | ## Contact 22 | [@github](https://www.github.com/adrenak) 23 | [@www](http://www.vatsalambastha.com) -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6c0d7307b1e3564ca18ff2389bb037d 3 | timeCreated: 1565252729 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 542eff69b9f82164c985e05e46eed510 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Adrenak.Unex.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Adrenak.Unex.Runtime", 3 | "references": [], 4 | "optionalUnityReferences": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [] 12 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Adrenak.Unex.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7451c1bd207d1244e8d45aef9616ef3c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Extensions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc42d6cb109bbc8488cf37925b3e2267 3 | folderAsset: yes 4 | timeCreated: 1514636136 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Extensions/CSharpExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UnityEngine; 5 | 6 | namespace Adrenak.Unex { 7 | public static class CSharpExtensions { 8 | // ENUM 9 | public static bool Has(this Enum type, T value) { 10 | try { 11 | return (((int)(object)type & (int)(object)value) == (int)(object)value); 12 | } 13 | catch { 14 | return false; 15 | } 16 | } 17 | 18 | public static bool Is(this Enum type, T value) { 19 | try { 20 | return (int)(object)type == (int)(object)value; 21 | } 22 | catch { 23 | return false; 24 | } 25 | } 26 | 27 | public static T Add(this Enum type, T value) { 28 | try { 29 | return (T)(object)(((int)(object)type | (int)(object)value)); 30 | } 31 | catch (Exception ex) { 32 | throw new ArgumentException( 33 | string.Format( 34 | "Could not append value from enumerated type '{0}'.", 35 | typeof(T).Name 36 | ), ex); 37 | } 38 | } 39 | 40 | 41 | public static T Remove(this Enum type, T value) { 42 | try { 43 | return (T)(object)(((int)(object)type & ~(int)(object)value)); 44 | } 45 | catch (Exception ex) { 46 | throw new ArgumentException( 47 | string.Format( 48 | "Could not remove value from enumerated type '{0}'.", 49 | typeof(T).Name 50 | ), ex); 51 | } 52 | } 53 | 54 | // MATH 55 | public static bool Approximately(this float a, float b) { 56 | return Mathf.Approximately(a, b); 57 | } 58 | 59 | // BYTE[] 60 | public static string ToUTF8String(this byte[] bytes) { 61 | return Encoding.UTF8.GetString(bytes); 62 | } 63 | 64 | 65 | // STRINGS 66 | public static bool IsNullOrEmpty(this string _string) { 67 | return string.IsNullOrEmpty(_string); 68 | } 69 | 70 | public static byte[] ToUTF8Bytes(this string str) { 71 | return Encoding.UTF8.GetBytes(str); 72 | } 73 | 74 | // DATE TIME 75 | public static bool IsOnSameDayAs(this DateTime dateTime, DateTime other) { 76 | if (dateTime.Day == other.Day && dateTime.Month == other.Month && dateTime.Year == other.Year) 77 | return true; 78 | return false; 79 | } 80 | 81 | public static bool IsOnSameDayAs(this DateTime @this, int day, int month, int year) { 82 | return @this.Day == day && @this.Month == month && @this.Year == year; 83 | } 84 | 85 | public static bool IsDateInRange(this DateTime toCheck, DateTime lowerBound, DateTime upperBound) { 86 | if (lowerBound < toCheck && toCheck < upperBound) 87 | return true; 88 | return false; 89 | } 90 | 91 | public static DateTime ToHumanTime(this long unixTimeStamp) { 92 | DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 93 | return epoch.AddMilliseconds(Convert.ToDouble(unixTimeStamp)); 94 | } 95 | 96 | public static DateTime? ToHumanTime(this string unixTimeStamp) { 97 | try { 98 | DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 99 | return epoch.AddMilliseconds(Convert.ToInt64(unixTimeStamp)); 100 | } 101 | catch { 102 | return null; 103 | } 104 | } 105 | 106 | public static long ToUnixTime(this DateTime date) { 107 | var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 108 | return (long)((date - epoch).TotalMilliseconds); 109 | } 110 | 111 | public static byte[] ToBytes(this float[] floatArray) { 112 | var floatLen = floatArray.Length; 113 | Int16[] intData = new Int16[floatLen]; 114 | Byte[] bytesData = new Byte[floatLen * 2]; 115 | Byte[] byteArr = new Byte[2]; 116 | 117 | int rescaleFactor = 32767; //to convert float to Int16 118 | 119 | for (int i = 0; i < floatArray.Length; i++) { 120 | intData[i] = (short)(floatArray[i] * rescaleFactor); 121 | byteArr = BitConverter.GetBytes(intData[i]); 122 | byteArr.CopyTo(bytesData, i * 2); 123 | } 124 | return bytesData; 125 | } 126 | 127 | public static bool IsNullOrEmpty(this List list) { 128 | return list == null || list.Count == 0; 129 | } 130 | 131 | public static bool IsNullOrEmpty(this T[] array) { 132 | return array == null || array.Length == 0; 133 | } 134 | 135 | public static T FromLast(this List list, int index) { 136 | if (index >= list.Count) 137 | throw new IndexOutOfRangeException(index + " is out of range"); 138 | return list[list.Count - 1 - index]; 139 | } 140 | 141 | public static T Last(this List list) { 142 | return list.FromLast(0); 143 | } 144 | 145 | public static void RemoveLast(this List list) { 146 | var last = list.Last(); 147 | list.Remove(last); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Extensions/CSharpExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f04737b1e0d73984d9722909e25f4879 3 | timeCreated: 1514636457 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Extensions/UnityAPIExtensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | using System.Collections.Generic; 5 | using System.Threading.Tasks; 6 | 7 | using System.Reflection; 8 | using System; 9 | using Object = UnityEngine.Object; 10 | 11 | namespace Adrenak.Unex { 12 | public static class UnityAPIExtensions { 13 | // VECTOR2 14 | public static bool Approximately(this Vector2 a, Vector2 b) { 15 | return 16 | Mathf.Approximately(a.x, b.x) && 17 | Mathf.Approximately(a.y, b.y); 18 | } 19 | 20 | public static bool Approximately(this Vector3 a, Vector3 b) { 21 | return 22 | Mathf.Approximately(a.x, b.x) && 23 | Mathf.Approximately(a.y, b.y) && 24 | Mathf.Approximately(a.z, b.z); 25 | } 26 | 27 | // GAME OBJECTS 28 | public static void Destroy(this GameObject gameObject) { 29 | MonoBehaviour.Destroy(gameObject); 30 | } 31 | 32 | public static void DestroyImmediate(this GameObject gameObject) { 33 | MonoBehaviour.DestroyImmediate(gameObject); 34 | } 35 | 36 | public static T EnsureComponent(this GameObject go) where T : Component { 37 | var get = go.GetComponent(); 38 | if (get == null) 39 | return go.AddComponent(); 40 | return get; 41 | } 42 | 43 | // https://answers.unity.com/questions/530178/how-to-get-a-component-from-an-object-and-add-it-t.html 44 | public static T Clone(this Component comp, T other) where T : Component { 45 | Type type = comp.GetType(); 46 | if (type != other.GetType()) return null; // type mis-match 47 | BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Default | BindingFlags.DeclaredOnly; 48 | PropertyInfo[] pinfos = type.GetProperties(flags); 49 | foreach (var pinfo in pinfos) { 50 | if (pinfo.CanWrite) { 51 | try { 52 | pinfo.SetValue(comp, pinfo.GetValue(other, null), null); 53 | } 54 | catch { } // In case of NotImplementedException being thrown. For some reason specifying that exception didn't seem to catch it, so I didn't catch anything specific. 55 | } 56 | } 57 | FieldInfo[] finfos = type.GetFields(flags); 58 | foreach (var finfo in finfos) 59 | finfo.SetValue(comp, finfo.GetValue(other)); 60 | return comp as T; 61 | } 62 | 63 | // LAYER MASK 64 | public static bool Contains(this LayerMask mask, int layer) { 65 | return mask == (mask | (1 << layer)); 66 | } 67 | 68 | public static int[] GetIncludedLayers(this LayerMask mask) { 69 | List layers = new List(); 70 | for (int i = 0; i < 32; i++) { 71 | var contains = mask.Contains(i); 72 | if (contains) 73 | layers.Add(i); 74 | } 75 | return layers.ToArray(); 76 | } 77 | 78 | public static bool[] GetLayersAsBool(this LayerMask mask) { 79 | bool[] boolArray = new bool[32]; 80 | for (int i = 0; i < 32; i++) 81 | boolArray[i] = mask.Contains(i); 82 | return boolArray; 83 | } 84 | 85 | public static void SetActiveRecursively(this GameObject go) { 86 | go.SetActive(true); 87 | foreach (Transform t in go.transform) 88 | t.gameObject.SetActiveRecursively(); 89 | } 90 | 91 | public static Texture2D GetFrame(this Camera cam) { 92 | cam.Render(); 93 | RenderTexture.active = cam.targetTexture; 94 | var tex = new Texture2D(cam.targetTexture.width, cam.targetTexture.height, TextureFormat.ARGB32, false); 95 | tex.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0); 96 | RenderTexture.active = null; 97 | 98 | return tex; 99 | } 100 | 101 | #if !UNEX_DISABLE_WEBCAM 102 | public static Texture2D GetFrame(this WebCamTexture tex) { 103 | if (!tex.isPlaying) return null; 104 | var result = new Texture2D(tex.width, tex.height); 105 | result.SetPixels(tex.GetPixels()); 106 | result.Apply(); 107 | return result; 108 | } 109 | #endif 110 | 111 | public static Object LoadObject(this AssetBundle bundle, string name, bool unload) { 112 | var temp = bundle.LoadObjects(new string[] { name }, unload); 113 | 114 | if (temp.Length != 0) return temp[0]; 115 | else return null; 116 | } 117 | 118 | public static Object[] LoadObjects(this AssetBundle bundle, string[] names, bool unload) { 119 | if (bundle == null) return new List().ToArray(); 120 | 121 | List result = new List(); 122 | 123 | for (int i = 0; i < names.Length; i++) { 124 | var temp = bundle.LoadAsset(names[i]); 125 | if (temp != null) 126 | result.Add(temp); 127 | } 128 | 129 | if (unload) 130 | bundle.Unload(false); 131 | 132 | return result.ToArray(); 133 | } 134 | 135 | public static Texture2D ToPixel(this Color color) { 136 | var texture = new Texture2D(1, 1); 137 | texture.SetPixel(0, 0, color); 138 | texture.Apply(); 139 | return texture; 140 | } 141 | 142 | public static Color GetAverageColor(this Texture2D tex) { 143 | var pixels = tex.GetPixels(); 144 | Vector3 avg = Vector3.zero; 145 | for (int i = 0; i < pixels.Length; i++) 146 | avg += new Vector3( 147 | pixels[i].r, 148 | pixels[i].g, 149 | pixels[i].b 150 | ); 151 | avg /= pixels.Length; 152 | return new Color(avg.x, avg.y, avg.z, 1); 153 | } 154 | 155 | public static bool Equals(this Color32 c1, Color32 c2) { 156 | return c1.r == c2.r && c1.g == c2.g && c1.b == c2.g && c1.a == c2.a; 157 | } 158 | 159 | public static Color Minus(this Color c1, Color c2) { 160 | return new Color( 161 | Mathf.Abs(c1.r - c2.r), 162 | Mathf.Abs(c1.g - c2.g), 163 | Mathf.Abs(c1.b - c2.b), 164 | Mathf.Abs(c1.a - c2.a) 165 | ); 166 | } 167 | 168 | public static Color32 Minus(this Color32 c1, Color32 c2) { 169 | return new Color32( 170 | (byte)Mathf.Abs(c1.r - c2.r), 171 | (byte)Mathf.Abs(c1.g - c2.g), 172 | (byte)Mathf.Abs(c1.b - c2.b), 173 | (byte)Mathf.Abs(c1.a - c2.a) 174 | ); 175 | } 176 | 177 | public static float Magnitude(this Color c) { 178 | return (c.r + c.g + c.b + c.a) / 4; 179 | } 180 | 181 | public static float Magnitude(this Color32 c) { 182 | return ((float)(c.r + c.g + c.b + c.a)) / 4; 183 | } 184 | 185 | public static bool SimilarTo(this Color c1, Color c2, float margin) { 186 | return c1.Minus(c2).Magnitude() < margin; 187 | } 188 | 189 | public static bool SimilarTo(this Color32 c1, Color32 c2, float margin) { 190 | return c1.Minus(c2).Magnitude() < margin; 191 | } 192 | 193 | public static Texture2D Crop(this Texture2D tex, Rect rect) { 194 | var w = tex.width; 195 | var h = tex.height; 196 | 197 | var colors = new Color32[(int)rect.width * (int)rect.height]; 198 | 199 | var index = 0; 200 | var pixels = tex.GetPixels32(); 201 | for (int i = 0; i < pixels.Length; i++) { 202 | var r = i / w; 203 | var c = i % w; 204 | if (r >= rect.y && r < rect.y + rect.height && c >= rect.x && c < rect.x + rect.width) { 205 | colors[index] = pixels[i]; 206 | index++; 207 | } 208 | } 209 | 210 | Object.Destroy(tex); 211 | tex = new Texture2D((int)rect.width, (int)rect.height, tex.format, true); 212 | tex.SetPixels32(colors, 0); 213 | tex.Apply(); 214 | return tex; 215 | } 216 | 217 | public static void Copy(this Texture2D tex, Texture2D other, Vector2 position, bool apply = true) { 218 | var pixels = other.GetPixels32(); 219 | var w = other.width; 220 | var h = other.height; 221 | 222 | tex.SetPixels32((int)position.x, (int)position.y, w, h, pixels); 223 | if (apply) 224 | tex.Apply(); 225 | pixels = null; 226 | } 227 | 228 | public static float GetGreyscale(this Color32 color) { 229 | return (color.r + color.g + color.b) / 3; 230 | } 231 | 232 | public static Sprite ToSprite(this Texture2D tex) { 233 | if (tex == null) return null; 234 | return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(.5F, .5F)); 235 | } 236 | 237 | public static Task MarkForUIRebuild(this T t) where T : Component { 238 | return t.gameObject.MarkForUIRebuild(); 239 | } 240 | 241 | async public static Task MarkForUIRebuild(this GameObject go) { 242 | if (go.GetComponent()) { 243 | await TaskX.WaitTillNextFrame(); 244 | LayoutRebuilder.MarkLayoutForRebuild(go.GetComponent()); 245 | await TaskX.WaitTillNextFrame(); 246 | } 247 | } 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Extensions/UnityAPIExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c19baf1a1b0edcb4bbc7898358f3aab9 3 | timeCreated: 1514636281 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/UnexInitializer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Adrenak.Unex { 4 | public class UnexInitializer : MonoBehaviour { 5 | static UnexInitializer instance; 6 | 7 | void Awake() { 8 | if (instance == null) 9 | instance = GetComponent(); 10 | Initialize(); 11 | } 12 | 13 | public static void Initialize() { 14 | Dispatcher.Init(); 15 | Runnable.Init(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/UnexInitializer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f921ef1b3b11a8c4a99182fc14dc66b2 3 | timeCreated: 1545507820 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 942b983167ec3414eb6fd5ea0bf35c8b 3 | folderAsset: yes 4 | timeCreated: 1514636651 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Dispatcher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Adrenak.Unex { 6 | public class Dispatcher : MonoBehaviour { 7 | static Dispatcher m_Instance; 8 | Queue m_Queue = new Queue(); 9 | 10 | public static void Init() { 11 | if (m_Instance != null) return; 12 | 13 | var go = new GameObject("Adrenak.Unex.Dispatcher") { 14 | hideFlags = HideFlags.HideAndDontSave 15 | }; 16 | DontDestroyOnLoad(go); 17 | m_Instance = go.AddComponent(); 18 | } 19 | 20 | public static void Enqueue(Action action) { 21 | lock (m_Instance.m_Queue) { 22 | m_Instance.m_Queue.Enqueue(action); 23 | } 24 | } 25 | 26 | void Update() { 27 | lock (m_Instance.m_Queue) { 28 | while (m_Instance.m_Queue.Count > 0) 29 | m_Instance.m_Queue.Dequeue()(); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Dispatcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60160bd41d1f5fc45b35e4f4398ccf6e 3 | timeCreated: 1545155279 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/FPSDisplay.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Adrenak.Unex { 4 | public class FPSDisplay : MonoBehaviour { 5 | public Color color = new Color(0.0f, 0.0f, 0.5f, 1.0f); 6 | float deltaTime = 0.0f; 7 | 8 | void Update() { 9 | deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f; 10 | } 11 | 12 | void OnGUI() { 13 | int w = Screen.width, h = Screen.height; 14 | 15 | GUIStyle style = new GUIStyle(); 16 | 17 | Rect rect = new Rect(0, 0, w, h * 2 / 100); 18 | style.alignment = TextAnchor.UpperLeft; 19 | style.fontSize = h * 2 / 100; 20 | style.normal.textColor = color; 21 | float msec = deltaTime * 1000.0f; 22 | float fps = 1.0f / deltaTime; 23 | string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps); 24 | GUI.Label(rect, text, style); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/FPSDisplay.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d196423211b468448a0909f5b4d42a74 3 | timeCreated: 1516577973 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Monitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Adrenak.Unex { 5 | [DisallowMultipleComponent] 6 | public class Monitor : MonoBehaviour { 7 | // OnTriggerEnter 8 | Action m_OnTriggerEnter; 9 | public void HandleTriggerEnter(Action callback) { 10 | m_OnTriggerEnter = callback; 11 | } 12 | void OnTriggerEnter(Collider collider) { 13 | m_OnTriggerEnter?.Invoke(collider); 14 | } 15 | 16 | // OnTriggerExit 17 | Action m_OnTriggerExit; 18 | public void HandleTriggerExit(Action callback) { 19 | m_OnTriggerExit = callback; 20 | } 21 | void OnTriggerExit(Collider collider) { 22 | m_OnTriggerExit?.Invoke(collider); 23 | } 24 | 25 | // OnTriggerStay 26 | Action m_OnTriggerStay; 27 | public void HandleTriggerStay(Action callback) { 28 | m_OnTriggerStay = callback; 29 | } 30 | void OnTriggerStay(Collider collider) { 31 | m_OnTriggerStay?.Invoke(collider); 32 | } 33 | 34 | // OnCollisionEnter 35 | Action m_OnCollisionEnter; 36 | public void HandleCollisionEnter(Action callback) { 37 | m_OnCollisionEnter = callback; 38 | } 39 | void OnCollisionEnter(Collision collision) { 40 | m_OnCollisionEnter?.Invoke(collision); 41 | } 42 | 43 | // OnCollisionExit 44 | Action m_OnCollisionExit; 45 | public void HandleCollisionExit(Action callback) { 46 | m_OnCollisionExit = callback; 47 | } 48 | void OnCollisionExit(Collision collision) { 49 | m_OnCollisionExit?.Invoke(collision); 50 | } 51 | 52 | // OnCollisionStay 53 | Action m_OnCollisionStay; 54 | public void HandleCollisionStay(Action callback) { 55 | m_OnCollisionStay = callback; 56 | } 57 | void OnCollisionStay(Collision collision) { 58 | m_OnCollisionStay?.Invoke(collision); 59 | } 60 | } 61 | 62 | public static class MonitorExtensions { 63 | public static Monitor GetMonitor(this GameObject gameObject) { 64 | Monitor monitor = gameObject.GetComponent(); 65 | if (monitor == null) 66 | monitor = gameObject.AddComponent(); 67 | return monitor; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Monitor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c27814f4e99e7b844b9b34be072271a4 3 | timeCreated: 1518507548 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/MonoSingleton.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Adrenak.Unex { 4 | public class MonoSingleton : MonoBehaviour where T : Component { 5 | private static T instance; 6 | public static T Instance { 7 | get { 8 | if (instance == null) { 9 | var objs = FindObjectsOfType(typeof(T)) as T[]; 10 | if (objs.Length > 0) 11 | instance = objs[0]; 12 | if (objs.Length > 1) 13 | Debug.LogWarning("There is more than one " + typeof(T).Name + " in the scene."); 14 | if (instance == null) { 15 | GameObject obj = new GameObject(); 16 | instance = obj.AddComponent(); 17 | } 18 | } 19 | return instance; 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/MonoSingleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a701d15884d2834b8cd55a8438dad72 3 | timeCreated: 1519919965 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Parallel.cs: -------------------------------------------------------------------------------- 1 | #region Copyright (c) 2009 Stewart Adcock 2 | // 3 | // Filename: Parallel.cs 4 | // 5 | // This file may be used under the terms of the 2-clause BSD license: 6 | // 7 | // Copyright (c) 2009, Stewart A. Adcock 8 | // All rights reserved. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, are 11 | // permitted provided that the following conditions are met: 12 | // 13 | // * Redistributions of source code must retain the above copyright notice, this list 14 | // of conditions and the following disclaimer. 15 | // * Redistributions in binary form must reproduce the above copyright notice, this 16 | // list of conditions and the following disclaimer in the documentation and/or other 17 | // materials provided with the distribution. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 22 | // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27 | // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // Revision History 30 | // Version date author changes 31 | // 1.0 2009-05-01 Stewart Initial version donated to MEDIT to replace older Parallel.cs 32 | // 33 | #endregion 34 | 35 | using System; 36 | using System.Collections.Generic; 37 | using System.Threading; 38 | 39 | namespace Adrenak.Unex { 40 | /// 41 | /// A lightweight implementation of a small subset of Microsoft's Parallel Extensions for 42 | /// .Net 3.5/4.0 that can be used with the earlier .Net/C# 2.0 43 | /// 44 | /// 45 | /// This is an analogue of "Microsoft Parallel Extensions to .NET Framework 3.5, June 46 | /// 2008 Community Technology Preview" from: 47 | /// http://www.microsoft.com/downloads/details.aspx?FamilyID=348f73fd-593d-4b3c-b055-694c50d2b0f3&DisplayLang=en 48 | /// It is not a full implementation, and should be deprecated when MEDIT switch to 49 | /// Visual Studio 2010/.Net 4.0 by using the Microsoft/Novell Mono equivalents. 50 | /// Mono already supports the Parallel Extensions. 51 | /// 52 | /// This class supports the Parallel.For and Parallel.ForEach loop constructs. 53 | /// 54 | /// See also: 55 | /// http://tirania.org/blog/archive/2008/Jul-26-1.html 56 | /// http://blogs.msdn.com/somasegar/archive/2008/06/02/june-2008-ctp-parallel-extensions-to-the-net-fx.aspx 57 | /// 58 | /// This should work on any version of C#/.Net that supports generics. 59 | /// 60 | public class Parallel : IDisposable { 61 | #region WorkerThread class 62 | /// 63 | /// Background thread definition. 64 | /// 65 | private sealed class WorkerThread : IDisposable { 66 | private Thread thread; 67 | private AutoResetEvent taskWaiting; 68 | private ManualResetEvent threadIdle; 69 | 70 | /// 71 | /// Initializes a new instance of the class. 72 | /// 73 | public WorkerThread() { 74 | this.taskWaiting = new AutoResetEvent(false); 75 | this.threadIdle = new ManualResetEvent(true); 76 | } 77 | 78 | /// 79 | /// Wait for thread termination and close events. 80 | /// 81 | public void Terminate() { 82 | this.taskWaiting.Set(); 83 | this.thread.Join(); 84 | 85 | this.taskWaiting.Close(); 86 | this.threadIdle.Close(); 87 | } 88 | 89 | #region IDisposable 90 | /// 91 | /// Releases unmanaged and - optionally - managed resources 92 | /// 93 | /// if set to true, dispose managed resources. 94 | private void Dispose(bool disposing) { 95 | if (disposing) { 96 | // dispose managed resources 97 | if (this.taskWaiting != null) { 98 | this.taskWaiting.Close(); 99 | this.taskWaiting = null; 100 | } 101 | if (this.threadIdle != null) { 102 | this.threadIdle.Close(); 103 | this.threadIdle = null; 104 | } 105 | } 106 | // free native resources 107 | } 108 | 109 | /// 110 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 111 | /// 112 | public void Dispose() { 113 | Dispose(true); 114 | GC.SuppressFinalize(this); 115 | } 116 | #endregion 117 | 118 | /// 119 | /// Gets or sets the thread. 120 | /// 121 | /// The thread. 122 | public Thread Thread { 123 | get { return this.thread; } 124 | set { this.thread = value; } 125 | } 126 | 127 | /// 128 | /// Gets the task waiting message event. 129 | /// 130 | /// The task waiting. 131 | public AutoResetEvent TaskWaiting { 132 | get { return this.taskWaiting; } 133 | } 134 | 135 | /// 136 | /// Gets the thread idle message event. 137 | /// 138 | /// The thread idle. 139 | public ManualResetEvent ThreadIdle { 140 | get { return this.threadIdle; } 141 | } 142 | } 143 | #endregion 144 | 145 | #region ParallelFor class 146 | /// 147 | /// Parallel For state class. 148 | /// 149 | public sealed class ParallelFor : IDisposable { 150 | /// 151 | /// Single instance of parallelFor class for singleton pattern 152 | /// 153 | private volatile static ParallelFor instance = null; 154 | 155 | /// 156 | /// Delegate defining For loop body. 157 | /// 158 | /// Loop index. 159 | public delegate void ForLoopDelegate(int index); 160 | 161 | /// 162 | /// For-loop body 163 | /// 164 | public ForLoopDelegate LoopFunction; 165 | 166 | /// 167 | /// Current loop index 168 | /// 169 | private int currentJobIndex; 170 | 171 | /// 172 | /// Stop loop index 173 | /// 174 | private int stopIndex; 175 | 176 | /// 177 | /// Number of threads to utilise 178 | /// 179 | private int threadCount = System.Environment.ProcessorCount; 180 | 181 | /// 182 | /// The worker threads. 183 | /// 184 | private List workerThreads; 185 | 186 | /// 187 | /// Runs the For loop. 188 | /// 189 | /// The start. 190 | /// The stop. 191 | /// The loop body. 192 | public void DoFor(int start, int stop, ForLoopDelegate loopBody) { 193 | this.currentJobIndex = start - 1; 194 | this.stopIndex = stop; 195 | this.LoopFunction = loopBody; 196 | 197 | // Signal waiting task to all threads and mark them not idle. 198 | for (int i = 0; i < this.threadCount; i++) { 199 | WorkerThread workerThread = workerThreads[i]; 200 | workerThread.ThreadIdle.Reset(); 201 | workerThread.TaskWaiting.Set(); 202 | } 203 | 204 | // Wait until all threads become idle 205 | for (int i = 0; i < this.threadCount; i++) { 206 | WorkerThread workerThread = workerThreads[i]; 207 | workerThread.ThreadIdle.WaitOne(); 208 | } 209 | } 210 | 211 | /// 212 | /// Get instance of the ParallelFor class for singleton pattern and 213 | /// update the number of threads if appropriate. 214 | /// 215 | /// The thread count. 216 | /// 217 | public static ParallelFor GetInstance(int threadCount) { 218 | 219 | if (instance == null) { 220 | instance = new ParallelFor(); 221 | instance.threadCount = threadCount; 222 | instance.Initialize(); 223 | } 224 | else { 225 | // Ensure we have the correct number of threads. 226 | if (instance.workerThreads.Count != threadCount) { 227 | instance.Terminate(); 228 | instance.threadCount = threadCount; 229 | instance.Initialize(); 230 | } 231 | } 232 | return instance; 233 | } 234 | 235 | #region Private methods 236 | private void Initialize() { 237 | this.workerThreads = new List(); 238 | 239 | for (int i = 0; i < this.threadCount; i++) { 240 | WorkerThread workerThread = new WorkerThread(); 241 | workerThread.Thread = new Thread(new ParameterizedThreadStart(RunWorkerThread)); 242 | workerThread.Thread.Name = "worker " + i; 243 | workerThreads.Add(workerThread); 244 | 245 | workerThread.Thread.IsBackground = true; 246 | workerThread.Thread.Start(i); 247 | } 248 | } 249 | 250 | private void Terminate() { 251 | // Finish thread by setting null loop body and signaling about available task 252 | LoopFunction = null; 253 | int workerThreadCount = this.workerThreads.Count; 254 | for (int i = 0; i < workerThreadCount; i++) { 255 | this.workerThreads[i].Terminate(); 256 | } 257 | } 258 | 259 | private void RunWorkerThread(object threadIndex) { 260 | WorkerThread workerThread = workerThreads[(int)threadIndex]; 261 | int localJobIndex = 0; 262 | 263 | while (true) { 264 | // Wait for a task. 265 | workerThread.TaskWaiting.WaitOne(); 266 | 267 | // Exit if task is empty. 268 | if (LoopFunction == null) { 269 | return; 270 | } 271 | 272 | localJobIndex = Interlocked.Increment(ref currentJobIndex); 273 | 274 | while (localJobIndex < stopIndex) { 275 | ////Console.WriteLine("Thread " + threadIndex + " of " + workerThreads.Count + " running task " + localJobIndex); 276 | LoopFunction(localJobIndex); 277 | localJobIndex = Interlocked.Increment(ref currentJobIndex); 278 | } 279 | 280 | // Signal that thread is idle. 281 | workerThread.ThreadIdle.Set(); 282 | } 283 | } 284 | #endregion 285 | 286 | #region IDisposable 287 | /// 288 | /// Disposes resources. 289 | /// 290 | /// if set to true, dispose managed resources. 291 | private void Dispose(bool disposing) { 292 | if (disposing) { 293 | // dispose managed resources 294 | foreach (WorkerThread worker in this.workerThreads) { 295 | worker.Dispose(); 296 | } 297 | this.workerThreads.Clear(); 298 | } 299 | // free native resources 300 | } 301 | 302 | /// 303 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 304 | /// 305 | public void Dispose() { 306 | Dispose(true); 307 | GC.SuppressFinalize(this); 308 | } 309 | #endregion 310 | } 311 | #endregion 312 | 313 | #region ParallelForEach class 314 | /// 315 | /// ParallelForEach state class. 316 | /// 317 | /// type 318 | public sealed class ParallelForEach : IDisposable { 319 | /// 320 | /// Single instance of parallelFor class for singleton pattern 321 | /// 322 | private volatile static ParallelForEach instance = null; 323 | 324 | /// 325 | /// Delegate defining Foreach loop body. 326 | /// 327 | /// Loop item. 328 | public delegate void ForEachLoopDelegate(T item); 329 | 330 | /// 331 | /// Foreach-loop body 332 | /// 333 | public ForEachLoopDelegate LoopFunction; 334 | 335 | /// 336 | /// Enumerator for the source IEnumerable. 337 | /// 338 | private IEnumerator enumerator; 339 | 340 | /// 341 | /// Number of threads to utilise 342 | /// 343 | private int threadCount = System.Environment.ProcessorCount; 344 | 345 | /// 346 | /// The worker threads. 347 | /// 348 | private List workerThreads; 349 | 350 | /// 351 | /// Runs the ForEach loop. 352 | /// 353 | /// The items. 354 | /// The loop body. 355 | public void DoForEach(IEnumerable items, ForEachLoopDelegate loopBody) { 356 | this.enumerator = items.GetEnumerator(); 357 | this.LoopFunction = loopBody; 358 | 359 | // Signal waiting task to all threads and mark them not idle. 360 | for (int i = 0; i < this.threadCount; i++) { 361 | WorkerThread workerThread = workerThreads[i]; 362 | workerThread.ThreadIdle.Reset(); 363 | workerThread.TaskWaiting.Set(); 364 | } 365 | 366 | // Wait until all threads become idle 367 | for (int i = 0; i < this.threadCount; i++) { 368 | WorkerThread workerThread = workerThreads[i]; 369 | workerThread.ThreadIdle.WaitOne(); 370 | } 371 | } 372 | 373 | /// 374 | /// Get instance of the ParallelFor class for singleton pattern and 375 | /// update the number of threads if appropriate. 376 | /// 377 | /// The thread count. 378 | /// 379 | public static ParallelForEach GetInstance(int threadCount) { 380 | 381 | if (instance == null) { 382 | instance = new ParallelForEach(); 383 | instance.threadCount = threadCount; 384 | instance.Initialize(); 385 | } 386 | else { 387 | // Ensure we have the correct number of threads. 388 | if (instance.workerThreads.Count != threadCount) { 389 | instance.Terminate(); 390 | instance.threadCount = threadCount; 391 | instance.Initialize(); 392 | } 393 | } 394 | return instance; 395 | } 396 | 397 | #region Private methods 398 | private void Initialize() { 399 | this.workerThreads = new List(); 400 | 401 | for (int i = 0; i < this.threadCount; i++) { 402 | WorkerThread workerThread = new WorkerThread(); 403 | workerThread.Thread = new Thread(new ParameterizedThreadStart(RunWorkerThread)); 404 | workerThread.Thread.Name = "worker " + i; 405 | workerThreads.Add(workerThread); 406 | 407 | workerThread.Thread.IsBackground = true; 408 | workerThread.Thread.Start(i); 409 | } 410 | } 411 | 412 | private void Terminate() { 413 | // Finish thread by setting null loop body and signaling about available task 414 | LoopFunction = null; 415 | int workerThreadCount = this.workerThreads.Count; 416 | for (int i = 0; i < workerThreadCount; i++) { 417 | this.workerThreads[i].Terminate(); 418 | } 419 | } 420 | 421 | private void RunWorkerThread(object threadIndex) { 422 | WorkerThread workerThread = workerThreads[(int)threadIndex]; 423 | 424 | while (true) { 425 | // Wait for a task. 426 | workerThread.TaskWaiting.WaitOne(); 427 | 428 | // Exit if task is empty. 429 | if (LoopFunction == null) { 430 | return; 431 | } 432 | 433 | bool didMoveNext; 434 | T localItem = default(T); 435 | lock (this.enumerator) { 436 | didMoveNext = enumerator.MoveNext(); 437 | if (didMoveNext) { 438 | localItem = enumerator.Current; 439 | } 440 | } 441 | 442 | while (didMoveNext == true) { 443 | ////Console.WriteLine("Thread " + threadIndex + " of " + workerThreads.Count + " running task " + localJobIndex); 444 | LoopFunction(localItem); 445 | lock (this.enumerator) { 446 | didMoveNext = enumerator.MoveNext(); 447 | if (didMoveNext) { 448 | localItem = enumerator.Current; 449 | } 450 | } 451 | } 452 | 453 | // Signal that thread is idle. 454 | workerThread.ThreadIdle.Set(); 455 | } 456 | } 457 | #endregion 458 | 459 | #region IDisposable 460 | /// 461 | /// Disposes resources. 462 | /// 463 | /// if set to true, dispose managed resources. 464 | private void Dispose(bool disposing) { 465 | if (disposing) { 466 | // dispose managed resources 467 | this.enumerator.Dispose(); 468 | foreach (WorkerThread worker in this.workerThreads) { 469 | worker.Dispose(); 470 | } 471 | this.workerThreads.Clear(); 472 | } 473 | // free native resources 474 | } 475 | 476 | /// 477 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 478 | /// 479 | public void Dispose() { 480 | Dispose(true); 481 | GC.SuppressFinalize(this); 482 | } 483 | #endregion 484 | } 485 | #endregion 486 | 487 | #region Class variables 488 | /// 489 | /// Object for thread locking 490 | /// 491 | private static object lockObject = new Object(); 492 | 493 | /// 494 | /// Number of threads to utilise 495 | /// 496 | private static int threadCount = System.Environment.ProcessorCount; 497 | #endregion 498 | 499 | #region Constructor 500 | /// 501 | /// Prevents a default instance of the class from being created. 502 | /// 503 | private Parallel() { 504 | // Do nothing. 505 | } 506 | #endregion 507 | 508 | #region IDisposable 509 | /// 510 | /// Disposes resources. 511 | /// 512 | /// if set to true, dispose managed resources. 513 | protected virtual void Dispose(bool disposing) { 514 | if (disposing) { 515 | // dispose managed resources 516 | // SAA TODO: Should we dispose the ParallelFor and ParallelForEach instances? 517 | } 518 | // free native resources 519 | } 520 | 521 | /// 522 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. 523 | /// 524 | public void Dispose() { 525 | Dispose(true); 526 | GC.SuppressFinalize(this); 527 | } 528 | #endregion 529 | 530 | #region Public methods 531 | /// 532 | /// Executes a parallel For loop. 533 | /// 534 | /// Loop start index. 535 | /// Loop stop index. 536 | /// Loop body. 537 | /// The method is used to parallelise for loop by running iterations across 538 | /// several threads. 539 | /// Example usage: 540 | /// 541 | /// for ( int i = 0; i < 10; i++ ) 542 | /// { 543 | /// System.Diagnostics.Debug.WriteLine( "i = " + i ); 544 | /// } 545 | /// 546 | /// can be replaced by: 547 | /// 548 | /// Parallel.For( 0, 10, delegate( int i ) 549 | /// { 550 | /// System.Diagnostics.Debug.WriteLine( "i = " + i ); 551 | /// } ); 552 | /// 553 | /// If Parallel.ThreadCount is exactly 1, no threads are spawned. 554 | /// 555 | public static void For(int start, int stop, ParallelFor.ForLoopDelegate loopBody) { 556 | if (Parallel.threadCount == 1) { 557 | for (int i = start; i < stop; i++) { 558 | loopBody(i); 559 | } 560 | } 561 | else { 562 | lock (lockObject) { 563 | ParallelFor parallel = ParallelFor.GetInstance(threadCount); 564 | parallel.DoFor(start, stop, loopBody); 565 | } 566 | } 567 | } 568 | 569 | /// 570 | /// Executes a parallel Foreach loop. 571 | /// 572 | /// type 573 | /// Loop items. 574 | /// Loop body. 575 | /// The method is used to parallelise for loop by running iterations across 576 | /// several threads. 577 | /// Example usage: 578 | /// 579 | /// foreach ( Molecule molecule in molecules ) 580 | /// { 581 | /// System.Diagnostics.Debug.WriteLine( "molecule.Title = " + molecule.Title ); 582 | /// } 583 | /// 584 | /// can be replaced by: 585 | /// 586 | /// Parallel.ForEach{Molecule}( molecules, delegate( Molecule molecule ) 587 | /// { 588 | /// System.Diagnostics.Debug.WriteLine( "molecule.Title = " + molecule.Title ); 589 | /// } ); 590 | /// 591 | /// If Parallel.ThreadCount is exactly 1, no threads are spawned. 592 | /// 593 | public static void ForEach(IEnumerable items, ParallelForEach.ForEachLoopDelegate loopBody) { 594 | if (Parallel.threadCount == 1) { 595 | foreach (T item in items) { 596 | loopBody(item); 597 | } 598 | } 599 | else { 600 | lock (lockObject) { 601 | ParallelForEach parallel = ParallelForEach.GetInstance(threadCount); 602 | parallel.DoForEach(items, loopBody); 603 | } 604 | } 605 | } 606 | #endregion 607 | 608 | #region Properties 609 | /// 610 | /// Gets or sets the number of threads used for parallel computations. 611 | /// 612 | /// The threads count. 613 | /// 614 | /// By default the property is number of CPUs, i.e., 615 | /// . Setting the 616 | /// property to zero also causes it to be reset to this value. 617 | /// 618 | public static int ThreadsCount { 619 | get { 620 | return Parallel.threadCount; 621 | } 622 | set { 623 | lock (lockObject) { 624 | Parallel.threadCount = value == 0 ? System.Environment.ProcessorCount : value; 625 | } 626 | } 627 | } 628 | #endregion 629 | } 630 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Parallel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3d917c835d433e42a00ed0c6ad807c5 3 | timeCreated: 1514636694 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Pool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using System.Collections.Generic; 4 | 5 | namespace Adrenak.Unex { 6 | public abstract class Pool { 7 | protected Stack m_Available = new Stack(); 8 | HashSet m_ToBeIgnored = new HashSet(); 9 | 10 | /// 11 | /// Gets a free instance from the pool. Constructs a new instance if none is free 12 | /// 13 | /// 14 | public T Get() { 15 | while(m_Available.Count > 0) { 16 | var instance = m_Available.Pop(); 17 | if (!m_ToBeIgnored.Contains(instance)) 18 | return instance; 19 | } 20 | Add(); 21 | return Get(); 22 | } 23 | 24 | /// 25 | /// Adds a new instance. To be override based on whether T is a component 26 | /// of a normal c# class 27 | /// 28 | protected abstract void Add(); 29 | 30 | /// 31 | /// Frees up the instance so that it can be retrieved by another request later 32 | /// 33 | /// 34 | public void Free(T obj) { 35 | m_Available.Push(obj); 36 | } 37 | 38 | /// 39 | /// 40 | /// 41 | public void Remove(T obj) { 42 | m_ToBeIgnored.Add(obj); 43 | } 44 | } 45 | 46 | /// 47 | /// An instance pool of a Unity component 48 | /// 49 | /// 50 | public class ComponentPool : Pool where T : Component { 51 | GameObjectPool m_Pool = new GameObjectPool(new GameObject("ComponentPoolContainer")); 52 | 53 | protected override void Add() { 54 | var container = m_Pool.Get(); 55 | container.name = typeof(T).FullName; 56 | var newInstance = container.AddComponent(); 57 | m_Available.Push(newInstance); 58 | } 59 | } 60 | 61 | /// 62 | /// An instance pool of a normal C# class 63 | /// 64 | /// 65 | public class ObjectPool : Pool { 66 | protected override void Add() { 67 | var def = default(T); 68 | var newInstance = Activator.CreateInstance(def.GetType()); 69 | m_Available.Push((T)newInstance); 70 | } 71 | } 72 | 73 | /// 74 | /// A Gameobject instance pool. Eg. Pool of bullet shells 75 | /// 76 | public class GameObjectPool : Pool { 77 | GameObject m_Instance; 78 | 79 | /// 80 | /// Constructs a gameobject pool with the given instance 81 | /// 82 | /// 83 | public GameObjectPool(GameObject instance) { 84 | m_Instance = instance; 85 | } 86 | 87 | /// 88 | /// Instantiates a copy of and adds it to the pool 89 | /// 90 | protected override void Add() { 91 | var newInstance = MonoBehaviour.Instantiate(m_Instance); 92 | m_Available.Push(newInstance); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Pool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be8f0e8e9dba2614cb7c2ef6bdc6e7ac 3 | timeCreated: 1518345278 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Runnable.cs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | // Uncomment to enable debugging of the Runnable class. 19 | //#define ENABLE_RUNNABLE_DEBUGGING 20 | 21 | using UnityEngine; 22 | using System.Collections; 23 | using System.Collections.Generic; 24 | 25 | namespace Adrenak.Unex { 26 | /// 27 | /// Helper class for running co-routines without having to inherit from MonoBehavior. 28 | /// 29 | public class Runnable : MonoBehaviour { 30 | 31 | static Runnable instance; 32 | #region Public Properties 33 | /// 34 | /// Returns the Runnable instance. 35 | /// 36 | public static Runnable Instance { 37 | get { 38 | if (instance == null) 39 | instance = FindObjectOfType(); 40 | if (instance == null) 41 | Init(); 42 | return instance; 43 | } 44 | } 45 | 46 | public static void Init(){ 47 | var go = new GameObject("Runnable"); 48 | go.hideFlags = HideFlags.HideAndDontSave; 49 | instance = go.AddComponent(); 50 | } 51 | #endregion 52 | 53 | #region Public Interface 54 | /// 55 | /// Start a co-routine function. 56 | /// 57 | /// The IEnumerator returns by the co-routine function the user is invoking. 58 | /// Returns a ID that can be passed into Stop() to halt the co-routine. 59 | public static int Run(IEnumerator routine) { 60 | Routine r = new Routine(routine); 61 | return r.ID; 62 | } 63 | 64 | /// 65 | /// Stops a active co-routine. 66 | /// 67 | /// THe ID of the co-routine to stop. 68 | public static void Stop(int ID) { 69 | Routine r = null; 70 | if (Instance._routines.TryGetValue(ID, out r)) 71 | r.Stop = true; 72 | } 73 | 74 | /// 75 | /// Check if a routine is still running. 76 | /// 77 | /// The ID returned by Run(). 78 | /// Returns true if the routine is still active. 79 | static public bool IsRunning(int id) { 80 | return Instance._routines.ContainsKey(id); 81 | } 82 | 83 | #if UNITY_EDITOR 84 | private static bool _editorRunnable = false; 85 | 86 | /// 87 | /// This function enables the Runnable in edit mode. 88 | /// 89 | public static void EnableRunnableInEditor() { 90 | if (!_editorRunnable) { 91 | _editorRunnable = true; 92 | UnityEditor.EditorApplication.update += UpdateRunnable; 93 | } 94 | } 95 | static void UpdateRunnable() { 96 | if (!Application.isPlaying) 97 | Instance.UpdateRoutines(); 98 | } 99 | 100 | #endif 101 | #endregion 102 | 103 | #region Private Types 104 | /// 105 | /// This class handles a running co-routine. 106 | /// 107 | private class Routine : IEnumerator { 108 | #region Public Properties 109 | public int ID { get; private set; } 110 | public bool Stop { get; set; } 111 | #endregion 112 | 113 | #region Private Data 114 | private bool _moveNext = false; 115 | private IEnumerator _enumerator = null; 116 | #endregion 117 | 118 | public Routine(IEnumerator a_enumerator) { 119 | _enumerator = a_enumerator; 120 | Instance.StartCoroutine(this); 121 | Stop = false; 122 | ID = Instance._nextRoutineId++; 123 | 124 | Instance._routines[ID] = this; 125 | #if ENABLE_RUNNABLE_DEBUGGING 126 | Log.Debug("Runnable.Routine()", "Coroutine {0} started.", ID ); 127 | #endif 128 | } 129 | 130 | #region IEnumerator Interface 131 | public object Current { get { return _enumerator.Current; } } 132 | public bool MoveNext() { 133 | _moveNext = _enumerator.MoveNext(); 134 | if (_moveNext && Stop) 135 | _moveNext = false; 136 | 137 | if (!_moveNext) { 138 | Runnable.Instance._routines.Remove(ID); // remove from the mapping 139 | } 140 | 141 | return _moveNext; 142 | } 143 | public void Reset() { _enumerator.Reset(); } 144 | #endregion 145 | } 146 | #endregion 147 | 148 | #region Private Data 149 | private Dictionary _routines = new Dictionary(); 150 | private int _nextRoutineId = 1; 151 | #endregion 152 | 153 | /// 154 | /// THis can be called by the user to force all co-routines to get a time slice, this is usually 155 | /// invoked from an EditorApplication.Update callback so we can use runnable in Editor mode. 156 | /// 157 | public void UpdateRoutines() { 158 | if (_routines.Count > 0) { 159 | // we are not in play mode, so we must manually update our co-routines ourselves 160 | List routines = new List(); 161 | foreach (var kp in _routines) 162 | routines.Add(kp.Value); 163 | 164 | foreach (var r in routines) 165 | r.MoveNext(); 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Runnable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50e1e8f3a8c708a4cb49a6a0de284d69 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/ScreenX.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Adrenak.Unex { 4 | public class ScreenX { 5 | public static int Height { 6 | get { return (int)WindowSize.x; } 7 | } 8 | 9 | public static int Width { 10 | get { return (int)WindowSize.y; } 11 | } 12 | 13 | /// 14 | /// Gets the current window size. 15 | /// In the build, this returns Screen.width, Screen.height 16 | /// In the editor, this returns the size of the Game Window using reflection 17 | /// 18 | public static Vector2 WindowSize { 19 | get { 20 | // Screen.width and Screen.height sometimes return the dimensions of the inspector 21 | // window when Screen.width originates from a ContextMenu or Button attribute 22 | // We use reflection to get the actual dimensions. During runtime we simply use Screen again 23 | #if UNITY_EDITOR 24 | System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); 25 | System.Reflection.MethodInfo GetSizeOfMainGameView = T.GetMethod("GetSizeOfMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); 26 | System.Object Res = GetSizeOfMainGameView.Invoke(null, null); 27 | return (Vector2)Res; 28 | #else 29 | return new Vector2( 30 | Screen.width, 31 | Screen.height 32 | ); 33 | #endif 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/ScreenX.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8df55c537ec32ac468563b1a11e5711a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/TaskGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Collections.Generic; 5 | 6 | namespace Adrenak.Unex { 7 | public class TaskGroup { 8 | public event Action SingleTaskCompleted; 9 | 10 | Dictionary> taskMap; 11 | 12 | public TaskGroup(Dictionary> map) { 13 | taskMap = map; 14 | } 15 | 16 | public async Task> Run() { 17 | var resultMap = new Dictionary(); 18 | 19 | while (taskMap.Count != 0) { 20 | var done = await Task.WhenAny(taskMap.Values.ToList()); 21 | var index = taskMap.Values.ToList().IndexOf(done); 22 | var key = taskMap.Keys.ToList()[index]; 23 | 24 | resultMap.Add(key, done.Result); 25 | SingleTaskCompleted?.Invoke(done.Result, index); 26 | taskMap.Remove(key); 27 | } 28 | 29 | return resultMap; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/TaskGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7571b411073f454db7466763fed2e95 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/TaskX.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | namespace Adrenak.Unex { 7 | public class TaskX { 8 | public static Task WaitTillNextFrame() { 9 | return WaitForFrames(1); 10 | } 11 | 12 | public async static Task WaitForFrames(int frames) { 13 | int startFrame = Time.frameCount; 14 | while (true) { 15 | if (Time.frameCount >= startFrame + frames) 16 | break; 17 | else 18 | await Task.Delay(TimeSpan.FromSeconds(Time.unscaledDeltaTime / 2)); 19 | } 20 | } 21 | 22 | public async static Task WaitForSeconds(float seconds) { 23 | await Task.Delay(TimeSpan.FromSeconds(seconds)); 24 | } 25 | 26 | public async static Task WaitWhile(Func condition) { 27 | if (condition()) 28 | await Task.FromResult(WaitTillNextFrame()); 29 | } 30 | 31 | public async static Task WaitUntil(Func condition) { 32 | if (condition() == false) 33 | await Task.FromResult(WaitTillNextFrame()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/TaskX.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bd61e862d8933f49a646dcee9ce7b3e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Texture32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Adrenak.Unex { 5 | /// 6 | /// A class to hold texture data as Color32 internally. 7 | /// All operations are done over only the array and 8 | /// 9 | public class Texture32 { 10 | public Color32[] Pixels { get; private set; } 11 | public int Width { get; private set; } 12 | public int Height { get; private set; } 13 | 14 | /// 15 | /// Creates an empty instance of the given width and height 16 | /// 17 | /// 18 | /// 19 | public Texture32(int width, int height) { 20 | Pixels = new Color32[width * height]; 21 | Width = width; 22 | Height = height; 23 | } 24 | 25 | /// 26 | /// Creates an instance from the pixels and the width and height they represent 27 | /// 28 | public Texture32(Color32[] pixels, int width, int height) { 29 | Pixels = pixels; 30 | Width = width; 31 | Height = height; 32 | } 33 | 34 | /// 35 | /// Creates a Texture32 isntance from a Texture2D object 36 | /// 37 | /// The Texture2D object from which the instance should be created 38 | /// The new Texture32 instance 39 | public static Texture32 FromTexture2D(Texture2D tex) { 40 | return new Texture32(tex.GetPixels32(), tex.width, tex.height); 41 | } 42 | 43 | /// 44 | /// Gets the pixels at the given coordinates 45 | /// 46 | public Color32 GetPixel(int x, int y) { 47 | return Pixels[Width * y + x]; 48 | } 49 | 50 | /// 51 | /// Sets a value to the given pixel 52 | /// 53 | public void SetPixel(int x, int y, Color32 pixel) { 54 | Pixels[Width * y + x] = pixel; 55 | } 56 | 57 | /// 58 | /// Returns a block of pixels from the Texture2D 59 | /// 60 | /// The X coordinate from where the block starts (bottom left) 61 | /// The Y coordinate from where the block starts (bottom left) 62 | /// The width of the block returned 63 | /// The height of the block returned 64 | /// 65 | public Texture32 GetBlock(int x, int y, int width, int height) { 66 | try { 67 | Color32[] bytes = new Color32[width * height]; 68 | 69 | int index = 0; 70 | for (int j = y; j < y + height; j++) { 71 | for (int i = x; i < x + width; i++) { 72 | bytes[index] = GetPixel(i, j); 73 | index++; 74 | } 75 | } 76 | return new Texture32(bytes, width, height); 77 | } 78 | catch(Exception e) { 79 | Debug.LogError(e); 80 | return null; 81 | } 82 | } 83 | 84 | /// 85 | /// Crops the texture represented by the pixels 86 | /// 87 | /// The X coordinate from where the cropping starts (bottom left) 88 | /// The Y coordinate from where the cropping starts (bottom left) 89 | /// The width of the texture after cropping 90 | /// The height of the texture after cropping 91 | public void Crop(int x, int y, int width, int height) { 92 | try { 93 | var block = GetBlock(x, y, width, height); 94 | Pixels = block.Pixels; 95 | Width = block.Width; 96 | Height = block.Height; 97 | } 98 | catch(Exception e) { 99 | Debug.LogError(e); 100 | } 101 | } 102 | 103 | /// 104 | /// Replaces a block of pixels with the ones in the provided Texture32 105 | /// 106 | /// The X coordinate from where the replacement should started 107 | /// The Y coordinate from where the replacement should started 108 | /// the Texture32 instance that is used to replace 109 | public void ReplaceBlock(int destX, int destY, Texture32 tex) { 110 | ReplaceBlock(destX, destY, tex.Pixels, tex.Width, tex.Height); 111 | } 112 | 113 | /// 114 | /// Replaces a block of pixels with the onces provided 115 | /// 116 | /// The X coordinate from where the replacement should started 117 | /// The Y coordinate from where the replacement should be started 118 | /// The pixels with this the Texture32 pixels are to be replaced 119 | /// The width of the block 120 | /// The height of the block 121 | public void ReplaceBlock(int destX, int destY, Color32[] pixels, int sourceWidth, int sourceHeight) { 122 | try { 123 | for(int i = 0; i < sourceWidth; i++) { 124 | for(int j = 0; j < sourceHeight; j++) { 125 | var pixel = pixels[j * sourceWidth + i]; 126 | SetPixel(destX + i, destY + j, pixel); 127 | } 128 | } 129 | } 130 | catch(Exception e) { 131 | Debug.LogError(e); 132 | } 133 | } 134 | 135 | /// 136 | /// Creates and returns a Texture2D objects from the internal Color32 pixels 137 | /// 138 | /// The format of the texture to be created 139 | /// Whether the created texture has mip maps 140 | /// Whether the creates texture is linear 141 | /// 142 | public Texture2D GetTexture2D(TextureFormat format, bool isMipMapped = true, bool isLinear = true) { 143 | var result = new Texture2D(Width, Height, format, isMipMapped, isLinear); 144 | result.SetPixels32(Pixels); 145 | result.Apply(); 146 | return result; 147 | } 148 | 149 | /// 150 | /// Clears the pixels and sets size to zero 151 | /// 152 | public void Clear() { 153 | Pixels = null; 154 | Width = 0; 155 | Height = 0; 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Runtime/Utils/Texture32.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b6f5c03f3965654bb2a93b8c87dafcb 3 | timeCreated: 1548853603 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d47a05bdabc7ea46a851133f091d8cf 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Adrenak.Unex.Samples.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Adrenak.Unex.Samples", 3 | "references": [ 4 | "Adrenak.Unex.Runtime" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [] 14 | } -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Adrenak.Unex.Samples.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22971a1ba2ff1f0499c2f52379152b78 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4474a3a1ed8f6e2498fddfdb58bde8c8 3 | folderAsset: yes 4 | timeCreated: 1518509576 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Materials/Blue.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/Adrenak.Unex/Samples/Materials/Blue.mat -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Materials/Blue.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5919c93d09416af4f840ed14df5fcb67 3 | timeCreated: 1518510070 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Materials/Maroon.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/Adrenak.Unex/Samples/Materials/Maroon.mat -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Materials/Maroon.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d2ed81e716f34e478fd78c7ec5f9fac 3 | timeCreated: 1518509583 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Monitor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d98138024221af342b053785a32428b1 3 | folderAsset: yes 4 | timeCreated: 1518587702 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Monitor/MonitorDemo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Adrenak.Unex; 3 | 4 | namespace Adrenak.Unex.Samples{ 5 | public class MonitorDemo : MonoBehaviour { 6 | public GameObject toMonitor; 7 | 8 | void Start () { 9 | toMonitor.GetMonitor().HandleCollisionEnter(collision => { 10 | Debug.Log("Object Collided with " + collision.collider.name); 11 | }); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Monitor/MonitorDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95715b6ee65154c47984aa0f25c905eb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Monitor/MonitorDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/Adrenak.Unex/Samples/Monitor/MonitorDemo.unity -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Monitor/MonitorDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69d260587f9ea0646baf8ba59afbb219 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Pool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b30534d570717824383eee8055a6cd82 3 | folderAsset: yes 4 | timeCreated: 1518505867 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Pool/PoolDemo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Adrenak.Unex; 4 | using System.Collections; 5 | 6 | namespace Adrenak.Unex.Samples{ 7 | public class PoolDemo : MonoBehaviour { 8 | GameObjectPool m_Pool; 9 | public int emisssionRate; 10 | public GameObject prefabReference; 11 | public Vector3 maxForce; 12 | public Transform parent; 13 | 14 | void Start () { 15 | m_Pool = new GameObjectPool(prefabReference); 16 | StartCoroutine(StartStuff()); 17 | } 18 | 19 | IEnumerator StartStuff() { 20 | while (true) { 21 | for(int i = 0; i < emisssionRate; i++) { 22 | var newInstance = m_Pool.Get(); 23 | 24 | // Set a single parent to batch instances 25 | newInstance.transform.SetParent(parent); 26 | 27 | // slow down to zero, Set to origin and apply force 28 | var rigidbody = newInstance.GetComponent(); 29 | rigidbody.velocity = Vector3.zero; 30 | 31 | // Move to position 32 | newInstance.transform.position = transform.position; 33 | 34 | // random force value 35 | var force = new Vector3( 36 | maxForce.x * (UnityEngine.Random.value - .5F), 37 | maxForce.y * (UnityEngine.Random.value - .5F), 38 | maxForce.z * (UnityEngine.Random.value - .5F) 39 | ); 40 | 41 | // Apply force 42 | rigidbody.AddForce(force, ForceMode.Impulse); 43 | 44 | // Handle recycling when the prefab hits the floor 45 | HandleCollision(newInstance); 46 | } 47 | yield return null; 48 | } 49 | } 50 | 51 | void HandleCollision(GameObject go) { 52 | go.GetMonitor().HandleTriggerEnter(_ => { 53 | if (_.name.Equals("Floor")) 54 | m_Pool.Free(go); 55 | }); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Pool/PoolDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97e91bc1875d3c447a9d932823a0d681 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Pool/PoolDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/Adrenak.Unex/Samples/Pool/PoolDemo.unity -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Pool/PoolDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbb84dddcd2d58841a6c903da7b0f784 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8f3e39154c82e94a900c2c0e368804a 3 | folderAsset: yes 4 | timeCreated: 1518507012 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Prefabs/Cube.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/Assets/Adrenak.Unex/Samples/Prefabs/Cube.prefab -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/Samples/Prefabs/Cube.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d15f788920a55bc4fa9491c1b1df23a2 3 | timeCreated: 1518507015 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.adrenak.unex", 3 | "version": "2.5.0", 4 | "displayName": "Unex", 5 | "description": "Unity3D, extended. Includes hotkeys, C# extensions, utilities and more.", 6 | "unity": "2018.4", 7 | "author": { 8 | "name": "Vatsal Ambastha", 9 | "email": "ambastha.vatsal@gmail.com", 10 | "url": "http://www.vatsalambastha.com" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/Adrenak.Unex/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b71d5d4dc3743534892d08de8ef62268 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.package-manager-ui": "2.0.13", 4 | "com.unity.modules.assetbundle": "1.0.0", 5 | "com.unity.modules.audio": "1.0.0", 6 | "com.unity.modules.imageconversion": "1.0.0", 7 | "com.unity.modules.imgui": "1.0.0", 8 | "com.unity.modules.physics": "1.0.0", 9 | "com.unity.modules.ui": "1.0.0", 10 | "com.unity.modules.umbra": "1.0.0", 11 | "com.unity.modules.unitywebrequest": "1.0.0", 12 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 13 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 14 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 15 | "com.unity.modules.unitywebrequestwww": "1.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96b05a68e64db664bbd1137298f7d897 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13e280ceee6b80e4db87a46ad59be4ad 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e992428c09a0e84681a4a90a5142390 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 621a4f3289db05f4f91c9c2e7a1ec64f 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b2855e053c63a34f8a4249f4e9239b6 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2232fb59d9080a245bcc81bd6344d341 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75d541dd71efd024da76258510dadf25 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98b7a548b4fcd5945ad08203a6745ee9 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eead64c8d6075db40a1141716a0712c0 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.4.30f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b596a241f132d2b47b5fd5b209650915 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 457251d2497489a419f8e1b646575c2b 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ff3046635a039346be00b9a91502425 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b8a9d225a7627041b4bbc85c72b9a0b 3 | timeCreated: 1512553230 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrenak/unex/aa60e785f92764301af1c17507fb92c23757e896/ProjectSettings/VFXManager.asset --------------------------------------------------------------------------------