├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yaml │ ├── config.yml │ ├── feature-request.yaml │ └── improvement-request.yaml └── workflows │ ├── build.yaml │ ├── documentation.yaml │ ├── release.yaml │ └── tests.yaml ├── .gitignore ├── .vsconfig ├── Assembly-CSharp-Editor.csproj ├── Assets ├── MackySoft.meta ├── MackySoft │ ├── MackySoft.XPool.meta │ └── MackySoft.XPool │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── MackySoft.XPool.Editor.asmdef │ │ ├── MackySoft.XPool.Editor.asmdef.meta │ │ ├── Timers.meta │ │ ├── Timers │ │ │ ├── PeriodicTimerDrawer.cs │ │ │ └── PeriodicTimerDrawer.cs.meta │ │ ├── Unity.meta │ │ └── Unity │ │ │ ├── SerializedPropertyUtility.cs │ │ │ ├── SerializedPropertyUtility.cs.meta │ │ │ ├── UnityObjectPoolDrawer.cs │ │ │ └── UnityObjectPoolDrawer.cs.meta │ │ ├── Runtime.meta │ │ ├── Runtime │ │ ├── Collections.meta │ │ ├── Collections │ │ │ ├── Array.meta │ │ │ ├── Array │ │ │ │ ├── ArrayPool.cs │ │ │ │ ├── ArrayPool.cs.meta │ │ │ │ ├── ArrayPoolExtensions.cs │ │ │ │ ├── ArrayPoolExtensions.cs.meta │ │ │ │ ├── ArrayPoolUtility.cs │ │ │ │ ├── ArrayPoolUtility.cs.meta │ │ │ │ ├── Temporary.meta │ │ │ │ └── Temporary │ │ │ │ │ ├── Array.meta │ │ │ │ │ ├── Array │ │ │ │ │ ├── TemporaryArray.Create.cs │ │ │ │ │ ├── TemporaryArray.Create.cs.meta │ │ │ │ │ ├── TemporaryArray.cs │ │ │ │ │ └── TemporaryArray.cs.meta │ │ │ │ │ ├── List.meta │ │ │ │ │ ├── List │ │ │ │ │ ├── TemporaryList.Create.cs │ │ │ │ │ ├── TemporaryList.Create.cs.meta │ │ │ │ │ ├── TemporaryList.cs │ │ │ │ │ └── TemporaryList.cs.meta │ │ │ │ │ ├── Queue.meta │ │ │ │ │ ├── Queue │ │ │ │ │ ├── TemporaryQueue.Create.cs │ │ │ │ │ ├── TemporaryQueue.Create.cs.meta │ │ │ │ │ ├── TemporaryQueue.cs │ │ │ │ │ └── TemporaryQueue.cs.meta │ │ │ │ │ ├── Stack.meta │ │ │ │ │ └── Stack │ │ │ │ │ ├── TemporaryStack.Create.cs │ │ │ │ │ ├── TemporaryStack.Create.cs.meta │ │ │ │ │ ├── TemporaryStack.cs │ │ │ │ │ └── TemporaryStack.cs.meta │ │ │ ├── CollectionPool.cs │ │ │ ├── CollectionPool.cs.meta │ │ │ ├── CollectionPoolUtility.cs │ │ │ ├── CollectionPoolUtility.cs.meta │ │ │ ├── Internal.meta │ │ │ ├── Internal │ │ │ │ ├── RuntimeHelpers.cs │ │ │ │ └── RuntimeHelpers.cs.meta │ │ │ ├── ObjectModel.meta │ │ │ └── ObjectModel │ │ │ │ ├── CollectionPoolBase.cs │ │ │ │ └── CollectionPoolBase.cs.meta │ │ ├── FactoryPool.cs │ │ ├── FactoryPool.cs.meta │ │ ├── IPool.cs │ │ ├── IPool.cs.meta │ │ ├── Internal.meta │ │ ├── Internal │ │ │ ├── Disposable.cs │ │ │ ├── Disposable.cs.meta │ │ │ ├── Error.cs │ │ │ └── Error.cs.meta │ │ ├── MackySoft.XPool.asmdef │ │ ├── MackySoft.XPool.asmdef.meta │ │ ├── ObjectModel.meta │ │ ├── ObjectModel │ │ │ ├── PoolBase.cs │ │ │ └── PoolBase.cs.meta │ │ ├── PoolExtensions.cs │ │ ├── PoolExtensions.cs.meta │ │ ├── Properties.meta │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ └── AssemblyInfo.cs.meta │ │ ├── RentInstance.cs │ │ ├── RentInstance.cs.meta │ │ ├── Timers.meta │ │ ├── Timers │ │ │ ├── ITimer.cs │ │ │ ├── ITimer.cs.meta │ │ │ ├── PeriadicTimer.cs │ │ │ ├── PeriadicTimer.cs.meta │ │ │ ├── PoolExtensions.Timer.cs │ │ │ ├── PoolExtensions.Timer.cs.meta │ │ │ ├── TimerTicker.cs │ │ │ └── TimerTicker.cs.meta │ │ ├── Unity.meta │ │ └── Unity │ │ │ ├── ComponentPool.cs │ │ │ ├── ComponentPool.cs.meta │ │ │ ├── ComponentPool.meta │ │ │ ├── ComponentPool │ │ │ ├── ParticleSystemPool.cs │ │ │ └── ParticleSystemPool.cs.meta │ │ │ ├── DefaultFunctions.cs │ │ │ ├── DefaultFunctions.cs.meta │ │ │ ├── GameObjectPool.cs │ │ │ ├── GameObjectPool.cs.meta │ │ │ ├── IUnityObjectPool.cs │ │ │ ├── IUnityObjectPool.cs.meta │ │ │ ├── ObjectModel.meta │ │ │ ├── ObjectModel │ │ │ ├── ComponentPoolBase.cs │ │ │ ├── ComponentPoolBase.cs.meta │ │ │ ├── UnityObjectPoolBase.cs │ │ │ └── UnityObjectPoolBase.cs.meta │ │ │ ├── UnityObjectPool.cs │ │ │ └── UnityObjectPool.cs.meta │ │ ├── Tests.meta │ │ ├── Tests │ │ ├── Editor.meta │ │ └── Editor │ │ │ ├── Collections.meta │ │ │ ├── Collections │ │ │ ├── ArrayPoolTest.cs │ │ │ ├── ArrayPoolTest.cs.meta │ │ │ ├── CollectionPoolBaseTest.cs │ │ │ ├── CollectionPoolBaseTest.cs.meta │ │ │ ├── TemporaryArrayTest.cs │ │ │ ├── TemporaryArrayTest.cs.meta │ │ │ ├── TemporaryListTest.cs │ │ │ ├── TemporaryListTest.cs.meta │ │ │ ├── TemporaryQueueTest.cs │ │ │ ├── TemporaryQueueTest.cs.meta │ │ │ ├── TemporaryStackTest.cs │ │ │ └── TemporaryStackTest.cs.meta │ │ │ ├── FactoryPoolTest.cs │ │ │ ├── FactoryPoolTest.cs.meta │ │ │ ├── MackySoft.XPool.Tests.Editor.asmdef │ │ │ ├── MackySoft.XPool.Tests.Editor.asmdef.meta │ │ │ ├── PoolExtensions.cs │ │ │ ├── PoolExtensions.cs.meta │ │ │ ├── Timers.meta │ │ │ ├── Timers │ │ │ ├── PeriodicTimerTest.cs │ │ │ └── PeriodicTimerTest.cs.meta │ │ │ ├── Unit.cs │ │ │ ├── Unit.cs.meta │ │ │ ├── Unity.meta │ │ │ └── Unity │ │ │ ├── ObjectModel.meta │ │ │ ├── ObjectModel │ │ │ ├── UnityObjectPoolBaseTest.cs │ │ │ └── UnityObjectPoolBaseTest.cs.meta │ │ │ ├── UnityObjectPoolTest.cs │ │ │ └── UnityObjectPoolTest.cs.meta │ │ ├── package.json │ │ └── package.json.meta ├── PackageTools.meta └── PackageTools │ ├── Editor.meta │ └── Editor │ ├── UnityPackageExporter.cs │ └── UnityPackageExporter.cs.meta ├── Documentation ├── changelog │ ├── CHANGELOG.md │ └── toc.yml ├── docfx.json ├── filterConfig.yml └── toc.yml ├── LICENSE ├── MackySoft.XPool.Editor.csproj ├── MackySoft.XPool.Tests.Editor.csproj ├── MackySoft.XPool.csproj ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Packages │ └── com.unity.testtools.codecoverage │ │ └── Settings.json ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset ├── XRSettings.asset └── boot.config ├── README.md └── XPool.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yaml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: File a bug report 3 | title: "[BUG] " 4 | labels: ["bug"] 5 | assignees: 6 | - mackysoft 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thanks for taking the time to fill out this bug report! 12 | - type: textarea 13 | id: what-happened 14 | attributes: 15 | label: What happened? 16 | description: Also tell us, what did you expect to happen? 17 | placeholder: Tell us what you see! 18 | value: "A bug happened!" 19 | validations: 20 | required: true 21 | - type: input 22 | id: version 23 | attributes: 24 | label: XPool Version 25 | description: What version of XPool were you running? 26 | placeholder: ex. 0.1.0 27 | validations: 28 | required: true 29 | - type: input 30 | id: unity-version 31 | attributes: 32 | label: Unity Version 33 | description: What version of Unity were you running? 34 | placeholder: ex. 2020.3.24f1 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Scripting API 4 | url: https://mackysoft.github.io/XPool/api/MackySoft.XPool.html 5 | about: You may find the feature you are looking for. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yaml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Suggest an idea for this library 3 | title: "[FEATURE] " 4 | labels: ["enhancement"] 5 | assignees: 6 | - mackysoft 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thanks for taking the time to fill out this feature request! 12 | - type: textarea 13 | id: feature-description 14 | attributes: 15 | label: Feature destription 16 | validations: 17 | required: true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/improvement-request.yaml: -------------------------------------------------------------------------------- 1 | name: Improvement Request 2 | description: Suggest an improve for this library 3 | title: "[IMPROVE] " 4 | labels: ["enhancement"] 5 | assignees: 6 | - mackysoft 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thanks for taking the time to fill out this improvement request! 12 | - type: textarea 13 | id: improvement-description 14 | attributes: 15 | label: Improvement destription 16 | validations: 17 | required: true -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | 6 | jobs: 7 | build: 8 | name: ${{ matrix.targetPlatform }} 9 | runs-on: ubuntu-latest 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | targetPlatform: 14 | - StandaloneOSX # Build a macOS standalone (Intel 64-bit). 15 | - StandaloneWindows # Build a Windows standalone. 16 | - StandaloneWindows64 # Build a Windows 64-bit standalone. 17 | - StandaloneLinux64 # Build a Linux 64-bit standalone. 18 | - iOS # Build an iOS player. 19 | - Android # Build an Android .apk standalone app. 20 | - WebGL # WebGL. 21 | 22 | steps: 23 | # Checkout 24 | - name: Checkout 25 | uses: actions/checkout@v2 26 | with: 27 | fetch-depth: 0 28 | lfs: true 29 | 30 | # Cache 31 | - name: Cache 32 | uses: actions/cache@v2 33 | with: 34 | path: Library 35 | key: Library-${{ matrix.targetPlatform }} 36 | restore-keys: Library- 37 | 38 | # Build 39 | - name: Build 40 | uses: game-ci/unity-builder@v2 41 | env: 42 | UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_2020 }} 43 | with: 44 | targetPlatform: ${{ matrix.targetPlatform }} 45 | 46 | - name: Upload Artifacts 47 | uses: actions/upload-artifact@v2 48 | with: 49 | name: Build-${{ matrix.targetPlatform }} 50 | path: build/${{ matrix.targetPlatform }} -------------------------------------------------------------------------------- /.github/workflows/documentation.yaml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | # Build the documentation 10 | build: 11 | runs-on: windows-latest # Required by DocFX 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | # with: 16 | # submodules: true 17 | 18 | - name: Install DocFX 19 | run: choco install -y docfx 20 | 21 | - name: Use README.md as index.md 22 | run: cp README.md Documentation/index.md 23 | 24 | - name: Build 25 | run: docfx Documentation/docfx.json 26 | 27 | # Upload the generated documentation 28 | - name: Upload site artifact 29 | uses: actions/upload-artifact@v1 30 | with: 31 | name: _site 32 | path: _site # Must equals the 'build.dest' value on your docfx.json 33 | 34 | # Deploy the generated documentation to the gh-pages branch 35 | deploy: 36 | needs: build 37 | runs-on: ubuntu-latest 38 | steps: 39 | - name: Checkout 40 | uses: actions/checkout@v2 41 | # with: 42 | # submodules: true 43 | 44 | # Download the generated documentation 45 | - name: Download site artifact 46 | uses: actions/download-artifact@v1 47 | with: 48 | name: _site 49 | 50 | - name: Deploy 51 | uses: peaceiris/actions-gh-pages@v3 52 | with: 53 | github_token: ${{ secrets.GITHUB_TOKEN }} 54 | publish_branch: gh-pages 55 | publish_dir: _site -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | tag: 7 | description: "tag: git tag you want create. (sample 1.0.0)" 8 | required: true 9 | 10 | env: 11 | GIT_TAG: ${{ github.event.inputs.tag }} 12 | 13 | jobs: 14 | update-packagejson: 15 | runs-on: ubuntu-latest 16 | env: 17 | TARGET_FILE: ./Assets/MackySoft/MackySoft.XPool/package.json 18 | outputs: 19 | sha: ${{ steps.commit.outputs.sha }} 20 | steps: 21 | - uses: actions/checkout@v2 22 | - name: Output package.json (Before) 23 | run: cat ${{ env.TARGET_FILE}} 24 | 25 | - name: Update package.json to version ${{ env.GIT_TAG }} 26 | run: sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }} 27 | 28 | - name: Check update 29 | id: check_update 30 | run: | 31 | cat ${{ env.TARGET_FILE}} 32 | git diff --exit-code || echo "::set-output name=changed::1" 33 | 34 | - name: Commit files 35 | id: commit 36 | if: steps.check_update.outputs.changed == '1' 37 | run: | 38 | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" 39 | git config --local user.name "github-actions[bot]" 40 | git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a 41 | echo "::set-output name=sha::$(git rev-parse HEAD)" 42 | 43 | - name: Check sha 44 | run: echo "SHA ${SHA}" 45 | env: 46 | SHA: ${{ steps.commit.outputs.sha }} 47 | 48 | - name: Create Tag 49 | if: steps.check_update.outputs.changed == '1' 50 | run: git tag ${{ env.GIT_TAG }} 51 | 52 | - name: Push changes 53 | if: steps.check_update.outputs.changed == '1' 54 | uses: ad-m/github-push-action@master 55 | with: 56 | github_token: ${{ secrets.GITHUB_TOKEN }} 57 | branch: ${{ github.ref }} 58 | tags: true 59 | 60 | build: 61 | needs: [update-packagejson] 62 | strategy: 63 | matrix: 64 | unity: ["2020.3.24f1"] 65 | include: 66 | - unityVersion: 2020.3.24f1 67 | license: UNITY_LICENSE_2020 68 | runs-on: ubuntu-latest 69 | timeout-minutes: 15 70 | steps: 71 | - run: echo ${{ needs.update-packagejson.outputs.sha }} 72 | - uses: actions/checkout@v2 73 | with: 74 | ref: ${{ needs.update-packagejson.outputs.sha }} 75 | 76 | - name: Export unitypackage 77 | uses: game-ci/unity-builder@v2 78 | env: 79 | UNITY_LICENSE: ${{ secrets[matrix.license] }} 80 | with: 81 | projectPath: . 82 | unityVersion: ${{ matrix.unityVersion }} 83 | targetPlatform: StandaloneLinux64 84 | buildMethod: MackySoft.PackageTools.Editor.UnityPackageExporter.Export 85 | versioning: None 86 | 87 | - name: check all .meta is commited 88 | run: | 89 | if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then 90 | echo "Detected .meta file generated. Do you forgot commit a .meta file?" 91 | exit 1 92 | else 93 | echo "Great, all .meta files are commited." 94 | fi 95 | working-directory: . 96 | 97 | # Store artifacts. 98 | - uses: actions/upload-artifact@v2 99 | with: 100 | name: XPool.unitypackage 101 | path: ./Build/XPool.unitypackage 102 | 103 | create-release: 104 | needs: [update-packagejson, build] 105 | runs-on: ubuntu-latest 106 | steps: 107 | # Create Releases 108 | - uses: actions/create-release@v1 109 | id: create_release 110 | env: 111 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 112 | with: 113 | tag_name: ${{ env.GIT_TAG }} 114 | release_name: ${{ env.GIT_TAG }} 115 | commitish: ${{ needs.update-packagejson.outputs.sha }} 116 | draft: true 117 | prerelease: false 118 | 119 | # Download(All) Artifacts to current directory 120 | - uses: actions/download-artifact@v2 121 | 122 | # Upload to Releases(unitypackage) 123 | - uses: actions/upload-release-asset@v1 124 | env: 125 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 126 | with: 127 | upload_url: ${{ steps.create_release.outputs.upload_url }} 128 | asset_path: ./XPool.unitypackage/XPool.unitypackage 129 | asset_name: XPool.unitypackage 130 | asset_content_type: application/octet-stream -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: push 4 | 5 | jobs: 6 | test: 7 | name: ${{ matrix.testMode }} on ${{ matrix.unityVersion }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | projectPath: 13 | - . 14 | unityVersion: 15 | - 2020.3.24f1 16 | testMode: 17 | - editmode 18 | steps: 19 | # Checkout 20 | - name: Checkout 21 | uses: actions/checkout@v2 22 | with: 23 | lfs: true 24 | 25 | # Cache 26 | - name: Cache 27 | uses: actions/cache@v2 28 | with: 29 | path: ${{ matrix.projectPath }}/Library 30 | key: Library-${{ matrix.projectPath }} 31 | restore-keys: | 32 | Library- 33 | 34 | # Tests 35 | - name: Tests 36 | uses: game-ci/unity-test-runner@v2 37 | id: tests 38 | env: 39 | UNITY_LICENSE: ${{ secrets.UNITY_LICENSE_2020 }} 40 | with: 41 | projectPath: ${{ matrix.projectPath }} 42 | unityVersion: ${{ matrix.unityVersion }} 43 | testMode: ${{ matrix.testMode }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Asset meta data should only be ignored when the corresponding asset is also ignored 18 | !/[Aa]ssets/**/*.meta 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.unityproj 36 | *.suo 37 | *.tmp 38 | *.user 39 | *.userprefs 40 | *.pidb 41 | *.booproj 42 | *.svd 43 | *.pdb 44 | *.mdb 45 | *.opendb 46 | *.VC.db 47 | 48 | # Unity3D generated meta files 49 | *.pidb.meta 50 | *.pdb.meta 51 | *.mdb.meta 52 | 53 | # Unity3D generated file on crash reports 54 | sysinfo.txt 55 | 56 | # Builds 57 | *.apk 58 | *.unitypackage 59 | 60 | # Crashlytics generated file 61 | crashlytics-build.properties 62 | 63 | # Packed Addressables 64 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 65 | 66 | # Temporary auto-generated Android Assets 67 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 68 | /[Aa]ssets/[Ss]treamingAssets/aa/* 69 | 70 | # Asset Store Tools 71 | /[Aa]ssets/[Aa]ssetStoreTools.meta 72 | /[Aa]ssets/[Aa]ssetStoreTools/ 73 | 74 | # Plugins 75 | /[Aa]ssets/[Pp]lugins.meta 76 | /[Aa]ssets/[Pp]lugins/ 77 | 78 | # Documentation 79 | Documentation/api/ 80 | Documentation/index.* 81 | _site/ 82 | Assets/**/obj/ 83 | 84 | # Code Coverage 85 | /[Cc]ode[Cc]overage/ -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Assets/MackySoft.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccf4c370a0ff0034fa667a073376b694 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e519b2da299e2f408357761e57095d2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40b135dd7602ed64a89227692f76dd16 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/MackySoft.XPool.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MackySoft.XPool.Editor", 3 | "rootNamespace": "MackySoft.XPool", 4 | "references": [ 5 | "GUID:6871bfe906a80344c9fdc325c92c646f" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/MackySoft.XPool.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f3fde010f86ceb4e877c124c54d63ff 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Timers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57d6586edf68b7941941e1e19c6fdc5b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Timers/PeriodicTimerDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace MackySoft.XPool.Timers { 5 | 6 | [CustomPropertyDrawer(typeof(PeriodicTimer))] 7 | public class PeriodicTimerDrawer : PropertyDrawer { 8 | 9 | public override void OnGUI (Rect position,SerializedProperty property,GUIContent label) { 10 | EditorGUI.BeginProperty(position,label,property); 11 | 12 | SerializedProperty interval = property.FindPropertyRelative("m_Interval"); 13 | 14 | EditorGUI.BeginChangeCheck(); 15 | 16 | float intervalValue = Mathf.Max(0.01f,EditorGUI.FloatField(position,label,interval.floatValue)); 17 | 18 | if (EditorGUI.EndChangeCheck() && (interval.floatValue != intervalValue)) { 19 | interval.floatValue = intervalValue; 20 | } 21 | 22 | EditorGUI.EndProperty(); 23 | } 24 | 25 | public override float GetPropertyHeight (SerializedProperty property,GUIContent label) { 26 | return EditorGUIUtility.singleLineHeight; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Timers/PeriodicTimerDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76fea1a29d890f6408632eef5be731a2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4948fd9ea0654e0419b18c7c9c66fcd7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Unity/SerializedPropertyUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEditor; 3 | 4 | namespace MackySoft.XPool.Unity { 5 | public static class SerializedPropertyUtility { 6 | 7 | public static IEnumerable GetVisibleChildren (this SerializedProperty property) { 8 | SerializedProperty currentProperty = property.Copy(); 9 | SerializedProperty nextSiblingProperty = property.Copy(); 10 | nextSiblingProperty.NextVisible(false); 11 | 12 | if (currentProperty.NextVisible(true)) { 13 | do { 14 | if (SerializedProperty.EqualContents(currentProperty,nextSiblingProperty)) { 15 | break; 16 | } 17 | yield return currentProperty; 18 | } 19 | while (currentProperty.NextVisible(false)); 20 | } 21 | } 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Unity/SerializedPropertyUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 983a93b55eb706b47b6535d01cd32c5e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Unity/UnityObjectPoolDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using MackySoft.XPool.Unity.ObjectModel; 4 | 5 | namespace MackySoft.XPool.Unity { 6 | 7 | [CustomPropertyDrawer(typeof(UnityObjectPool<>),true)] 8 | [CustomPropertyDrawer(typeof(UnityObjectPoolBase<>),true)] 9 | public class UnityObjectPoolDrawer : PropertyDrawer { 10 | 11 | public override void OnGUI (Rect position,SerializedProperty property,GUIContent label) { 12 | EditorGUI.BeginProperty(position,label,property); 13 | EditorGUI.BeginDisabledGroup(Application.isPlaying); 14 | 15 | SerializedProperty original = property.FindPropertyRelative("m_Original"); 16 | SerializedProperty capacity = property.FindPropertyRelative("m_Capacity"); 17 | 18 | // Draw prefix label 19 | Rect prefixLabelPosition = position; 20 | prefixLabelPosition.height = EditorGUIUtility.singleLineHeight; 21 | EditorGUI.PrefixLabel(position,label); 22 | 23 | Rect propertyPosition = EditorGUI.IndentedRect(prefixLabelPosition); 24 | propertyPosition.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 25 | using (new EditorGUI.IndentLevelScope()) { 26 | // Draw original property 27 | EditorGUI.PropertyField(propertyPosition,original); 28 | 29 | // Draw capacity property 30 | propertyPosition.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 31 | 32 | EditorGUI.BeginChangeCheck(); 33 | int capacityValue = Mathf.Max(0,EditorGUI.IntField(propertyPosition,new GUIContent(capacity.displayName,capacity.tooltip),capacity.intValue)); 34 | if (EditorGUI.EndChangeCheck() && (capacity.intValue != capacityValue)) { 35 | capacity.intValue = capacityValue; 36 | } 37 | 38 | if (property.Copy().CountRemaining() > 2) { 39 | propertyPosition.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 40 | foreach (var child in SerializedPropertyUtility.GetVisibleChildren(property)) { 41 | if (child.name == "m_Original" || child.name == "m_Capacity") { 42 | continue; 43 | } 44 | float height = EditorGUI.GetPropertyHeight(child); 45 | propertyPosition.height = height; 46 | EditorGUI.PropertyField(propertyPosition,child); 47 | propertyPosition.y += height + EditorGUIUtility.standardVerticalSpacing; 48 | } 49 | } 50 | } 51 | 52 | EditorGUI.EndDisabledGroup(); 53 | EditorGUI.EndProperty(); 54 | } 55 | 56 | public override float GetPropertyHeight (SerializedProperty property,GUIContent label) { 57 | float height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 58 | foreach (var child in SerializedPropertyUtility.GetVisibleChildren(property)) { 59 | height += EditorGUI.GetPropertyHeight(child) + EditorGUIUtility.standardVerticalSpacing; 60 | } 61 | return height; 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Editor/Unity/UnityObjectPoolDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b7423e4bb970f6438fed92866cbcb39 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5033be8cebcc80b47ad218911dbce381 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1af2a137808e8fa40a7fc7b3971b744c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e430f234f3f9644e82b6d157187d496 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Collections.Generic; 4 | using MackySoft.XPool.Internal; 5 | using MackySoft.XPool.Collections.Internal; 6 | 7 | namespace MackySoft.XPool.Collections { 8 | 9 | public class ArrayPool : IPool { 10 | 11 | const int kMaxBucketSize = 32; 12 | 13 | public static readonly ArrayPool Shared = new ArrayPool(); 14 | 15 | readonly Stack[] m_Pool; 16 | readonly SpinLock[] m_Locks; 17 | 18 | public ArrayPool () { 19 | m_Pool = new Stack[18]; 20 | m_Locks = new SpinLock[18]; 21 | for (int i = 0;m_Pool.Length > i;i++) { 22 | m_Locks[i] = new SpinLock(false); 23 | } 24 | } 25 | 26 | /// 27 | /// The array length is not always accurate. 28 | /// 29 | /// 30 | public T[] Rent (int minimumLength) { 31 | if (minimumLength < 0) { 32 | throw Error.RequiredNonNegative(nameof(minimumLength)); 33 | } 34 | else if (minimumLength == 0) { 35 | return Array.Empty(); 36 | } 37 | 38 | int size = CalculateArraySize(minimumLength); 39 | int poolIndex = GetPoolIndex(size); 40 | 41 | if (poolIndex != -1) { 42 | var pool = m_Pool[poolIndex] ?? (m_Pool[poolIndex] = new Stack()); 43 | 44 | bool lockTaken = false; 45 | try { 46 | m_Locks[poolIndex].Enter(ref lockTaken); 47 | if (pool.Count != 0) { 48 | return pool.Pop(); 49 | } 50 | } 51 | finally { 52 | if (lockTaken) { 53 | m_Locks[poolIndex].Exit(false); 54 | } 55 | } 56 | } 57 | 58 | return new T[size]; 59 | } 60 | 61 | /// 62 | /// Return the array to the pool. 63 | /// The length of the array must be greater than or equal to 8 and a power of 2. 64 | /// 65 | /// The length of the array must be greater than or equal to 8 and a power of 2. 66 | public void Return (T[] array) { 67 | Return(array,RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 68 | } 69 | 70 | /// 71 | /// Return the array to the pool. 72 | /// The length of the array must be greater than or equal to 8 and a power of 2. 73 | /// 74 | /// The length of the array must be greater than or equal to 8 and a power of 2. 75 | public void Return (T[] array,bool clearArray = false) { 76 | if ((array == null) || (array.Length == 0)) { 77 | return; 78 | } 79 | 80 | int poolIndex = GetPoolIndex(array.Length); 81 | if (poolIndex == -1) { 82 | return; 83 | } 84 | 85 | var pool = m_Pool[poolIndex] ?? (m_Pool[poolIndex] = new Stack()); 86 | 87 | if (clearArray) { 88 | Array.Clear(array,0,array.Length); 89 | } 90 | 91 | bool lockTaken = false; 92 | try { 93 | m_Locks[poolIndex].Enter(ref lockTaken); 94 | 95 | if (pool.Count < kMaxBucketSize) { 96 | pool.Push(array); 97 | } 98 | } 99 | finally { 100 | if (lockTaken) { 101 | m_Locks[poolIndex].Exit(false); 102 | } 103 | } 104 | } 105 | 106 | /// 107 | /// Return the array to the pool and set array reference to null. 108 | /// The length of the array must be greater than or equal to 8 and a power of 2. 109 | /// 110 | /// The length of the array must be greater than or equal to 8 and a power of 2. 111 | public void Return (ref T[] array,bool clearArray = false) { 112 | Return(array,clearArray); 113 | array = null; 114 | } 115 | 116 | public void ReleaseInstances (int keep) { 117 | if ((keep < 0) || (keep > kMaxBucketSize)) { 118 | throw Error.ArgumentOutOfRangeOfCollection(nameof(keep)); 119 | } 120 | 121 | if (keep != 0) { 122 | // Release instances from each buckets. 123 | for (int i = 0;i < m_Pool.Length;i++) { 124 | var bucket = m_Pool[i]; 125 | for (int k = bucket.Count - keep;i > 0;k--) { 126 | bucket.Pop(); 127 | } 128 | } 129 | } 130 | else { 131 | // Release buckets. 132 | Array.Clear(m_Pool,0,m_Pool.Length); 133 | } 134 | } 135 | 136 | static int CalculateArraySize (int size) { 137 | size--; 138 | size |= size >> 1; 139 | size |= size >> 2; 140 | size |= size >> 4; 141 | size |= size >> 8; 142 | size |= size >> 16; 143 | size += 1; 144 | 145 | if (size < ArrayPoolUtility.kMinArraySize) { 146 | size = ArrayPoolUtility.kMinArraySize; 147 | } 148 | return size; 149 | } 150 | 151 | static int GetPoolIndex (int length) { 152 | switch (length) { 153 | case 8: 154 | return 0; 155 | case 16: 156 | return 1; 157 | case 32: 158 | return 2; 159 | case 64: 160 | return 3; 161 | case 128: 162 | return 4; 163 | case 256: 164 | return 5; 165 | case 512: 166 | return 6; 167 | case 1024: 168 | return 7; 169 | case 2048: 170 | return 8; 171 | case 4096: 172 | return 9; 173 | case 8192: 174 | return 10; 175 | case 16384: 176 | return 11; 177 | case 32768: 178 | return 12; 179 | case 65536: 180 | return 13; 181 | case 131072: 182 | return 14; 183 | case 262144: 184 | return 15; 185 | case 524288: 186 | return 16; 187 | case 1048576: 188 | return 17; 189 | default: 190 | return -1; 191 | } 192 | } 193 | 194 | int IPool.Capacity => throw Error.FunctionIsNotSupported(); 195 | 196 | int IPool.Count => throw Error.FunctionIsNotSupported(); 197 | 198 | T[] IPool.Rent () { 199 | throw Error.FunctionIsNotSupported(); 200 | } 201 | } 202 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2615d26ef701dc942b876e630b823061 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPoolExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool.Collections { 6 | public static class ArrayPoolExtensions { 7 | 8 | /// 9 | /// Convert enumerable to array. Array are returned from . 10 | /// The array length is not always accurate. 11 | /// 12 | public static T[] ToArrayFromPool (this IEnumerable source) { 13 | return ToArrayFromPool(source,ArrayPool.Shared,out _); 14 | } 15 | 16 | /// 17 | /// Convert enumerable to array. Array are returned from . 18 | /// The array length is not always accurate. 19 | /// 20 | public static T[] ToArrayFromPool (this IEnumerable source,ArrayPool pool) { 21 | return ToArrayFromPool(source,pool,out _); 22 | } 23 | 24 | /// 25 | /// Convert enumerable to array. Array are returned from . 26 | /// The array length is not always accurate. 27 | /// 28 | /// Number of elements in source. 29 | public static T[] ToArrayFromPool (this IEnumerable source,out int count) { 30 | return ToArrayFromPool(source,ArrayPool.Shared,out count); 31 | } 32 | 33 | /// 34 | /// Convert enumerable to array. Array are returned from . 35 | /// The array length is not always accurate. 36 | /// 37 | /// Number of elements in source. 38 | public static T[] ToArrayFromPool (this IEnumerable source,ArrayPool pool,out int count) { 39 | if (source == null) { 40 | throw Error.ArgumentNullException(nameof(source)); 41 | } 42 | if (pool == null) { 43 | throw Error.ArgumentNullException(nameof(pool)); 44 | } 45 | 46 | // Tries to cast source to the collection interfaces. 47 | if (source is IList list) { 48 | count = list.Count; 49 | return ToArrayFromPoolInternal(list,pool); 50 | } 51 | if (source is IReadOnlyList readonlyList) { 52 | count = readonlyList.Count; 53 | return ToArrayFromPoolInternal(readonlyList,pool); 54 | } 55 | if (source is ICollection collection) { 56 | count = collection.Count; 57 | return ToArrayFromPoolInternal(collection,pool); 58 | } 59 | if (source is IReadOnlyCollection readonlyCollection) { 60 | count = readonlyCollection.Count; 61 | return ToArrayFromPoolInternal(readonlyCollection,pool); 62 | } 63 | 64 | T[] array = pool.Rent(32); 65 | count = 0; 66 | foreach (T item in source) { 67 | ArrayPoolUtility.EnsureCapacity(ref array,count,pool); 68 | array[count] = item; 69 | count++; 70 | } 71 | return array; 72 | } 73 | 74 | static T[] ToArrayFromPoolInternal (IReadOnlyList source,ArrayPool pool) { 75 | T[] array = pool.Rent(source.Count); 76 | for (int i = 0;source.Count > i;i++) { 77 | array[i] = source[i]; 78 | } 79 | return array; 80 | } 81 | 82 | static T[] ToArrayFromPoolInternal (IList source,ArrayPool pool) { 83 | T[] array = pool.Rent(source.Count); 84 | source.CopyTo(array,0); 85 | return array; 86 | } 87 | 88 | static T[] ToArrayFromPoolInternal (IReadOnlyCollection source,ArrayPool pool) { 89 | T[] array = pool.Rent(source.Count); 90 | int i = 0; 91 | foreach (T item in source) { 92 | array[i] = item; 93 | i++; 94 | } 95 | return array; 96 | } 97 | 98 | static T[] ToArrayFromPoolInternal (ICollection source,ArrayPool pool) { 99 | T[] array = pool.Rent(source.Count); 100 | source.CopyTo(array,0); 101 | return array; 102 | } 103 | 104 | } 105 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPoolExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 940dcd08b6cc22f41be1f7b76b83c0b8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPoolUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MackySoft.XPool.Collections.Internal; 3 | 4 | namespace MackySoft.XPool.Collections { 5 | public static class ArrayPoolUtility { 6 | 7 | public const int kMinArraySize = 8; 8 | 9 | public static void EnsureCapacity (ref T[] array,int newSize,ArrayPool pool) { 10 | if (array.Length < newSize) { 11 | int minimumSize = (array.Length != 0) ? array.Length * 2 : kMinArraySize; 12 | T[] newArray = pool.Rent((newSize < minimumSize) ? minimumSize : (newSize * 2)); 13 | Array.Copy(array,0,newArray,0,array.Length); 14 | 15 | pool.Return(array,!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 16 | 17 | array = newArray; 18 | } 19 | } 20 | 21 | // Circular Buffer: https://en.wikipedia.org/wiki/Circular_buffer 22 | public static bool EnsureCapacityCircular (ref T[] array,int count,int newSize,ref int first,ref int last,ArrayPool pool) { 23 | if (array.Length < newSize) { 24 | int minimumSize = (array.Length != 0) ? array.Length * 2 : kMinArraySize; 25 | T[] newArray = pool.Rent((newSize < minimumSize) ? minimumSize : (newSize * 2)); 26 | if (newSize > 0) { 27 | if (first < last) { 28 | Array.Copy(array,first,newArray,0,newSize); 29 | } 30 | else { 31 | Array.Copy(array,first,newArray,0,array.Length - first); 32 | Array.Copy(array,0,newArray,array.Length - first,last); 33 | } 34 | } 35 | 36 | pool.Return(array,!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 37 | 38 | array = newArray; 39 | first = 0; 40 | last = (count == array.Length) ? 0 : count; 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/ArrayPoolUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12f4eede3237d044181f9c4769b983ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee4e795f6ae7d604994776f4a40de31b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Array.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ea81fdf87d5ebc4b86bbf5f47e68203 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Array/TemporaryArray.Create.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool.Collections { 6 | 7 | // Static TemporaryArray create methods 8 | public partial struct TemporaryArray { 9 | 10 | /// 11 | /// Create a temporary array of the specified length. 12 | /// 13 | /// 14 | public static TemporaryArray Create (int length) { 15 | return Create(length,ArrayPool.Shared); 16 | } 17 | 18 | /// 19 | /// Create a temporary array of the specified length. 20 | /// 21 | /// 22 | /// 23 | public static TemporaryArray Create (int length,ArrayPool pool) { 24 | return new TemporaryArray(pool,length); 25 | } 26 | 27 | /// 28 | /// Create a temporary array from the elements of . 29 | /// 30 | /// 31 | public static TemporaryArray From (IEnumerable source) { 32 | return From(source,ArrayPool.Shared); 33 | } 34 | 35 | /// 36 | /// Create a temporary array from the elements of . 37 | /// 38 | /// 39 | public static TemporaryArray From (IEnumerable source,ArrayPool pool) { 40 | if (source == null) { 41 | throw Error.ArgumentNullException(nameof(source)); 42 | } 43 | if (pool == null) { 44 | throw Error.ArgumentNullException(nameof(pool)); 45 | } 46 | 47 | T[] array = source.ToArrayFromPool(pool,out int count); 48 | return new TemporaryArray(pool,array,count); 49 | } 50 | 51 | /// 52 | /// Create a temporary array from the elements of . 53 | /// 54 | public static TemporaryArray From (TemporaryArray source) { 55 | return From(source,ArrayPool.Shared); 56 | } 57 | 58 | /// 59 | /// Create a temporary array from the elements of . 60 | /// 61 | /// 62 | /// 63 | public static TemporaryArray From (TemporaryArray source,ArrayPool pool) { 64 | if (pool == null) { 65 | throw Error.ArgumentNullException(nameof(pool)); 66 | } 67 | if (source.Array == null) { 68 | throw Error.TemporaryIsDisposed(nameof(source)); 69 | } 70 | 71 | var result = Create(source.Length,pool); 72 | for (int i = 0;source.Length > i;i++) { 73 | result[i] = source[i]; 74 | } 75 | return result; 76 | } 77 | 78 | } 79 | 80 | public static class TemporaryArrayExtensions { 81 | 82 | /// 83 | /// Create a temporary array from the elements of . 84 | /// 85 | public static TemporaryArray ToTemporaryArray (this IEnumerable source) { 86 | return ToTemporaryArray(source,ArrayPool.Shared); 87 | } 88 | 89 | /// 90 | /// Create a temporary array from the elements of . 91 | /// 92 | public static TemporaryArray ToTemporaryArray (this IEnumerable source,ArrayPool pool) { 93 | return TemporaryArray.From(source,pool); 94 | } 95 | 96 | } 97 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Array/TemporaryArray.Create.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daa9b6b7497d6cf45bbc9d34d8bb100d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Array/TemporaryArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MackySoft.XPool.Collections.Internal; 5 | using MackySoft.XPool.Internal; 6 | 7 | namespace MackySoft.XPool.Collections { 8 | 9 | /// 10 | /// Temporary array without allocation. 11 | /// This struct use internally to avoid allocation and can be used just like a normal array. 12 | /// After using it, please call the Dispose(). 13 | /// 14 | public partial struct TemporaryArray : IEnumerable, IDisposable { 15 | 16 | T[] m_Array; 17 | int m_Length; 18 | ArrayPool m_Pool; 19 | 20 | public int Length => m_Length; 21 | 22 | /// 23 | /// Length of internal array. 24 | /// 25 | public int Capacity => m_Array.Length; 26 | 27 | /// 28 | /// Internal array. 29 | /// The length of internal array is always greater than or equal to property. 30 | /// 31 | public T[] Array => m_Array; 32 | 33 | public T this[int index] { 34 | get { 35 | return index >= 0 && index < m_Length ? m_Array[index] : throw Error.ArgumentOutOfRangeOfCollection(nameof(index)); 36 | } 37 | set { 38 | if (index < 0 && index >= m_Length) { 39 | throw Error.ArgumentOutOfRangeOfCollection(nameof(index)); 40 | } 41 | m_Array[index] = value; 42 | } 43 | } 44 | 45 | public TemporaryArray (ArrayPool pool,int length) { 46 | m_Pool = pool ?? throw Error.ArgumentNullException(nameof(pool)); 47 | m_Array = pool.Rent(length); 48 | m_Length = length; 49 | } 50 | 51 | internal TemporaryArray (ArrayPool pool,T[] array,int length) { 52 | m_Pool = pool ?? throw Error.ArgumentNullException(nameof(pool)); 53 | m_Array = array; 54 | m_Length = length; 55 | } 56 | 57 | /// 58 | /// Return the internal array to the pool. 59 | /// 60 | public void Dispose () { 61 | Dispose(!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 62 | } 63 | 64 | /// 65 | /// Return the internal array to the pool. 66 | /// 67 | public void Dispose (bool clearArray) { 68 | m_Pool.Return(ref m_Array,clearArray); 69 | m_Length = 0; 70 | m_Pool = null; 71 | } 72 | 73 | public IEnumerator GetEnumerator () { 74 | for (int i = 0;m_Length > i;i++) { 75 | yield return m_Array[i]; 76 | } 77 | } 78 | 79 | IEnumerator IEnumerable.GetEnumerator () { 80 | return GetEnumerator(); 81 | } 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Array/TemporaryArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74cc2066bb0d9cf448e27a905b25e398 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/List.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cdf557e59c4b1d4095519f54c9a698b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/List/TemporaryList.Create.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool.Collections { 6 | 7 | // Static TemporaryList create methods 8 | public partial struct TemporaryList { 9 | 10 | /// 11 | /// Create an empty temporay list using . 12 | /// 13 | public static TemporaryList Create () { 14 | return Create(ArrayPool.Shared); 15 | } 16 | 17 | /// 18 | /// Create an empty temporay list. 19 | /// 20 | public static TemporaryList Create (ArrayPool pool) { 21 | return new TemporaryList(pool,0); 22 | } 23 | 24 | /// 25 | /// Create an empty temporary list with the specified initial capacity. 26 | /// 27 | public static TemporaryList Create (int minimumCapacity) { 28 | return Create(minimumCapacity,ArrayPool.Shared); 29 | } 30 | 31 | /// 32 | /// Create an empty temporary list with the specified initial capacity. 33 | /// 34 | /// 35 | public static TemporaryList Create (int minimumCapacity,ArrayPool pool) { 36 | return new TemporaryList(pool,minimumCapacity); 37 | } 38 | 39 | /// 40 | /// Create a temporary list from the elements of using . 41 | /// 42 | public static TemporaryList From (IEnumerable source) { 43 | return From(source,ArrayPool.Shared); 44 | } 45 | 46 | /// 47 | /// Create a temporary list from the elements of . 48 | /// 49 | /// 50 | /// 51 | public static TemporaryList From (IEnumerable source,ArrayPool pool) { 52 | if (source == null) { 53 | throw Error.ArgumentNullException(nameof(source)); 54 | } 55 | if (pool == null) { 56 | throw Error.ArgumentNullException(nameof(pool)); 57 | } 58 | 59 | T[] array = source.ToArrayFromPool(pool,out int count); 60 | return new TemporaryList(pool,array,count); 61 | } 62 | 63 | } 64 | 65 | public static class TemporaryListExtensions { 66 | 67 | /// 68 | /// Create a temporary list from the elements of . 69 | /// 70 | public static TemporaryList ToTemporaryList (this IEnumerable source) { 71 | return ToTemporaryList(source,ArrayPool.Shared); 72 | } 73 | 74 | /// 75 | /// Create a temporary list from the elements of using . 76 | /// 77 | public static TemporaryList ToTemporaryList (this IEnumerable source,ArrayPool pool) { 78 | return TemporaryList.From(source,pool); 79 | } 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/List/TemporaryList.Create.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cff9ab51e67c37d43823dd898b1d8d16 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/List/TemporaryList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a41ac695b92b4454997da64ac3e1f904 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Queue.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ae9c37ecf8097c4692c8fe72e4ad9e5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Queue/TemporaryQueue.Create.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool.Collections { 4 | 5 | // Static TemporaryQueue create methods 6 | public partial struct TemporaryQueue { 7 | 8 | /// 9 | /// Create an empty temporay queue using . 10 | /// 11 | public static TemporaryQueue Create () { 12 | return Create(ArrayPool.Shared); 13 | } 14 | 15 | /// 16 | /// Create an empty temporay queue. 17 | /// 18 | /// 19 | public static TemporaryQueue Create (ArrayPool pool) { 20 | return new TemporaryQueue(pool,0); 21 | } 22 | 23 | /// 24 | /// Create an empty temporary queue with the specified initial capacity. 25 | /// 26 | public static TemporaryQueue Create (int minimumCapacity) { 27 | return Create(minimumCapacity,ArrayPool.Shared); 28 | } 29 | 30 | /// 31 | /// Create an empty temporary queue with the specified initial capacity. 32 | /// 33 | /// 34 | public static TemporaryQueue Create (int minimumCapacity,ArrayPool pool) { 35 | return new TemporaryQueue(pool,minimumCapacity); 36 | } 37 | 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Queue/TemporaryQueue.Create.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 387ec54b58fa01f449f7384ce6333bab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Queue/TemporaryQueue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MackySoft.XPool.Collections.Internal; 5 | using MackySoft.XPool.Internal; 6 | 7 | namespace MackySoft.XPool.Collections { 8 | 9 | /// 10 | /// Temporary queue without allocation. 11 | /// This struct use internally to avoid allocation and can be used just like a normal queue. 12 | /// After using it, please call the Dispose(). 13 | /// 14 | public partial struct TemporaryQueue : IEnumerable, IDisposable { 15 | 16 | T[] m_Array; 17 | ArrayPool m_Pool; 18 | int m_Count; 19 | int m_First; 20 | int m_Last; 21 | int m_Mask; 22 | 23 | public int Count => m_Count; 24 | public int Capacity => m_Array.Length; 25 | public T[] Array => m_Array; 26 | 27 | public TemporaryQueue (ArrayPool pool,int minimumCapacity) { 28 | m_Pool = pool ?? throw Error.ArgumentNullException(nameof(pool)); 29 | m_Array = pool.Rent(minimumCapacity); 30 | m_Count = 0; 31 | m_First = 0; 32 | m_Last = 0; 33 | m_Mask = (m_Array.Length == 0) ? 0 : (m_Array.Length - 1); 34 | } 35 | 36 | /// 37 | /// Add object to the tail of the queue. 38 | /// 39 | /// Object to add to the queue. 40 | public void Enqueue (T item) { 41 | if (ArrayPoolUtility.EnsureCapacityCircular(ref m_Array,m_Count,m_Count + 1,ref m_First,ref m_Last,m_Pool)) { 42 | m_Mask = m_Array.Length - 1; 43 | } 44 | m_Array[m_Last] = item; 45 | m_Last = (m_Last + 1) & m_Mask; 46 | m_Count++; 47 | } 48 | 49 | /// 50 | /// Remove object at the head of the queue and returns it. If the queue is empty, will be thrown. 51 | /// 52 | /// 53 | public T Dequeue () { 54 | if (m_Count == 0) { 55 | throw Error.EmptyCollection(); 56 | } 57 | T removed = m_Array[m_First]; 58 | m_Array[m_First] = default; 59 | m_First = (m_First + 1) & m_Mask; 60 | m_Count--; 61 | return removed; 62 | } 63 | 64 | /// 65 | /// Return object at the head of the queue. If the queue is empty, will be thrown. 66 | /// 67 | /// 68 | public T Peek () { 69 | if (m_Count == 0) { 70 | throw Error.EmptyCollection(); 71 | } 72 | return m_Array[m_First]; 73 | } 74 | 75 | /// 76 | /// Remove all objects from the queue. 77 | /// 78 | public void Clear () { 79 | if (m_First < m_Last) { 80 | System.Array.Clear(m_Array,m_First,m_Count); 81 | } 82 | else { 83 | System.Array.Clear(m_Array,m_First,m_Array.Length - m_First); 84 | System.Array.Clear(m_Array,0,m_Last); 85 | } 86 | m_First = 0; 87 | m_Last = 0; 88 | m_Count = 0; 89 | m_Mask = 0; 90 | } 91 | 92 | /// 93 | /// Whether the specified object exists in the queue. 94 | /// 95 | public bool Contains (T item) { 96 | int index = m_First; 97 | int count = m_Count; 98 | 99 | if (item == null) { 100 | while (count-- > 0) { 101 | if (m_Array[index] == null) { 102 | return true; 103 | } 104 | index = (index + 1) & m_Mask; 105 | } 106 | } 107 | else { 108 | var c = EqualityComparer.Default; 109 | while (count-- > 0) { 110 | T e = m_Array[index]; 111 | if ((e != null) && c.Equals(e,item)) { 112 | return true; 113 | } 114 | index = (index + 1) & m_Mask; 115 | } 116 | } 117 | return false; 118 | } 119 | 120 | /// 121 | /// Copy objects to array in the queue. 122 | /// 123 | /// 124 | /// 125 | /// 126 | /// 127 | /// 128 | public void CopyTo (T[] array,int arrayIndex) { 129 | if (array == null) { 130 | throw Error.ArgumentNullException(nameof(array)); 131 | } 132 | if (arrayIndex < 0 || arrayIndex > array.Length) { 133 | throw Error.ArgumentOutOfRangeOfCollection(nameof(arrayIndex)); 134 | } 135 | if ((array.Length - arrayIndex) < m_Count) { 136 | throw Error.InvalidOffLength(); 137 | } 138 | 139 | if (m_First < m_Last) { 140 | System.Array.Copy(m_Array,m_First,array,arrayIndex,m_Count); 141 | } 142 | else { 143 | System.Array.Copy(m_Array,m_First,array,arrayIndex,m_Array.Length - m_First); 144 | System.Array.Copy(m_Array,0,array,arrayIndex + (m_Array.Length - m_First),m_Last); 145 | } 146 | } 147 | 148 | /// 149 | /// Return the internal array to the pool. 150 | /// 151 | public void Dispose () { 152 | Dispose(!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 153 | } 154 | 155 | /// 156 | /// Return the internal array to the pool. 157 | /// 158 | public void Dispose (bool clearArray) { 159 | m_Pool.Return(ref m_Array,clearArray); 160 | m_Pool = null; 161 | m_First = 0; 162 | m_Last = 0; 163 | m_Count = 0; 164 | m_Mask = 0; 165 | } 166 | 167 | internal T GetElement (int index) { 168 | return m_Array[(m_First + index) & m_Mask]; 169 | } 170 | 171 | public IEnumerator GetEnumerator () { 172 | for (int i = 0;m_Count > i;i++) { 173 | yield return m_Array[i]; 174 | } 175 | } 176 | 177 | IEnumerator IEnumerable.GetEnumerator () => GetEnumerator(); 178 | 179 | } 180 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Queue/TemporaryQueue.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a064651a08cb92544a13c9283923208b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Stack.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34b602e33c3353442a8db4cebef84a88 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Stack/TemporaryStack.Create.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool.Collections { 4 | 5 | // Static TemporaryStack create methods 6 | public partial struct TemporaryStack { 7 | 8 | /// 9 | /// Create an empty temporay stack using . 10 | /// 11 | public static TemporaryStack Create () { 12 | return Create(ArrayPool.Shared); 13 | } 14 | 15 | /// 16 | /// Create an empty temporay stack. 17 | /// 18 | /// 19 | public static TemporaryStack Create (ArrayPool pool) { 20 | return new TemporaryStack(pool,0); 21 | } 22 | 23 | /// 24 | /// Create an empty temporary stack with the specified initial capacity. 25 | /// 26 | public static TemporaryStack Create (int minimumCapacity) { 27 | return Create(minimumCapacity,ArrayPool.Shared); 28 | } 29 | 30 | /// 31 | /// Create an empty temporary stack with the specified initial capacity. 32 | /// 33 | /// 34 | public static TemporaryStack Create (int minimumCapacity,ArrayPool pool) { 35 | return new TemporaryStack(pool,minimumCapacity); 36 | } 37 | 38 | } 39 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Stack/TemporaryStack.Create.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3f1890d6509c07438eec745ef776054 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Stack/TemporaryStack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MackySoft.XPool.Collections.Internal; 5 | using MackySoft.XPool.Internal; 6 | 7 | namespace MackySoft.XPool.Collections { 8 | public partial struct TemporaryStack : IEnumerable, IDisposable { 9 | 10 | T[] m_Array; 11 | ArrayPool m_Pool; 12 | int m_Count; 13 | 14 | public int Count => m_Count; 15 | public int Capacity => m_Array.Length; 16 | public T[] Array => m_Array; 17 | 18 | public TemporaryStack (ArrayPool pool,int minimumCapacity) { 19 | m_Pool = pool ?? throw Error.ArgumentNullException(nameof(pool)); 20 | m_Array = pool.Rent(minimumCapacity); 21 | m_Count = 0; 22 | } 23 | 24 | /// 25 | /// Add object to the head of the stack. 26 | /// 27 | /// Object to add to the stack. 28 | public void Push (T item) { 29 | ArrayPoolUtility.EnsureCapacity(ref m_Array,m_Count + 1,m_Pool); 30 | m_Array[m_Count] = item; 31 | m_Count++; 32 | } 33 | 34 | /// 35 | /// Remove object at the head of the stack and returns it. If the stack is empty, will be thrown. 36 | /// 37 | /// 38 | public T Pop () { 39 | if (m_Count == 0) { 40 | throw Error.EmptyCollection(); 41 | } 42 | T item = m_Array[m_Count - 1]; 43 | m_Array[m_Count - 1] = default; 44 | m_Count--; 45 | return item; 46 | } 47 | 48 | /// 49 | /// Return object at the head of the stack. If the stack is empty, will be thrown. 50 | /// 51 | /// 52 | public T Peek () { 53 | if (m_Count == 0) { 54 | throw Error.EmptyCollection(); 55 | } 56 | return m_Array[m_Count - 1]; 57 | } 58 | 59 | /// 60 | /// Remove all objects from the stack. 61 | /// 62 | public void Clear () { 63 | m_Pool.Return(m_Array,!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 64 | m_Array = m_Pool.Rent(0); 65 | m_Count = 0; 66 | } 67 | 68 | /// 69 | /// Whether the specified object exists in the stack. 70 | /// 71 | public bool Contains (T item) { 72 | int count = m_Count; 73 | if (item == null) { 74 | while (count-- > 0) { 75 | if (m_Array[count] == null) { 76 | return true; 77 | } 78 | } 79 | } 80 | else { 81 | var c = EqualityComparer.Default; 82 | while (count-- > 0) { 83 | T e = m_Array[count]; 84 | if ((e != null) && c.Equals(e,item)) { 85 | return true; 86 | } 87 | } 88 | } 89 | return true; 90 | } 91 | 92 | /// 93 | /// Copy objects to array in the stack. 94 | /// 95 | /// 96 | /// 97 | /// 98 | /// 99 | /// 100 | public void CopyTo (T[] array,int arrayIndex) { 101 | if (array == null) { 102 | throw Error.ArgumentNullException(nameof(array)); 103 | } 104 | if ((arrayIndex < 0) || (arrayIndex > array.Length)) { 105 | throw Error.ArgumentOutOfRangeOfCollection(nameof(arrayIndex)); 106 | } 107 | if ((array.Length - arrayIndex) < m_Count) { 108 | throw Error.InvalidOffLength(); 109 | } 110 | System.Array.Copy(m_Array,0,array,arrayIndex,m_Count); 111 | System.Array.Reverse(array,arrayIndex,m_Count); 112 | } 113 | 114 | /// 115 | /// Return the internal array to the pool. 116 | /// 117 | public void Dispose () { 118 | Dispose(!RuntimeHelpers.IsWellKnownNoReferenceContainsType()); 119 | } 120 | 121 | /// 122 | /// Return the internal array to the pool. 123 | /// 124 | public void Dispose (bool clearArray) { 125 | m_Pool.Return(ref m_Array,clearArray); 126 | m_Pool = null; 127 | m_Count = 0; 128 | } 129 | 130 | public IEnumerator GetEnumerator () { 131 | for (int i = m_Count - 1;i >= 0;i--) { 132 | yield return m_Array[i]; 133 | } 134 | } 135 | 136 | IEnumerator IEnumerable.GetEnumerator () => GetEnumerator(); 137 | 138 | } 139 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Array/Temporary/Stack/TemporaryStack.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bdd6e93b59b19cb4aafb4ed9f28c439c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/CollectionPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using MackySoft.XPool.Collections.ObjectModel; 3 | 4 | namespace MackySoft.XPool.Collections { 5 | public class ListPool : CollectionPoolBase> { 6 | 7 | public static readonly ListPool Shared = new ListPool(); 8 | 9 | public ListPool () : base(CollectionPoolUtility.kDefaultCapacity,() => new List(),list => list.Clear()) { 10 | } 11 | } 12 | 13 | public class QueuePool : CollectionPoolBase> { 14 | 15 | public static readonly QueuePool Shared = new QueuePool(); 16 | 17 | public QueuePool () : base(CollectionPoolUtility.kDefaultCapacity,() => new Queue(),queue => queue.Clear()) { 18 | } 19 | } 20 | 21 | public class StackPool : CollectionPoolBase> { 22 | 23 | public static readonly StackPool Shared = new StackPool(); 24 | 25 | public StackPool () : base(CollectionPoolUtility.kDefaultCapacity,() => new Stack(),stack => stack.Clear()) { 26 | } 27 | } 28 | 29 | public class HashSetPool : CollectionPoolBase> { 30 | 31 | public static readonly HashSetPool Shared = new HashSetPool(); 32 | 33 | public HashSetPool () : base(CollectionPoolUtility.kDefaultCapacity,() => new HashSet(),hashSet => hashSet.Clear()) { 34 | } 35 | } 36 | 37 | public class DictionaryPool : CollectionPoolBase> { 38 | 39 | public static readonly DictionaryPool Shared = new DictionaryPool(); 40 | 41 | public DictionaryPool () : base(CollectionPoolUtility.kDefaultCapacity,() => new Dictionary(),dictionary => dictionary.Clear()) { 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/CollectionPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9268b9b21a1912a45bb02889e7a1158e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/CollectionPoolUtility.cs: -------------------------------------------------------------------------------- 1 | namespace MackySoft.XPool.Collections { 2 | public static class CollectionPoolUtility { 3 | 4 | /// 5 | /// The default capacity of collection pool. This is used by and others. 6 | /// 7 | public const int kDefaultCapacity = 8; 8 | } 9 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/CollectionPoolUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d8ce3405e8d07a4eb3a1127e2e82f31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a3f4c3b4e0e23947a9c54e4e69576fc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Internal/RuntimeHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace MackySoft.XPool.Collections.Internal { 5 | internal static class RuntimeHelpers { 6 | 7 | public static bool IsWellKnownNoReferenceContainsType () { 8 | return WellKnownNoReferenceContainsType.IsWellKnownType; 9 | } 10 | 11 | static bool WellKnownNoReferenceContainsTypeInitialize (Type t) { 12 | if (t.IsPrimitive) { 13 | return true; 14 | } 15 | if (t.IsEnum) { return true; } 16 | if (t == typeof(DateTime)) { return true; } 17 | if (t == typeof(DateTimeOffset)) { return true; } 18 | if (t == typeof(Guid)) { return true; } 19 | if (t == typeof(decimal)) { return true; } 20 | 21 | if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) { 22 | return WellKnownNoReferenceContainsTypeInitialize(t.GetGenericArguments()[0]); 23 | } 24 | 25 | if (t == typeof(Vector2)) { return true; } 26 | if (t == typeof(Vector3)) { return true; } 27 | if (t == typeof(Vector4)) { return true; } 28 | if (t == typeof(Vector2Int)) { return true; } 29 | if (t == typeof(Vector3Int)) { return true; } 30 | if (t == typeof(Rect)) { return true; } 31 | if (t == typeof(RectInt)) { return true; } 32 | if (t == typeof(Bounds)) { return true; } 33 | if (t == typeof(BoundsInt)) { return true; } 34 | if (t == typeof(Quaternion)) { return true; } 35 | if (t == typeof(Color)) { return true; } 36 | 37 | return false; 38 | } 39 | 40 | static class WellKnownNoReferenceContainsType { 41 | 42 | public static readonly bool IsWellKnownType; 43 | 44 | static WellKnownNoReferenceContainsType () { 45 | IsWellKnownType = WellKnownNoReferenceContainsTypeInitialize(typeof(T)); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/Internal/RuntimeHelpers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c880c8b98798358489983bde14c05c83 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/ObjectModel.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29db364f8bd3e9f46a39f390933bd6c5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/ObjectModel/CollectionPoolBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool.Collections.ObjectModel { 6 | 7 | /// 8 | /// Base of pool for collections. 9 | /// 10 | /// 11 | public abstract class CollectionPoolBase : IPool where T : class { 12 | 13 | readonly Stack m_Pool; 14 | readonly int m_Capacity; 15 | 16 | // The new() constraint of generics use Activator.CreateInstance, which incurs overhead during object creation. 17 | // Therefore, explicit constructor call by factory method are used to avoid the overhead. 18 | readonly Func m_Factory; 19 | 20 | // Stack and Queue do not implement ICollection, so need to use a delegate to call the Clear method instead. 21 | readonly Action m_Clear; 22 | 23 | public int Capacity => m_Capacity; 24 | 25 | public int Count => m_Pool.Count; 26 | 27 | /// 28 | /// Constructor to initialize a collection pool. You must call this in the constructor of the inherited class. 29 | /// 30 | /// The pool capacity. If less than 0, will be thrown. 31 | /// Method that create new instance. If is null, will be thrown. 32 | /// Method that clear collection. If is null, will be thrown. 33 | protected CollectionPoolBase (int capacity,Func factory,Action clear) { 34 | if (capacity < 0) { 35 | throw Error.RequiredNonNegative(nameof(capacity)); 36 | } 37 | if (factory == null) { 38 | throw Error.ArgumentNullException(nameof(factory)); 39 | } 40 | if (clear == null) { 41 | throw Error.ArgumentNullException(nameof(clear)); 42 | } 43 | m_Pool = new Stack(m_Capacity); 44 | m_Capacity = capacity; 45 | m_Factory = factory; 46 | m_Clear = clear; 47 | } 48 | 49 | public T Rent () { 50 | lock (m_Pool) { 51 | return (m_Pool.Count == 0) ? m_Factory() : m_Pool.Pop(); 52 | } 53 | } 54 | 55 | public void Return (T collection) { 56 | if (collection == null) { 57 | return; 58 | } 59 | 60 | m_Clear(collection); 61 | 62 | lock (m_Pool) { 63 | if (m_Pool.Count < m_Capacity) { 64 | m_Pool.Push(collection); 65 | } 66 | } 67 | } 68 | 69 | public void ReleaseInstances (int keep) { 70 | if ((keep < 0) || (keep > m_Capacity)) { 71 | throw Error.ArgumentOutOfRangeOfCollection(nameof(keep)); 72 | } 73 | 74 | lock (m_Pool) { 75 | if (keep != 0) { 76 | for (int i = m_Pool.Count - keep;i > 0;i--) { 77 | m_Pool.Pop(); 78 | } 79 | } 80 | else { 81 | m_Pool.Clear(); 82 | } 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Collections/ObjectModel/CollectionPoolBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd5d85a616aa76846adf7b97bf2b8fe9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/FactoryPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MackySoft.XPool.Internal; 3 | using MackySoft.XPool.ObjectModel; 4 | 5 | namespace MackySoft.XPool { 6 | 7 | /// 8 | /// Pool that create an instance from a custom factory method. 9 | /// 10 | public sealed class FactoryPool : PoolBase { 11 | 12 | readonly Func m_Factory; 13 | readonly Action m_OnRent; 14 | readonly Action m_OnReturn; 15 | readonly Action m_OnRelease; 16 | 17 | /// The pool capacity. If less than or equal to 0, will be thrown. 18 | /// Method that create new instance. If is null, will be thrown. This method is must return not null. If returns null, throw . 19 | /// Callback that is called when is successful. 20 | /// Callback that is called when is successful. 21 | /// Callback that is called when capacity is exceeded and the instance cannot be returned to the pool. 22 | /// 23 | /// 24 | public FactoryPool (int capacity,Func factory,Action onRent = null,Action onReturn = null,Action onRelease = null) : base(capacity) { 25 | m_Factory = factory ?? throw Error.ArgumentNullException(nameof(factory)); 26 | m_OnRent = onRent; 27 | m_OnReturn = onReturn; 28 | m_OnRelease = onRelease; 29 | } 30 | 31 | protected override T Factory () => m_Factory(); 32 | protected override void OnRent (T instance) => m_OnRent?.Invoke(instance); 33 | protected override void OnReturn (T instance) => m_OnReturn?.Invoke(instance); 34 | protected override void OnRelease (T instance) => m_OnRelease?.Invoke(instance); 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/FactoryPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f4351cec4381644c87cd47d202ae4c1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/IPool.cs: -------------------------------------------------------------------------------- 1 | namespace MackySoft.XPool { 2 | 3 | /// 4 | /// Interface provides that basic features of pool. 5 | /// 6 | public interface IPool { 7 | 8 | /// 9 | /// Capacity to store instances in the pool. 10 | /// 11 | int Capacity { get; } 12 | 13 | /// 14 | /// Quantity of instances stored in the pool. 15 | /// 16 | int Count { get; } 17 | 18 | /// 19 | /// Keeps the specified quantity and releases the pooled instances. 20 | /// 21 | /// Quantity that keep pooled instances. 22 | void ReleaseInstances (int keep); 23 | } 24 | 25 | /// 26 | /// Interface provides that basic features of pool. 27 | /// 28 | /// Type of instance to pool. 29 | public interface IPool : IPool { 30 | 31 | /// 32 | /// Return the pooled instance. If pool is empty, create new instance and returns it. 33 | /// 34 | T Rent (); 35 | 36 | /// 37 | /// Return instance to the pool. 38 | /// 39 | void Return (T instance); 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/IPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9cb03d4e16be6145bfd6db110713935 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e48cec77b22e0746ae43c9cb9382578 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Internal/Disposable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool.Internal { 4 | internal static class Disposable { 5 | 6 | public static IDisposable Combine (IDisposable disposable1,IDisposable disposable2) { 7 | return new Binary(disposable1,disposable2); 8 | } 9 | 10 | class Binary : IDisposable { 11 | 12 | readonly IDisposable m_Disposable1; 13 | readonly IDisposable m_Disposable2; 14 | 15 | public Binary (IDisposable disposable1,IDisposable disposable2) { 16 | m_Disposable1 = disposable1; 17 | m_Disposable2 = disposable2; 18 | } 19 | 20 | public void Dispose () { 21 | m_Disposable1.Dispose(); 22 | m_Disposable2.Dispose(); 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Internal/Disposable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 888e6c1c23bdb2a42b700d3c5c3859b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Internal/Error.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using UnityEngine; 4 | 5 | namespace MackySoft.XPool.Internal { 6 | internal static class Error { 7 | 8 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 9 | public static ArgumentNullException ArgumentNullException (string paramName) { 10 | return new ArgumentNullException(paramName); 11 | } 12 | 13 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 14 | public static InvalidOperationException EmptyCollection () { 15 | return new InvalidOperationException("Collection is empty."); 16 | } 17 | 18 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 19 | public static ArgumentOutOfRangeException ArgumentOutOfRangeOfCollection (string paramName) { 20 | return new ArgumentOutOfRangeException(paramName,"Parameter is out of range of collection."); 21 | } 22 | 23 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 24 | public static ArgumentOutOfRangeException RequiredNonNegative (string paramName) { 25 | return new ArgumentOutOfRangeException(paramName,"Must be a non-negative value."); 26 | } 27 | 28 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 29 | public static ArgumentOutOfRangeException RequiredGreaterThanZero (string paramName) { 30 | return new ArgumentOutOfRangeException(paramName,"The value must be greater than 0."); 31 | } 32 | 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public static NullReferenceException FactoryMustReturnNotNull () { 35 | return new NullReferenceException("Factory method must return not null."); 36 | } 37 | 38 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 39 | public static ArgumentException InvalidOffLength () { 40 | return new ArgumentException("Parameter is invalid off length."); 41 | } 42 | 43 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 44 | public static ArgumentOutOfRangeException ArgumentOutOfRangeCount (string paramName) { 45 | return new ArgumentOutOfRangeException(nameof(paramName)); 46 | } 47 | 48 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 49 | public static ArgumentException TemporaryIsDisposed (string paramName) { 50 | return new ArgumentException(paramName,"A temporary object is already disposed."); 51 | } 52 | 53 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 54 | public static InvalidOperationException CannotSetCallback () { 55 | return new InvalidOperationException("Cannot set the callback because the pool is active."); 56 | } 57 | 58 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 59 | public static NotSupportedException FunctionIsNotSupported () { 60 | return new NotSupportedException("This function is not supported."); 61 | } 62 | 63 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 64 | public static MissingReferenceException InstanceDestroyed () { 65 | return new MissingReferenceException("The instance was destroyed in callback."); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Internal/Error.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fd543b5927697f42b70bef79a135658 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/MackySoft.XPool.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MackySoft.XPool", 3 | "rootNamespace": "MackySoft.XPool", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/MackySoft.XPool.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6871bfe906a80344c9fdc325c92c646f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/ObjectModel.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0abae53172615e943aebf2ca27cd2c82 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/ObjectModel/PoolBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool.ObjectModel { 6 | 7 | /// 8 | /// Provides basic features of pool. 9 | /// 10 | public abstract class PoolBase : IPool { 11 | 12 | readonly int m_Capacity; 13 | readonly Queue m_Pool; 14 | 15 | #if !XPOOL_OPTIMIZE 16 | readonly HashSet m_InPool; 17 | #endif 18 | 19 | public int Capacity => m_Capacity; 20 | 21 | public int Count => m_Pool.Count; 22 | 23 | /// 24 | /// Initialize the pool with capacity. The inherited class must call this constructor. 25 | /// 26 | /// The pool capacity. If less than or equal to 0, will be thrown. 27 | protected PoolBase (int capacity) { 28 | if (capacity < 0) { 29 | throw Error.RequiredNonNegative(nameof(capacity)); 30 | } 31 | m_Capacity = capacity; 32 | m_Pool = new Queue(capacity); 33 | 34 | #if !XPOOL_OPTIMIZE 35 | m_InPool = new HashSet(); 36 | #endif 37 | } 38 | 39 | /// 40 | /// Return the pooled instance. If pool is empty, create new instance and returns it. 41 | /// 42 | /// 43 | public T Rent () { 44 | T instance; 45 | if (m_Pool.Count > 0) { 46 | instance = m_Pool.Dequeue(); 47 | #if !XPOOL_OPTIMIZE 48 | m_InPool.Remove(instance); 49 | #endif 50 | } 51 | else { 52 | instance = Factory() ?? throw Error.FactoryMustReturnNotNull(); 53 | } 54 | 55 | OnRent(instance); 56 | return instance; 57 | } 58 | 59 | /// 60 | /// Return instance to the pool. If the capacity is exceeded, the instance will not be returned to the pool. 61 | /// 62 | /// 63 | public void Return (T instance) { 64 | if (instance == null) { 65 | throw Error.ArgumentNullException(nameof(instance)); 66 | } 67 | if (m_Pool.Count == m_Capacity) { 68 | OnRelease(instance); 69 | return; 70 | } 71 | #if !XPOOL_OPTIMIZE 72 | if (!m_InPool.Add(instance)) { 73 | return; 74 | } 75 | #endif 76 | m_Pool.Enqueue(instance); 77 | OnReturn(instance); 78 | } 79 | 80 | /// 81 | /// Keeps the specified quantity and releases the pooled instances. 82 | /// 83 | /// Quantity that keep pooled instances. If less than 0 or greater than capacity, will be thrown. 84 | public void ReleaseInstances (int keep) { 85 | if ((keep < 0) || (keep > m_Capacity)) { 86 | throw Error.ArgumentOutOfRangeOfCollection(nameof(keep)); 87 | } 88 | 89 | if (keep != 0) { 90 | for (int i = m_Pool.Count - keep;i > 0;i--) { 91 | T instance = m_Pool.Dequeue(); 92 | OnRelease(instance); 93 | #if !XPOOL_OPTIMIZE 94 | m_InPool.Remove(instance); 95 | #endif 96 | } 97 | } 98 | else { 99 | while (m_Pool.Count > 0) { 100 | T instance = m_Pool.Dequeue(); 101 | OnRelease(instance); 102 | } 103 | #if !XPOOL_OPTIMIZE 104 | m_InPool.Clear(); 105 | #endif 106 | } 107 | } 108 | 109 | /// 110 | /// Called when called if pool is empty. This method must return a not null. 111 | /// 112 | protected abstract T Factory (); 113 | 114 | /// 115 | /// Called when rent an instance from the pool. 116 | /// 117 | protected abstract void OnRent (T instance); 118 | 119 | /// 120 | /// Called when return an instance to the pool. 121 | /// 122 | protected abstract void OnReturn (T instance); 123 | 124 | /// 125 | /// Called when the capacity of the pool is exceeded and the instance cannot be returned. The process to release the object must be performed, such as Dispose. 126 | /// 127 | protected abstract void OnRelease (T instance); 128 | 129 | } 130 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/ObjectModel/PoolBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b8154baf11a70b40b7b9ac1ea71206c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/PoolExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MackySoft.XPool.Internal; 3 | 4 | namespace MackySoft.XPool { 5 | public static partial class PoolExtensions { 6 | 7 | /// 8 | /// Release the all pooled instances. 9 | /// 10 | /// 11 | public static void Clear (this IPool pool) { 12 | if (pool == null) { 13 | throw Error.ArgumentNullException(nameof(pool)); 14 | } 15 | pool.ReleaseInstances(0); 16 | } 17 | 18 | /// 19 | /// Return the instance to the pool and set reference to null. 20 | /// 21 | /// 22 | public static void Return (this IPool pool,ref T instance) { 23 | if (pool == null) { 24 | throw Error.ArgumentNullException(nameof(pool)); 25 | } 26 | pool.Return(instance); 27 | instance = default; 28 | } 29 | 30 | /// 31 | /// Temporary rent an instance from pool. By using the using statement, you can safely return instance. 32 | /// 33 | /// using (myPool.RentTemporary(out var instance)) { 34 | /// // Use instance... 35 | /// } 36 | /// 37 | /// 38 | public static RentInstance RentTemporary (this IPool pool,out T instance) { 39 | if (pool == null) { 40 | throw Error.ArgumentNullException(nameof(pool)); 41 | } 42 | instance = pool.Rent(); 43 | return new RentInstance(pool,instance); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/PoolExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa92fc1e6fc2d9343b3b06a403f5044c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Properties.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5e6a8aa94ae53a4ba4ea5dba67fd7d7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("MackySoft.XPool.Tests.Editor")] -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Properties/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adb09105525ebea4fabeeb3ee48459cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/RentInstance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool { 4 | 5 | /// 6 | /// This is a token that indicates that rented an instance from the pool. 7 | /// You can return an instance to the pool by calling . 8 | /// See: 9 | /// 10 | public struct RentInstance : IDisposable { 11 | 12 | readonly T m_Instance; 13 | readonly IPool m_Pool; 14 | 15 | internal RentInstance (IPool pool,T instance) { 16 | m_Pool = pool; 17 | m_Instance = instance; 18 | } 19 | 20 | /// 21 | /// Return instance to the pool. 22 | /// 23 | public void Dispose () => m_Pool.Return(m_Instance); 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/RentInstance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47061e1744888694a8fb5ef81110d2e2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41e5f84c621fc6a4a80b214477c56c77 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/ITimer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool.Timers { 4 | 5 | public interface IReadOnlyTimer { 6 | /// 7 | /// Called when the timer has elapsed. 8 | /// 9 | event Action OnElapsed; 10 | } 11 | 12 | public interface ITimer : IReadOnlyTimer { 13 | /// 14 | /// Update timer. Return true if timer has elapsed. 15 | /// 16 | bool Tick (float deltaTime); 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/ITimer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 528447a0f051eb140a50d1e66fa4324b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/PeriadicTimer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace MackySoft.XPool.Timers { 5 | 6 | /// 7 | /// Timer that resets each time a interval of time elapses. 8 | /// 9 | [Serializable] 10 | public class PeriodicTimer : ITimer { 11 | 12 | [SerializeField] 13 | float m_Interval = 1f; 14 | 15 | float m_ElapsedTime; 16 | 17 | public event Action OnElapsed; 18 | 19 | public float Interval { 20 | get => m_Interval; 21 | set => m_Interval = (value > 0f) ? value : 0.01f; 22 | } 23 | 24 | public PeriodicTimer () { 25 | } 26 | 27 | public PeriodicTimer (float interval) { 28 | Interval = interval; 29 | } 30 | 31 | public bool Tick (float deltaTime) { 32 | m_ElapsedTime += deltaTime; 33 | if (m_ElapsedTime >= m_Interval) { 34 | m_ElapsedTime -= m_Interval; 35 | OnElapsed?.Invoke(); 36 | return true; 37 | } 38 | return false; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/PeriadicTimer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbb02dededa268e4e895d384d9089be1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/PoolExtensions.Timer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MackySoft.XPool.Timers; 3 | using MackySoft.XPool.Internal; 4 | 5 | namespace MackySoft.XPool { 6 | public static partial class PoolExtensions { 7 | 8 | /// 9 | /// Periodically release instances in the pool. 10 | /// 11 | /// Target pool. 12 | /// Time interval to release an instances in the pool. 13 | /// Quantity that keep pooled instances when release instances. 14 | /// 15 | /// 16 | public static IDisposable ReleaseInstancesPeriodically (this IPool pool,float interval,int keep) { 17 | if (pool == null) { 18 | throw Error.ArgumentNullException(nameof(pool)); 19 | } 20 | if (interval <= 0f) { 21 | throw Error.RequiredGreaterThanZero(nameof(interval)); 22 | } 23 | if (keep < 0) { 24 | throw Error.RequiredNonNegative(nameof(keep)); 25 | } 26 | 27 | var timer = new PeriodicTimer(interval); 28 | 29 | // Subscribe timer to the ticker. 30 | IDisposable subscription = TimerTicker.Instance.Subscribe(timer); 31 | 32 | // Bind pool to the timer. 33 | IDisposable binding = BindTo(pool,timer,keep); 34 | 35 | return Disposable.Combine(subscription,binding); 36 | } 37 | 38 | /// 39 | /// Bind the pool to the timer and releases an instances in the pool each time the callback is called. 40 | /// 41 | /// Target pool. 42 | /// Timer to be bound to the pool. 43 | /// Quantity that keep pooled instances when release instances. 44 | /// 45 | /// 46 | public static IDisposable BindTo (this IPool pool,IReadOnlyTimer timer,int keep) { 47 | if (pool == null) { 48 | throw Error.ArgumentNullException(nameof(pool)); 49 | } 50 | if (timer == null) { 51 | throw Error.ArgumentNullException(nameof(timer)); 52 | } 53 | if (keep < 0) { 54 | throw Error.RequiredNonNegative(nameof(keep)); 55 | } 56 | return new TimerBinding(pool,timer,keep); 57 | } 58 | 59 | class TimerBinding : IDisposable { 60 | 61 | readonly IReadOnlyTimer m_Timer; 62 | readonly IPool m_Pool; 63 | readonly int m_Keep; 64 | bool m_IsDisposed; 65 | 66 | public TimerBinding (IPool pool,IReadOnlyTimer timer,int keep) { 67 | m_Pool = pool; 68 | m_Timer = timer; 69 | m_Keep = keep; 70 | 71 | m_Timer.OnElapsed += OnElapsed; 72 | } 73 | 74 | public void Dispose () { 75 | if (m_IsDisposed) { 76 | return; 77 | } 78 | m_IsDisposed = true; 79 | m_Timer.OnElapsed -= OnElapsed; 80 | } 81 | 82 | void OnElapsed () { 83 | m_Pool.ReleaseInstances(m_Keep > m_Pool.Capacity ? m_Pool.Capacity : m_Keep); 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/PoolExtensions.Timer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36bd87ebb47eaf3469f28ef308cfa24d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/TimerTicker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | using UnityEngine; 5 | 6 | namespace MackySoft.XPool.Timers { 7 | 8 | /// 9 | /// A component that keeps updating the registered timers. 10 | /// 11 | public class TimerTicker : MonoBehaviour { 12 | 13 | public static TimerTicker Instance { 14 | get { 15 | if (s_Instance == null) { 16 | var go = new GameObject("[XPool] TimerTicker"); 17 | s_Instance = go.AddComponent(); 18 | DontDestroyOnLoad(go); 19 | } 20 | return s_Instance; 21 | } 22 | } 23 | 24 | static TimerTicker s_Instance; 25 | 26 | readonly List m_Timers = new List(); 27 | 28 | void Awake () { 29 | if (s_Instance == null) { 30 | s_Instance = this; 31 | } 32 | } 33 | 34 | void OnDestroy () { 35 | if (s_Instance == this) { 36 | s_Instance = null; 37 | } 38 | } 39 | 40 | void Update () { 41 | float deltaTime = Time.deltaTime; 42 | for (int i = 0;i < m_Timers.Count;i++) { 43 | m_Timers[i].Tick(deltaTime); 44 | } 45 | } 46 | 47 | public void Register (ITimer timer) { 48 | if ((timer == null) || m_Timers.Contains(timer)) { 49 | return; 50 | } 51 | m_Timers.Add(timer); 52 | } 53 | 54 | public void Unregister (ITimer timer) { 55 | m_Timers.Remove(timer); 56 | } 57 | 58 | public IDisposable Subscribe (ITimer timer) { 59 | return (timer != null) ? new TimerRegistration(timer,this) : throw Error.ArgumentNullException(nameof(timer)); 60 | } 61 | 62 | class TimerRegistration : IDisposable { 63 | 64 | readonly ITimer m_Timer; 65 | readonly TimerTicker m_TimerTicker; 66 | bool m_IsDisposed; 67 | 68 | public TimerRegistration (ITimer timer,TimerTicker timerTicker) { 69 | m_Timer = timer; 70 | m_TimerTicker = timerTicker; 71 | 72 | m_TimerTicker.Register(timer); 73 | } 74 | 75 | public void Dispose () { 76 | if (m_IsDisposed) { 77 | return; 78 | } 79 | m_IsDisposed = true; 80 | 81 | if (m_TimerTicker != null) { 82 | m_TimerTicker.Unregister(m_Timer); 83 | } 84 | } 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Timers/TimerTicker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2b8d3437b24a7b4b8dafd08c0cd881f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4933db97161cfe94e9f074f696031810 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ComponentPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityObject = UnityEngine.Object; 4 | 5 | namespace MackySoft.XPool.Unity { 6 | 7 | /// 8 | /// A pool for Component. 9 | /// 10 | [Serializable] 11 | public class ComponentPool : UnityObjectPool, IHierarchicalUnityObjectPool where T : Component { 12 | 13 | public ComponentPool () { 14 | } 15 | 16 | /// The original object from which the pool will instantiate a new instance. 17 | /// The pool capacity. If less than 0, will be thrown. 18 | /// 19 | /// 20 | public ComponentPool (T original,int capacity) : base(original,capacity) { 21 | } 22 | 23 | public T Rent (Vector3 position,Quaternion rotation,Transform parent = null) { 24 | T instance = GetPooledInstance(); 25 | if (instance != null) { 26 | Transform transform = parent.transform; 27 | transform.SetParent(parent); 28 | transform.SetPositionAndRotation(position,rotation); 29 | } 30 | else { 31 | instance = UnityObject.Instantiate(m_Original,position,rotation,parent); 32 | m_OnCreate?.Invoke(instance);; 33 | } 34 | m_OnRent?.Invoke(instance); 35 | return instance; 36 | } 37 | 38 | public T Rent (Transform parent,bool worldPositionStays) { 39 | T instance = GetPooledInstance(); 40 | if (instance != null) { 41 | instance.transform.SetParent(parent,worldPositionStays); 42 | } 43 | else { 44 | instance = UnityObject.Instantiate(m_Original,parent,worldPositionStays); 45 | m_OnCreate?.Invoke(instance); 46 | } 47 | m_OnRent?.Invoke(instance); 48 | return instance; 49 | } 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ComponentPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5ced2797349c814cb12ad26003cc60b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ComponentPool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35dea0d2b1909a446a3550640bf87a1c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ComponentPool/ParticleSystemPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MackySoft.XPool.Unity.ObjectModel; 4 | 5 | namespace MackySoft.XPool.Unity { 6 | 7 | /// 8 | /// Optimized pool for . 9 | /// 10 | [Serializable] 11 | public class ParticleSystemPool : ComponentPoolBase { 12 | 13 | [Tooltip("If true, ParticleSystem will play when the it is rented.")] 14 | [SerializeField] 15 | bool m_PlayOnRent = true; 16 | 17 | /// 18 | /// If true, will play when the it is rented. 19 | /// 20 | public bool PlayOnRent { get => m_PlayOnRent; set => m_PlayOnRent = value; } 21 | 22 | public ParticleSystemPool () { 23 | } 24 | 25 | /// The original object from which the pool will instantiate a new instance. 26 | /// The pool capacity. If less than 0, will be thrown. 27 | /// 28 | /// 29 | public ParticleSystemPool (ParticleSystem original,int capacity) : base(original,capacity) { 30 | } 31 | 32 | protected override void OnCreate (ParticleSystem instance) { 33 | var main = instance.main; 34 | main.stopAction = ParticleSystemStopAction.Callback; 35 | var trigger = instance.gameObject.AddComponent(); 36 | trigger.Initialize(instance,this); 37 | } 38 | 39 | protected override void OnRent (ParticleSystem instance) { 40 | if (m_PlayOnRent) { 41 | instance.Play(true); 42 | } 43 | } 44 | 45 | protected override void OnReturn (ParticleSystem instance) { 46 | instance.Stop(true,ParticleSystemStopBehavior.StopEmitting); 47 | } 48 | 49 | protected override void OnRelease (ParticleSystem instance) { 50 | UnityEngine.Object.Destroy(instance.gameObject); 51 | } 52 | 53 | public class ParticleSystemStoppedTrigger : MonoBehaviour { 54 | 55 | ParticleSystem m_ParticleSystem; 56 | IPool m_Pool; 57 | 58 | internal void Initialize (ParticleSystem ps,IPool pool) { 59 | m_ParticleSystem = ps; 60 | m_Pool = pool; 61 | } 62 | 63 | void OnParticleSystemStopped () { 64 | m_Pool?.Return(m_ParticleSystem); 65 | } 66 | 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ComponentPool/ParticleSystemPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce024f912e13b9043bbadb69db5fe59b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/DefaultFunctions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityObject = UnityEngine.Object; 4 | 5 | namespace MackySoft.XPool.Unity { 6 | public static class DefaultFunctions { 7 | 8 | public static Action Destroy () where T : UnityObject { 9 | return CachedUnityObjectFunctions.Destroy; 10 | } 11 | 12 | public static Action DestroyGameObjectWithComponent () where T : Component { 13 | return CachedComponentFunctions.DestroyGameObjectWithComponent; 14 | } 15 | 16 | static class CachedUnityObjectFunctions where T : UnityObject { 17 | 18 | public static readonly Action Destroy = instance => { 19 | #if UNITY_EDITOR 20 | if (Application.isPlaying) { 21 | UnityObject.Destroy(instance); 22 | } 23 | else { 24 | UnityObject.DestroyImmediate(instance); 25 | } 26 | #else 27 | UnityObject.Destroy(instance); 28 | #endif 29 | }; 30 | } 31 | 32 | static class CachedComponentFunctions where T : Component { 33 | 34 | public static readonly Action DestroyGameObjectWithComponent = instance => { 35 | #if UNITY_EDITOR 36 | if (Application.isPlaying) { 37 | UnityObject.Destroy(instance.gameObject); 38 | } 39 | else { 40 | UnityObject.DestroyImmediate(instance.gameObject); 41 | } 42 | #else 43 | UnityObject.Destroy(instance.gameObject); 44 | #endif 45 | }; 46 | } 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/DefaultFunctions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55473a8626e679f44b40861f8c7e9024 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/GameObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityObject = UnityEngine.Object; 4 | 5 | namespace MackySoft.XPool.Unity { 6 | 7 | /// 8 | /// A pool for GameObject. 9 | /// 10 | [Serializable] 11 | public class GameObjectPool : UnityObjectPool, IHierarchicalUnityObjectPool { 12 | 13 | public GameObjectPool () { 14 | } 15 | 16 | /// The original object from which the pool will instantiate a new instance. 17 | /// The pool capacity. If less than 0, will be thrown. 18 | /// 19 | /// 20 | public GameObjectPool (GameObject original,int capacity) : base(original,capacity) { 21 | } 22 | 23 | public GameObject Rent (Vector3 position,Quaternion rotation,Transform parent = null) { 24 | GameObject instance = GetPooledInstance(); 25 | if (instance != null) { 26 | Transform transform = parent.transform; 27 | transform.SetParent(parent); 28 | transform.SetPositionAndRotation(position,rotation); 29 | } 30 | else { 31 | instance = UnityObject.Instantiate(m_Original,position,rotation,parent); 32 | m_OnCreate?.Invoke(instance); 33 | } 34 | m_OnRent?.Invoke(instance); 35 | return instance; 36 | } 37 | 38 | public GameObject Rent (Transform parent,bool worldPositionStays) { 39 | GameObject instance = GetPooledInstance(); 40 | if (instance != null) { 41 | instance.transform.SetParent(parent,worldPositionStays); 42 | } 43 | else { 44 | instance = UnityObject.Instantiate(m_Original,parent,worldPositionStays); 45 | m_OnCreate?.Invoke(instance); 46 | } 47 | m_OnRent?.Invoke(instance); 48 | return instance; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/GameObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 109004947b9806e4bb3bf0b08ebb27cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/IUnityObjectPool.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityObject = UnityEngine.Object; 3 | 4 | namespace MackySoft.XPool.Unity { 5 | 6 | /// 7 | /// Interface that provides a pool for . 8 | /// 9 | public interface IUnityObjectPool : IPool where T : UnityObject { 10 | 11 | } 12 | 13 | /// 14 | /// Interface that provides rent method for GameObject or components. 15 | /// 16 | public interface IHierarchicalUnityObjectPool : IUnityObjectPool where T : UnityObject { 17 | 18 | /// 19 | /// Return the pooled instance. If pool is empty, create new instance and returns it. 20 | /// 21 | T Rent (Vector3 position,Quaternion rotation,Transform parent = null); 22 | 23 | /// 24 | /// Return the pooled instance. If pool is empty, create new instance and returns it. 25 | /// 26 | T Rent (Transform parent,bool worldPositionStays); 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/IUnityObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddbafeda9e6b266429e34202260e30f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ObjectModel.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89d6d7447fb4c1c4da762ad174ec4e91 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ObjectModel/ComponentPoolBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MackySoft.XPool.Internal; 3 | using UnityEngine; 4 | 5 | namespace MackySoft.XPool.Unity.ObjectModel { 6 | 7 | /// 8 | /// Base of pool for . 9 | /// 10 | public abstract class ComponentPoolBase : UnityObjectPoolBase, IHierarchicalUnityObjectPool where T : Component { 11 | 12 | protected ComponentPoolBase () { 13 | } 14 | 15 | /// The original object from which the pool will instantiate a new instance. 16 | /// The pool capacity. If less than 0, will be thrown. 17 | /// 18 | /// 19 | protected ComponentPoolBase (T original,int capacity) : base(original,capacity) { 20 | } 21 | 22 | public T Rent (Vector3 position,Quaternion rotation,Transform parent = null) { 23 | T instance = GetPooledInstance(); 24 | if (instance != null) { 25 | Transform transform = parent.transform; 26 | transform.SetParent(parent); 27 | transform.SetPositionAndRotation(position,rotation); 28 | } 29 | else { 30 | instance = UnityEngine.Object.Instantiate(m_Original,position,rotation,parent); 31 | OnCreate(instance); 32 | } 33 | OnRent(instance); 34 | 35 | return (instance != null) ? instance : throw Error.InstanceDestroyed(); 36 | } 37 | 38 | public T Rent (Transform parent,bool worldPositionStays) { 39 | T instance = GetPooledInstance(); 40 | if (instance != null) { 41 | instance.transform.SetParent(parent,worldPositionStays); 42 | } 43 | else { 44 | instance = UnityEngine.Object.Instantiate(m_Original,parent,worldPositionStays); 45 | OnCreate(instance); 46 | } 47 | OnRent(instance); 48 | 49 | return (instance != null) ? instance : throw Error.InstanceDestroyed(); 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ObjectModel/ComponentPoolBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b650bd23ef12ff648a98c5b19b34eb94 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ObjectModel/UnityObjectPoolBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | using UnityEngine; 5 | using UnityObject = UnityEngine.Object; 6 | 7 | namespace MackySoft.XPool.Unity.ObjectModel { 8 | 9 | /// 10 | /// Base of pool for . 11 | /// 12 | public abstract class UnityObjectPoolBase : IUnityObjectPool where T : UnityObject { 13 | 14 | [Tooltip("The original object from which the pool will instantiate a new instance.")] 15 | [SerializeField] 16 | protected T m_Original; 17 | 18 | [Tooltip("Capacity to store instances in the pool.")] 19 | [SerializeField] 20 | int m_Capacity; 21 | 22 | readonly Queue m_Pool = new Queue(); 23 | 24 | public int Capacity => m_Capacity; 25 | 26 | public int Count => m_Pool.Count; 27 | 28 | protected UnityObjectPoolBase () { 29 | } 30 | 31 | /// The original object from which the pool will instantiate a new instance. 32 | /// The pool capacity. If less than 0, will be thrown. 33 | /// 34 | /// 35 | protected UnityObjectPoolBase (T original,int capacity) { 36 | m_Original = (original != null) ? original : throw Error.ArgumentNullException(nameof(original)); 37 | m_Capacity = (capacity >= 0) ? capacity : throw Error.RequiredNonNegative(nameof(capacity)); 38 | } 39 | 40 | public T Rent () { 41 | T instance = GetPooledInstance(); 42 | if (instance == null) { 43 | instance = UnityObject.Instantiate(m_Original); 44 | OnCreate(instance); 45 | } 46 | OnRent(instance); 47 | 48 | return (instance != null) ? instance : throw Error.InstanceDestroyed(); 49 | } 50 | 51 | public void Return (T instance) { 52 | if (instance == null) { 53 | throw Error.ArgumentNullException(nameof(instance)); 54 | } 55 | if (m_Pool.Count == m_Capacity) { 56 | OnRelease(instance); 57 | return; 58 | } 59 | m_Pool.Enqueue(instance); 60 | OnReturn(instance); 61 | } 62 | 63 | public void ReleaseInstances (int keep) { 64 | if ((keep < 0) || (keep > m_Capacity)) { 65 | throw Error.ArgumentOutOfRangeOfCollection(nameof(keep)); 66 | } 67 | 68 | if (keep != 0) { 69 | for (int i = m_Pool.Count - keep;i > 0;i--) { 70 | T instance = m_Pool.Dequeue(); 71 | if (instance != null) { 72 | OnRelease(instance); 73 | } 74 | } 75 | } 76 | else { 77 | while (m_Pool.Count > 0) { 78 | T instance = m_Pool.Dequeue(); 79 | if (instance != null) { 80 | OnRelease(instance); 81 | } 82 | } 83 | } 84 | } 85 | 86 | /// 87 | /// Try to get an instance until the pool is empty or an instance can be retrieved. 88 | /// This is because can become null externally due to the method. 89 | /// 90 | protected T GetPooledInstance () { 91 | T instance = null; 92 | while ((m_Pool.Count > 0) && (instance == null)) { 93 | instance = m_Pool.Dequeue(); 94 | } 95 | return instance; 96 | } 97 | 98 | /// 99 | /// Called when called if pool is empty and new instance is instantiated by the pool. 100 | /// 101 | protected abstract void OnCreate (T instance); 102 | 103 | /// 104 | /// Called when rent an instance from the pool. 105 | /// 106 | protected abstract void OnRent (T instance); 107 | 108 | /// 109 | /// Called when return an instance to the pool. 110 | /// 111 | protected abstract void OnReturn (T instance); 112 | 113 | /// 114 | /// Called when the capacity of the pool is exceeded and the instance cannot be returned. The process to release the object must be performed, such as Dispose. 115 | /// 116 | protected abstract void OnRelease (T instance); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/ObjectModel/UnityObjectPoolBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a5fe59b4c79b1d4f9c87e2e0fb04940 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/UnityObjectPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using MackySoft.XPool.Internal; 4 | using UnityEngine; 5 | using UnityObject = UnityEngine.Object; 6 | 7 | namespace MackySoft.XPool.Unity { 8 | 9 | /// 10 | /// A pool for object that inherit from . 11 | /// 12 | [Serializable] 13 | public class UnityObjectPool : IUnityObjectPool where T : UnityObject { 14 | 15 | [Tooltip("The original object from which the pool will instantiate a new instance.")] 16 | [SerializeField] 17 | protected T m_Original; 18 | 19 | [Tooltip("Capacity to store instances in the pool.")] 20 | [SerializeField] 21 | int m_Capacity; 22 | 23 | readonly Queue m_Pool = new Queue(); 24 | 25 | protected Action m_OnCreate; 26 | protected Action m_OnRent; 27 | protected Action m_OnReturn; 28 | protected Action m_OnRelease; 29 | 30 | /// 31 | /// The original object from which the pool will instantiate a new instance. 32 | /// 33 | public T Original => m_Original; 34 | 35 | public int Capacity => m_Capacity; 36 | 37 | public int Count => m_Pool.Count; 38 | 39 | /// 40 | /// Called when called if pool is empty and new instance is instantiated by the pool. 41 | /// 42 | public Action OnCreate { set => SetCallback(ref m_OnCreate,value); } 43 | 44 | /// 45 | /// Called when rent an instance from the pool. 46 | /// 47 | public Action OnRent { set => SetCallback(ref m_OnRent,value); } 48 | 49 | /// 50 | /// Called when return an instance to the pool. 51 | /// 52 | public Action OnReturn { set => SetCallback(ref m_OnReturn,value); } 53 | 54 | /// 55 | /// Called when the capacity of the pool is exceeded and the instance cannot be returned. The process to release the object must be performed, such as Dispose. 56 | /// 57 | public Action OnRelease { set => SetCallback(ref m_OnRelease,value); } 58 | 59 | public UnityObjectPool () { 60 | } 61 | 62 | /// The original object from which the pool will instantiate a new instance. 63 | /// The pool capacity. If less than 0, will be thrown. 64 | /// 65 | /// 66 | public UnityObjectPool (T original,int capacity) { 67 | m_Original = (original != null) ? original : throw Error.ArgumentNullException(nameof(original)); 68 | m_Capacity = (capacity >= 0) ? capacity : throw Error.RequiredNonNegative(nameof(capacity)); 69 | } 70 | 71 | public T Rent () { 72 | T instance = GetPooledInstance(); 73 | if (instance == null) { 74 | instance = UnityObject.Instantiate(m_Original); 75 | m_OnCreate?.Invoke(instance); 76 | } 77 | m_OnRent?.Invoke(instance); 78 | return instance; 79 | } 80 | 81 | public void Return (T instance) { 82 | if (instance == null) { 83 | throw Error.ArgumentNullException(nameof(instance)); 84 | } 85 | if (m_Pool.Count == m_Capacity) { 86 | m_OnRelease.Invoke(instance); 87 | return; 88 | } 89 | m_Pool.Enqueue(instance); 90 | m_OnReturn?.Invoke(instance); 91 | } 92 | 93 | public void ReleaseInstances (int keep) { 94 | if ((keep < 0) || (keep > m_Capacity)) { 95 | throw Error.ArgumentOutOfRangeOfCollection(nameof(keep)); 96 | } 97 | 98 | if (keep != 0) { 99 | for (int i = m_Pool.Count - keep;i > 0;i--) { 100 | T instance = m_Pool.Dequeue(); 101 | if (instance != null) { 102 | m_OnRelease.Invoke(instance); 103 | } 104 | } 105 | } 106 | else { 107 | while (m_Pool.Count > 0) { 108 | T instance = m_Pool.Dequeue(); 109 | if (instance != null) { 110 | m_OnRelease.Invoke(instance); 111 | } 112 | } 113 | } 114 | } 115 | 116 | /// 117 | /// Try to get an instance until the pool is empty or an instance can be retrieved. 118 | /// This is because can become null externally due to the method. 119 | /// 120 | protected T GetPooledInstance () { 121 | T instance = null; 122 | while ((m_Pool.Count > 0) && (instance == null)) { 123 | instance = m_Pool.Dequeue(); 124 | } 125 | return instance; 126 | } 127 | 128 | /// 129 | /// Set the callback. If used when the pool is not empty, i.e. when the pool is active, throw . 130 | /// 131 | void SetCallback (ref Action target,Action call) { 132 | target = (m_Pool.Count == 0) ? call : throw Error.CannotSetCallback(); 133 | } 134 | 135 | } 136 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Runtime/Unity/UnityObjectPool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edc35edf315e76c46a8e8968a4aa2a1d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b243b5cb074efbb4ca9e554965aedba7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a656218de3939040ab1b613ec5c19a2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 538116277c58ec44badd35c23ea788a5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/ArrayPoolTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using NUnit.Framework; 5 | using Unity.PerformanceTesting; 6 | using UnityEngine; 7 | using UnityEngine.TestTools.Constraints; 8 | using MackySoft.XPool.Tests; 9 | using Is = UnityEngine.TestTools.Constraints.Is; 10 | 11 | namespace MackySoft.XPool.Collections.Tests { 12 | public class ArrayPoolTest { 13 | 14 | static readonly int[] kArraySizes = new int[] { 15 | 8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576 16 | }; 17 | 18 | ArrayPool m_Pool; 19 | 20 | [SetUp] 21 | public void Init () { 22 | m_Pool = new ArrayPool(); 23 | } 24 | 25 | [Test] 26 | public void Throw_if_required_size_is_negative () { 27 | Assert.Throws(typeof(ArgumentOutOfRangeException),() => m_Pool.Rent(-1)); 28 | } 29 | 30 | [Test] 31 | public void Return_empty_array_if_required_size_is_zero () { 32 | Assert.IsEmpty(m_Pool.Rent(0)); 33 | } 34 | 35 | [Test] 36 | public void Return_minimum_size_array_if_required_size_less_than_minimum_array_size () { 37 | Assert.AreEqual(ArrayPoolUtility.kMinArraySize,m_Pool.Rent(1).Length); 38 | } 39 | 40 | [Test, TestCaseSource(nameof(kArraySizes))] 41 | public void Returned_array_size_is_next_power_of_two (int powerOfTwoSize) { 42 | // 8 -> 8 43 | Assert.AreEqual(powerOfTwoSize,m_Pool.Rent(powerOfTwoSize).Length); 44 | 45 | // 7 -> 8 46 | Assert.AreEqual(powerOfTwoSize,m_Pool.Rent(powerOfTwoSize - 1).Length); 47 | 48 | // 9 -> 16 49 | Assert.AreEqual(powerOfTwoSize * 2,m_Pool.Rent(powerOfTwoSize + 1).Length); 50 | } 51 | 52 | [Test] 53 | public void Rent_does_not_allocate () { 54 | WarmUp(5); 55 | 56 | Assert.That(() => { 57 | m_Pool.Rent(5); 58 | },Is.Not.AllocatingGCMemory()); 59 | } 60 | 61 | [Test] 62 | public void Return_does_not_allocate () { 63 | WarmUp(5); 64 | 65 | var array = m_Pool.Rent(5); 66 | Assert.That(() => { 67 | m_Pool.Return(array); 68 | },Is.Not.AllocatingGCMemory()); 69 | } 70 | 71 | void WarmUp (int size) { 72 | m_Pool.Return(m_Pool.Rent(size)); 73 | } 74 | 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/ArrayPoolTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 936e642b233824c488bd6d9250c5652f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/CollectionPoolBaseTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UnityEngine.TestTools.Constraints; 3 | using MackySoft.XPool.Tests; 4 | using Is = UnityEngine.TestTools.Constraints.Is; 5 | 6 | namespace MackySoft.XPool.Collections.Tests { 7 | public class CollectionPoolBaseTest { 8 | 9 | ListPool m_Pool; 10 | 11 | [SetUp] 12 | public void Init () { 13 | m_Pool = new ListPool(); 14 | } 15 | 16 | [Test] 17 | public void Rent_does_not_allocate () { 18 | m_Pool.WarmUp(1); 19 | 20 | Assert.That(() => { 21 | m_Pool.Rent(); 22 | },Is.Not.AllocatingGCMemory()); 23 | } 24 | 25 | [Test] 26 | public void Return_does_not_allocate () { 27 | m_Pool.WarmUp(1); 28 | 29 | var array = m_Pool.Rent(); 30 | Assert.That(() => { 31 | m_Pool.Return(array); 32 | },Is.Not.AllocatingGCMemory()); 33 | } 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/CollectionPoolBaseTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a9022a5519a48d44ac79de320aed292 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryArrayTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEngine; 5 | using MackySoft.XPool.Tests; 6 | 7 | namespace MackySoft.XPool.Collections.Tests { 8 | public class TemporaryArrayTest { 9 | 10 | ArrayPool m_Pool; 11 | 12 | [SetUp] 13 | public void Init () { 14 | m_Pool = new ArrayPool(); 15 | } 16 | 17 | [Test] 18 | public void Create_method_return_expected_array () { 19 | var array = TemporaryArray.Create(6,m_Pool); 20 | Assert.AreEqual(6,array.Length); 21 | Assert.AreEqual(8,array.Capacity); 22 | } 23 | 24 | [Test] 25 | public void Array_is_null_when_disposed () { 26 | var array = TemporaryArray.Create(0,m_Pool); 27 | array.Dispose(); 28 | Assert.IsNull(array.Array); 29 | } 30 | 31 | [Test] 32 | public void Same_as_copied_collection () { 33 | var collection = new int[] { 1,2,3 }; 34 | var array = TemporaryArray.From(collection,ArrayPool.Shared); 35 | CollectionAssert.AreEqual(collection,array); 36 | } 37 | 38 | [Test] 39 | public void Same_as_copied_temporary_array () { 40 | var collection = new int[] { 1,2,3 }; 41 | var sourceArray = TemporaryArray.From(collection); 42 | var copiedArray = TemporaryArray.From(sourceArray); 43 | CollectionAssert.AreEqual(sourceArray,copiedArray); 44 | } 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryArrayTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23a50332be44e11488fe930521f00488 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryListTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UnityEngine; 3 | using UnityEngine.TestTools.Constraints; 4 | using MackySoft.XPool.Tests; 5 | using Is = UnityEngine.TestTools.Constraints.Is; 6 | 7 | namespace MackySoft.XPool.Collections.Tests { 8 | public class TemporaryListTest { 9 | 10 | ArrayPool m_Pool; 11 | 12 | [SetUp] 13 | public void Init () { 14 | m_Pool = new ArrayPool(); 15 | } 16 | 17 | [Test] 18 | public void Create_method_return_expected_list () { 19 | using (var list = TemporaryList.Create(m_Pool)) { 20 | Assert.AreEqual(0,list.Count); 21 | Assert.AreEqual(0,list.Capacity); 22 | } 23 | using (var list = TemporaryList.Create(6,m_Pool)) { 24 | Assert.AreEqual(0,list.Count); 25 | Assert.AreEqual(8,list.Capacity); 26 | } 27 | } 28 | 29 | [Test] 30 | public void Array_is_null_when_disposed () { 31 | var list = TemporaryList.Create(m_Pool); 32 | Assert.IsNotNull(list.Array); 33 | 34 | list.Dispose(); 35 | Assert.IsNull(list.Array); 36 | } 37 | 38 | [Test] 39 | public void Same_as_copied_collection () { 40 | var collection = new int[] { 1,2,3 }; 41 | using (var list = TemporaryList.From(collection)) { 42 | CollectionAssert.AreEqual(collection,list); 43 | } 44 | } 45 | 46 | [Test] 47 | public void Add_does_not_allocate () { 48 | using (var list = TemporaryList.Create(8,m_Pool)) { 49 | // Warm up 50 | list.Add(Unit.Default); 51 | 52 | Assert.That(() => { 53 | list.Add(Unit.Default); 54 | },Is.Not.AllocatingGCMemory()); 55 | } 56 | } 57 | 58 | } 59 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryListTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4126daaa1f218c439b87ce6aa70e7e5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryQueueTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using UnityEngine; 3 | using UnityEngine.TestTools.Constraints; 4 | using MackySoft.XPool.Tests; 5 | using Is = UnityEngine.TestTools.Constraints.Is; 6 | 7 | namespace MackySoft.XPool.Collections.Tests { 8 | public class TemporaryQueueTest { 9 | 10 | ArrayPool m_Pool; 11 | 12 | [SetUp] 13 | public void Init () { 14 | m_Pool = new ArrayPool(); 15 | } 16 | 17 | [Test] 18 | public void Create_method_return_expected_queue () { 19 | using (var queue = TemporaryQueue.Create(m_Pool)) { 20 | Assert.Zero(queue.Count); 21 | Assert.Zero(queue.Capacity); 22 | } 23 | using (var queue = TemporaryQueue.Create(0,m_Pool)) { 24 | Assert.Zero(queue.Count); 25 | Assert.Zero(queue.Capacity); 26 | } 27 | } 28 | 29 | [Test] 30 | public void Enqueue_succeeded () { 31 | using (var queue = TemporaryQueue.Create(m_Pool)) { 32 | var item = new Unit(); 33 | queue.Enqueue(item); 34 | Assert.AreSame(item,queue.GetElement(0)); 35 | } 36 | using (var queue = TemporaryQueue.Create(8,m_Pool)) { 37 | while (queue.Capacity > queue.Count) { 38 | queue.Enqueue(new Unit()); 39 | } 40 | Assert.AreEqual(8,queue.Count); 41 | 42 | var item = new Unit(); 43 | queue.Enqueue(item); 44 | Assert.AreSame(item,queue.GetElement(8)); 45 | Assert.AreEqual(16,queue.Capacity); 46 | } 47 | } 48 | 49 | [Test] 50 | public void Dequeue_succeeded () { 51 | using (var queue = TemporaryQueue.Create(m_Pool)) { 52 | var item = new Unit(); 53 | queue.Enqueue(item); 54 | Assert.AreSame(item,queue.Dequeue()); 55 | } 56 | using (var queue = TemporaryQueue.Create(m_Pool)) { 57 | for (int i = 0;8 > i;i++) { 58 | var item = new Unit(); 59 | queue.Enqueue(item); 60 | Assert.AreSame(item,queue.Dequeue()); 61 | } 62 | } 63 | } 64 | 65 | [Test] 66 | public void Clear_succeeded () { 67 | using (var queue = TemporaryQueue.Create(m_Pool)) { 68 | var item = new Unit(); 69 | queue.Enqueue(item); 70 | 71 | queue.Clear(); 72 | Assert.IsEmpty(queue); 73 | } 74 | } 75 | 76 | [Test] 77 | public void Same_as_copied_array () { 78 | using (var queue = TemporaryQueue.Create(m_Pool)) { 79 | for (int i = 0;8 > i;i++) { 80 | var item = new Unit(); 81 | queue.Enqueue(item); 82 | } 83 | Unit[] array = new Unit[8]; 84 | queue.CopyTo(array,0); 85 | CollectionAssert.AreEqual(queue,array); 86 | } 87 | } 88 | 89 | [Test] 90 | public void Array_is_null_when_disposed () { 91 | var queue = TemporaryQueue.Create(m_Pool); 92 | Assert.IsNotNull(queue.Array); 93 | 94 | queue.Dispose(); 95 | Assert.IsNull(queue.Array); 96 | } 97 | 98 | } 99 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryQueueTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48459aec97194a5469db33a34fce08fc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryStackTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using NUnit.Framework; 5 | using UnityEngine; 6 | using UnityEngine.TestTools.Constraints; 7 | using MackySoft.XPool.Tests; 8 | using Is = UnityEngine.TestTools.Constraints.Is; 9 | using MackySoft.XPool.Collections; 10 | 11 | namespace MackySoft.XPool.Collections.Tests { 12 | public class TemporaryStackTest { 13 | 14 | ArrayPool m_Pool; 15 | 16 | [SetUp] 17 | public void Init () { 18 | m_Pool = new ArrayPool(); 19 | } 20 | 21 | [Test] 22 | public void Create_method_return_expected_stack () { 23 | using (var stack = TemporaryStack.Create(m_Pool)) { 24 | Assert.Zero(stack.Count); 25 | Assert.Zero(stack.Capacity); 26 | } 27 | using (var stack = TemporaryStack.Create(0,m_Pool)) { 28 | Assert.Zero(stack.Count); 29 | Assert.Zero(stack.Capacity); 30 | } 31 | } 32 | 33 | [Test] 34 | public void Push_succeeded () { 35 | using (var stack = TemporaryStack.Create(m_Pool)) { 36 | var item = new Unit(); 37 | stack.Push(item); 38 | Assert.AreSame(item,stack.Peek()); 39 | } 40 | using (var stack = TemporaryStack.Create(8,m_Pool)) { 41 | while (stack.Capacity > stack.Count) { 42 | stack.Push(new Unit()); 43 | } 44 | Assert.AreEqual(8,stack.Count); 45 | 46 | var item = new Unit(); 47 | stack.Push(item); 48 | Assert.AreSame(item,stack.Peek()); 49 | Assert.AreEqual(16,stack.Capacity); 50 | } 51 | } 52 | 53 | [Test] 54 | public void Pop_and_Peek_throw_InvalidOperartionException_if_stack_is_empty () { 55 | using (var stack = TemporaryStack.Create(m_Pool)) { 56 | Assert.IsEmpty(stack); 57 | Assert.Throws(() => stack.Pop()); 58 | Assert.Throws(() => stack.Peek()); 59 | } 60 | } 61 | 62 | [Test] 63 | public void Pop_succeeded () { 64 | using (var stack = TemporaryStack.Create(m_Pool)) { 65 | var item = new Unit(); 66 | stack.Push(item); 67 | Assert.AreSame(item,stack.Pop()); 68 | } 69 | using (var stack = TemporaryStack.Create(m_Pool)) { 70 | for (int i = 0;8 > i;i++) { 71 | stack.Push(new Unit()); 72 | } 73 | for (int i = 0;8 > i;i++) { 74 | Unit item = stack.Peek(); 75 | Assert.AreSame(item,stack.Pop()); 76 | } 77 | } 78 | } 79 | 80 | [Test] 81 | public void Clear_succeeded () { 82 | using (var stack = TemporaryStack.Create(m_Pool)) { 83 | var item = new Unit(); 84 | stack.Push(item); 85 | 86 | stack.Clear(); 87 | Assert.IsEmpty(stack); 88 | } 89 | } 90 | 91 | [Test] 92 | public void Same_as_copied_array () { 93 | using (var stack = TemporaryStack.Create(m_Pool)) { 94 | for (int i = 0;8 > i;i++) { 95 | var item = new Unit(); 96 | stack.Push(item); 97 | } 98 | Unit[] array = new Unit[8]; 99 | stack.CopyTo(array,0); 100 | CollectionAssert.AreEqual(stack,array); 101 | } 102 | } 103 | 104 | [Test] 105 | public void Array_is_null_when_disposed () { 106 | var stack = TemporaryStack.Create(m_Pool); 107 | Assert.IsNotNull(stack.Array); 108 | 109 | stack.Dispose(); 110 | Assert.IsNull(stack.Array); 111 | } 112 | 113 | } 114 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Collections/TemporaryStackTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8a4500b1041d864d90ab90a501f7faa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/FactoryPoolTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | 4 | namespace MackySoft.XPool.Tests { 5 | public class FactoryPoolTest { 6 | 7 | class IdentityFunction { 8 | public static readonly Action Action = _ => { }; 9 | public static readonly Func Func = () => default; 10 | } 11 | 12 | [Test] 13 | public void Throw_ArgumentOutOfRangeException_if_capcity_less_than_zero () { 14 | Assert.Throws(() => new FactoryPool(-1,() => Unit.Default)); 15 | } 16 | 17 | [Test] 18 | public void Throw_ArgumentNullException_if_factory_is_null () { 19 | Assert.Throws(() => new FactoryPool(1,null,IdentityFunction.Action,IdentityFunction.Action)); 20 | } 21 | 22 | [Test] 23 | public void Rent_returned_new_instance_if_first_Rent () { 24 | int created = 0; 25 | var pool = new FactoryPool(2,() => { 26 | created++; 27 | return new Unit(); 28 | }); 29 | 30 | Unit createdInstance = pool.Rent(); 31 | Assert.AreEqual(1,created); 32 | 33 | pool.Return(createdInstance); 34 | pool.Rent(); 35 | Assert.AreNotEqual(2,created); 36 | } 37 | 38 | [Test] 39 | public void Rent_returned_pooled_instance () { 40 | var pool = new FactoryPool(1,() => new Unit()); 41 | Unit expected = pool.Rent(); 42 | pool.Return(expected); 43 | 44 | Assert.AreSame(expected,pool.Rent()); 45 | } 46 | 47 | [Test] 48 | public void Throw_NullReferenceException_if_factory_returned_null () { 49 | var pool = new FactoryPool(1,() => null); 50 | Assert.Throws(() => pool.Rent()); 51 | } 52 | 53 | [Test] 54 | public void onRent_is_called_if_Rent_suceeded () { 55 | bool called = false; 56 | var pool = new FactoryPool(1,() => new Unit(),onRent: x => called = true); 57 | pool.Rent(); 58 | Assert.IsTrue(called); 59 | } 60 | 61 | [Test] 62 | public void Not_return_instance_to_pool_if_capacity_is_exceeded () { 63 | int returned = 0; 64 | var pool = new FactoryPool(1,() => new Unit(),onReturn: x => returned++); 65 | 66 | pool.Return(new Unit()); 67 | Assert.AreEqual(1,returned); 68 | 69 | pool.Return(new Unit()); 70 | Assert.AreNotEqual(2,returned); 71 | } 72 | 73 | [Test] 74 | public void onRelease_is_called_if_capacity_is_exceeded () { 75 | bool called = false; 76 | var pool = new FactoryPool(1,() => new Unit(),onRelease: x => called = true); 77 | 78 | pool.Return(new Unit()); 79 | Assert.IsFalse(called); 80 | 81 | pool.Return(new Unit()); 82 | Assert.IsTrue(called); 83 | } 84 | 85 | [Test] 86 | public void onReturn_is_called_if_Return_suceeded () { 87 | bool called = false; 88 | var pool = new FactoryPool(1,() => new Unit(),onReturn: x => called = true); 89 | pool.Return(new Unit()); 90 | Assert.IsTrue(called); 91 | } 92 | 93 | [Test] 94 | public void ReleaseInstances_throw_ArgumentOutOfRangeException_if_keep_is_less_than_zero_or_greater_than_capacity () { 95 | var pool = new FactoryPool(1,() => new Unit()); 96 | Assert.Throws(() => pool.ReleaseInstances(-1)); 97 | Assert.Throws(() => pool.ReleaseInstances(2)); 98 | } 99 | 100 | [Test] 101 | public void ReleaseInstances_is_keep_specified_quantity_and_release_instances () { 102 | int released = 0; 103 | var pool = new FactoryPool(3,() => new Unit(),onRelease: x => released++); 104 | pool.Return(new Unit()); 105 | pool.Return(new Unit()); 106 | pool.Return(new Unit()); 107 | pool.ReleaseInstances(1); 108 | 109 | Assert.AreEqual(2,released); 110 | } 111 | 112 | [Test] 113 | public void ReleaseInstances_is_release_all_instances_if_keep_is_zero () { 114 | int released = 0; 115 | var pool = new FactoryPool(2,() => new Unit(),onRelease: x => released++); 116 | pool.Return(new Unit()); 117 | pool.Return(new Unit()); 118 | pool.ReleaseInstances(0); 119 | 120 | Assert.AreEqual(2,released); 121 | } 122 | 123 | [Test] 124 | public void onRelease_is_called_when_clear_pool () { 125 | int released = 0; 126 | var pool = new FactoryPool(2,() => new Unit(),onRelease: x => released++); 127 | pool.Return(new Unit()); 128 | pool.Return(new Unit()); 129 | Assert.Zero(released); 130 | 131 | pool.Clear(); 132 | Assert.AreEqual(2,released); 133 | } 134 | 135 | } 136 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/FactoryPoolTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98fc7d168149c934ebf6cd80de9fee3c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/MackySoft.XPool.Tests.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MackySoft.XPool.Tests.Editor", 3 | "rootNamespace": "MackySoft.XPool.Tests", 4 | "references": [ 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner", 7 | "MackySoft.XPool", 8 | "Unity.PerformanceTesting" 9 | ], 10 | "includePlatforms": [ 11 | "Editor" 12 | ], 13 | "excludePlatforms": [], 14 | "allowUnsafeCode": false, 15 | "overrideReferences": true, 16 | "precompiledReferences": [ 17 | "nunit.framework.dll" 18 | ], 19 | "autoReferenced": false, 20 | "defineConstraints": [ 21 | "UNITY_INCLUDE_TESTS" 22 | ], 23 | "versionDefines": [], 24 | "noEngineReferences": false 25 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/MackySoft.XPool.Tests.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e730c3cbc99d90841b4af1a4cd2762a0 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/PoolExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MackySoft.XPool.Tests { 4 | public static class PoolExtensions { 5 | public static void WarmUp (this IPool pool,int count) { 6 | if (pool == null) { 7 | throw new ArgumentNullException(nameof(pool)); 8 | } 9 | if (count < 0) { 10 | throw new ArgumentOutOfRangeException(nameof(count)); 11 | } 12 | 13 | T[] array = new T[count]; 14 | for (int i = 0;i < count;i++) { 15 | array[i] = pool.Rent(); 16 | } 17 | for (int i = 0;i < count;i++) { 18 | pool.Return(array[i]); 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/PoolExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 268bd7773fa00a442a80a127ed80b04b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Timers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e9efa9eb5b6cb2439670bb8951bd69d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Timers/PeriodicTimerTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace MackySoft.XPool.Timers.Tests { 4 | public class PeriodicTimerTest { 5 | 6 | [Test] 7 | public void Invoke_OnElapsed_when_interval_is_elapsed () { 8 | var timer = new PeriodicTimer(1f); 9 | 10 | bool called = false; 11 | timer.OnElapsed += () => called = true; 12 | 13 | timer.Tick(0.9f); 14 | Assert.IsFalse(called); 15 | 16 | timer.Tick(0.1f); 17 | Assert.IsTrue(called); 18 | } 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Timers/PeriodicTimerTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f59d2abcb4870b42b45e27d048eb588 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unit.cs: -------------------------------------------------------------------------------- 1 | namespace MackySoft.XPool.Tests { 2 | public class Unit { 3 | public static readonly Unit Default = new Unit(); 4 | } 5 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unit.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cf3982484fac8b4680927ffff8de36a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e0cb6760c5e1054c8ede18825e1946f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity/ObjectModel.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e11b4c6fed3bef843b5e1d421a52eac1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity/ObjectModel/UnityObjectPoolBaseTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using UnityEngine; 4 | using MackySoft.XPool.Tests; 5 | using UnityObject = UnityEngine.Object; 6 | using UnityAssert = UnityEngine.Assertions.Assert; 7 | using MackySoft.XPool.Unity.ObjectModel; 8 | 9 | namespace MackySoft.XPool.Unity.Tests { 10 | public class UnityObjectPoolBaseTest { 11 | 12 | GameObject m_Original; 13 | 14 | [OneTimeSetUp] 15 | public void OneTimeSetUp () { 16 | m_Original = GameObject.CreatePrimitive(PrimitiveType.Cube); 17 | } 18 | 19 | [OneTimeTearDown] 20 | public void OneTimeTearDown () { 21 | UnityObject.DestroyImmediate(m_Original); 22 | } 23 | 24 | [Test] 25 | public void Throw_ArgumentNullException_if_original_is_null () { 26 | Assert.Throws(() => new TestGameObjectPool(null,8)); 27 | } 28 | 29 | [Test] 30 | public void Throw_ArgumentOutOfRangeException_if_capacity_is_less_than_zero () { 31 | Assert.Throws(() => new TestGameObjectPool(m_Original,-1)); 32 | 33 | // Does not throw if capacity is 0. 34 | Assert.DoesNotThrow(() => new TestGameObjectPool(m_Original,0)); 35 | } 36 | 37 | [Test] 38 | public void Create_new_instance_if_cant_get_pooled_instance () { 39 | int count = 0; 40 | var pool = new TestGameObjectPool(m_Original,8,onCreate: _ => count++); 41 | 42 | var instance = pool.Rent(); 43 | Assert.AreEqual(1,count); 44 | 45 | // Return instance to the pool and destroy it. 46 | pool.Return(instance); 47 | UnityObject.DestroyImmediate(instance); 48 | UnityAssert.IsNull(instance); 49 | 50 | // Since the pooled instance has been destroyed, create a new instance. 51 | pool.Rent(); 52 | Assert.AreEqual(2,count); 53 | } 54 | 55 | [Test] 56 | public void Release_instance_if_capacity_is_exceeded () { 57 | bool called = false; 58 | var pool = new TestGameObjectPool(m_Original,1,onRelease: _ => called = true); 59 | 60 | var instance1 = pool.Rent(); 61 | var instance2 = pool.Rent(); 62 | 63 | pool.Return(instance1); 64 | Assert.False(called); 65 | 66 | pool.Return(instance2); 67 | Assert.True(called); 68 | } 69 | 70 | public void ReleaseInstances_throw_ArgumentOutOfRangeException_if_keep_is_less_than_zero_or_greater_than_capacity () { 71 | var pool = new TestGameObjectPool(m_Original,1); 72 | Assert.Throws(() => pool.ReleaseInstances(-1)); 73 | Assert.Throws(() => pool.ReleaseInstances(2)); 74 | } 75 | 76 | [Test] 77 | public void ReleaseInstances_is_keep_specified_quantity_and_release_instances () { 78 | int released = 0; 79 | var pool = new TestGameObjectPool(m_Original,3,onRelease: _ => released++); 80 | 81 | pool.WarmUp(3); 82 | pool.ReleaseInstances(1); 83 | 84 | Assert.AreEqual(2,released); 85 | } 86 | 87 | [Test] 88 | public void ReleaseInstances_is_release_all_instances_if_keep_is_zero () { 89 | int released = 0; 90 | var pool = new TestGameObjectPool(m_Original,2,onRelease: _ => released++); 91 | pool.WarmUp(2); 92 | pool.ReleaseInstances(0); 93 | 94 | Assert.AreEqual(2,released); 95 | } 96 | 97 | class TestGameObjectPool : UnityObjectPoolBase { 98 | 99 | protected Action m_OnCreate; 100 | protected Action m_OnRent; 101 | protected Action m_OnReturn; 102 | protected Action m_OnRelease; 103 | 104 | public TestGameObjectPool (GameObject original,int capacity,Action onCreate = null,Action onRent = null,Action onReturn = null,Action onRelease = null) : base(original,capacity) { 105 | m_OnCreate = onCreate; 106 | m_OnRent = onRent; 107 | m_OnReturn = onReturn; 108 | m_OnRelease = onRelease; 109 | } 110 | 111 | protected override void OnCreate (GameObject instance) { 112 | m_OnCreate?.Invoke(instance); 113 | } 114 | 115 | protected override void OnRent (GameObject instance) { 116 | m_OnRent?.Invoke(instance); 117 | } 118 | 119 | protected override void OnReturn (GameObject instance) { 120 | m_OnReturn?.Invoke(instance); 121 | } 122 | 123 | protected override void OnRelease (GameObject instance) { 124 | m_OnRelease(instance); 125 | } 126 | 127 | } 128 | 129 | } 130 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity/ObjectModel/UnityObjectPoolBaseTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 555c40d947113d841a6ac5af1031d31b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity/UnityObjectPoolTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using UnityEngine; 4 | using MackySoft.XPool.Tests; 5 | using UnityObject = UnityEngine.Object; 6 | using UnityAssert = UnityEngine.Assertions.Assert; 7 | 8 | namespace MackySoft.XPool.Unity.Tests { 9 | 10 | public class UnityObjectPoolTest { 11 | 12 | GameObject m_Original; 13 | 14 | [OneTimeSetUp] 15 | public void OneTimeSetUp () { 16 | m_Original = GameObject.CreatePrimitive(PrimitiveType.Cube); 17 | } 18 | 19 | [OneTimeTearDown] 20 | public void OneTimeTearDown () { 21 | UnityObject.DestroyImmediate(m_Original); 22 | } 23 | 24 | [Test] 25 | public void Throw_ArgumentNullException_if_original_is_null () { 26 | Assert.Throws(() => new UnityObjectPool(null,8)); 27 | } 28 | 29 | [Test] 30 | public void Throw_ArgumentOutOfRangeException_if_capacity_is_less_than_zero () { 31 | Assert.Throws(() => new UnityObjectPool(m_Original,-1)); 32 | 33 | // Does not throw if capacity is 0. 34 | Assert.DoesNotThrow(() => new UnityObjectPool(m_Original,0)); 35 | } 36 | 37 | [Test] 38 | public void Throw_InvaidOperationException_if_try_to_set_callback_when_there_is_instance_in_pool () { 39 | var pool = new UnityObjectPool(m_Original,8); 40 | pool.Return(pool.Rent()); 41 | 42 | Assert.Throws(() => pool.OnCreate = _ => { }); 43 | Assert.Throws(() => pool.OnRent = _ => { }); 44 | Assert.Throws(() => pool.OnReturn = _ => { }); 45 | Assert.Throws(() => pool.OnRelease = _ => { }); 46 | } 47 | 48 | [Test] 49 | public void Create_new_instance_if_cant_get_pooled_instance () { 50 | int count = 0; 51 | var pool = new UnityObjectPool(m_Original,8) { 52 | OnCreate = _ => count++ 53 | }; 54 | 55 | var instance = pool.Rent(); 56 | Assert.AreEqual(1,count); 57 | 58 | // Return instance to the pool and destroy it. 59 | pool.Return(instance); 60 | UnityObject.DestroyImmediate(instance); 61 | UnityAssert.IsNull(instance); 62 | 63 | // Since the pooled instance has been destroyed, create a new instance. 64 | pool.Rent(); 65 | Assert.AreEqual(2,count); 66 | } 67 | 68 | [Test] 69 | public void Release_instance_if_capacity_is_exceeded () { 70 | bool called = false; 71 | var pool = new UnityObjectPool(m_Original,1) { 72 | OnRelease = _ => called = true 73 | }; 74 | 75 | var instance1 = pool.Rent(); 76 | var instance2 = pool.Rent(); 77 | 78 | pool.Return(instance1); 79 | Assert.False(called); 80 | 81 | pool.Return(instance2); 82 | Assert.True(called); 83 | } 84 | 85 | public void ReleaseInstances_throw_ArgumentOutOfRangeException_if_keep_is_less_than_zero_or_greater_than_capacity () { 86 | var pool = new UnityObjectPool(m_Original,1); 87 | Assert.Throws(() => pool.ReleaseInstances(-1)); 88 | Assert.Throws(() => pool.ReleaseInstances(2)); 89 | } 90 | 91 | [Test] 92 | public void ReleaseInstances_is_keep_specified_quantity_and_release_instances () { 93 | int released = 0; 94 | var pool = new UnityObjectPool(m_Original,3) { 95 | OnRelease = _ => released++ 96 | }; 97 | pool.WarmUp(3); 98 | pool.ReleaseInstances(1); 99 | 100 | Assert.AreEqual(2,released); 101 | } 102 | 103 | [Test] 104 | public void ReleaseInstances_is_release_all_instances_if_keep_is_zero () { 105 | int released = 0; 106 | var pool = new UnityObjectPool(m_Original,2) { 107 | OnRelease = _ => released++ 108 | }; 109 | pool.WarmUp(2); 110 | pool.ReleaseInstances(0); 111 | 112 | Assert.AreEqual(2,released); 113 | } 114 | 115 | } 116 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/Tests/Editor/Unity/UnityObjectPoolTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 79254e88ae08a6f49a48c037931f741c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.mackysoft.xpool", 3 | "displayName": "XPool", 4 | "version": "0.1.1", 5 | "unity": "2020.1", 6 | "description": "Object pooling system for Unity.", 7 | "keywords": [ "XPool" ], 8 | "license": "MIT", 9 | "dependencies": {} 10 | } -------------------------------------------------------------------------------- /Assets/MackySoft/MackySoft.XPool/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 917f67862e77f584a9a5b50e90f1ba81 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/PackageTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f4375a28609484428ddea8e8f519972 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PackageTools/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcc1148481889924d91760737bcc6516 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/PackageTools/Editor/UnityPackageExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace MackySoft.PackageTools.Editor { 7 | 8 | public static class UnityPackageExporter { 9 | 10 | // The name of the unitypackage to output. 11 | const string k_PackageName = "XPool"; 12 | 13 | // The path to the package under the `Assets/` folder. 14 | const string k_PackagePath = "MackySoft"; 15 | 16 | // Path to export to. 17 | const string k_ExportPath = "Build"; 18 | 19 | const string k_SearchPattern = "*"; 20 | const string k_PackageToolsFolderName = "PackageTools"; 21 | const string k_ResourcesFolderName = "Resources"; 22 | 23 | [MenuItem("Tools/XPool/Export Package")] 24 | public static void Export () { 25 | ExportPackage($"{k_ExportPath}/{k_PackageName}.unitypackage"); 26 | } 27 | 28 | 29 | public static string ExportPackage (string exportPath) { 30 | // Ensure export path. 31 | var dir = new FileInfo(exportPath).Directory; 32 | if (dir != null && !dir.Exists) { 33 | dir.Create(); 34 | } 35 | 36 | // Export 37 | AssetDatabase.ExportPackage( 38 | GetAssetPaths(), 39 | exportPath, 40 | ExportPackageOptions.Default 41 | ); 42 | 43 | return Path.GetFullPath(exportPath); 44 | } 45 | 46 | public static string[] GetAssetPaths () { 47 | var path = Path.Combine(Application.dataPath,k_PackagePath); 48 | var assets = Directory.EnumerateFiles(path,k_SearchPattern,SearchOption.AllDirectories) 49 | .Where(x => !x.Contains(k_PackageToolsFolderName) && !x.Contains(k_ResourcesFolderName)) 50 | .Select(x => "Assets" + x.Replace(Application.dataPath,"").Replace(@"\","/")) 51 | .ToArray(); 52 | return assets; 53 | } 54 | 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/PackageTools/Editor/UnityPackageExporter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18e0101a13bd4d541a4622e86ec18b4e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Documentation/changelog/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [0.1.1] - 2022-03-04 9 | 10 | ### Added 11 | - Added `IPool.ReleaseInstancesPeriodically()` extension method. 12 | - Added `IPool.BindTo()` extension method. 13 | - Added Timer APIs 14 | 15 | ### Changed 16 | - Extracted `IPool` from `IPool`. 17 | - `IPool.Clear()` make to non-generic. 18 | 19 | ## [0.1.0] - 2022-03-01 20 | First release 21 | -------------------------------------------------------------------------------- /Documentation/changelog/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Changelog 2 | href: CHANGELOG.md -------------------------------------------------------------------------------- /Documentation/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "src": "..", 7 | "files": [ 8 | "Assets/**/*.cs" 9 | ], 10 | "exclude": [ 11 | "Assets/Plugins/**" 12 | ] 13 | } 14 | ], 15 | "globalNamespaceId": "Global", 16 | "filter": "filterConfig.yml", 17 | "dest": "api" 18 | } 19 | ], 20 | "build": { 21 | "globalMetadata": { 22 | "_appTitle": "XPool", 23 | "_appFooter": "XPool - Object Pooling System", 24 | "_enableSearch": true, 25 | "_enableNewTab": true, 26 | "_disableContribution": true 27 | }, 28 | "content": [ 29 | { 30 | "files": [ 31 | "toc.yml", 32 | "index.md" 33 | ] 34 | }, 35 | { 36 | "src": "api", 37 | "files": [ 38 | "*.yml" 39 | ], 40 | "dest": "api" 41 | }, 42 | { 43 | "src": "changelog", 44 | "files": [ 45 | "toc.yml", 46 | "*.md" 47 | ], 48 | "dest": "changelog" 49 | } 50 | ], 51 | "overwrite": [ 52 | { 53 | "src": "..", 54 | "files": [ 55 | "Assets/Scripts/**/*.md" 56 | ] 57 | } 58 | ], 59 | "resource": [ 60 | { 61 | "files": [ 62 | "resources/**/*" 63 | ] 64 | } 65 | ], 66 | "sitemap": { 67 | "baseUrl": "https://mackysoft.github.io/XPool", 68 | "changefreq": "weekly", 69 | "fileOptions": { 70 | "api/*": { 71 | "changefreq": "daily" 72 | } 73 | } 74 | }, 75 | "xref": [ 76 | "https://normanderwan.github.io/UnityXrefMaps/xrefmap.yml" 77 | ], 78 | "xrefService": [ 79 | "https://xref.docs.microsoft.com/query?uid={uid}" 80 | ], 81 | "dest": "../_site" 82 | } 83 | } -------------------------------------------------------------------------------- /Documentation/filterConfig.yml: -------------------------------------------------------------------------------- 1 | apiRules: 2 | - include: 3 | uidRegex: ^MackySoft\.XPool 4 | type: Namespace 5 | - include: 6 | uidRegex: ^Global 7 | type: Namespace 8 | - exclude: 9 | uidRegex: .* 10 | type: Namespace -------------------------------------------------------------------------------- /Documentation/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Scripting API 2 | href: api/ 3 | - name: Changelog 4 | href: changelog/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Hiroya Aramaki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "2.0.5", 4 | "com.unity.ide.rider": "3.0.24", 5 | "com.unity.ide.visualstudio": "2.0.18", 6 | "com.unity.ide.vscode": "1.2.5", 7 | "com.unity.test-framework": "1.1.33", 8 | "com.unity.test-framework.performance": "2.8.0-preview", 9 | "com.unity.testtools.codecoverage": "1.2.4", 10 | "com.unity.textmeshpro": "3.0.6", 11 | "com.unity.timeline": "1.6.5", 12 | "com.unity.ugui": "1.0.0", 13 | "com.unity.modules.ai": "1.0.0", 14 | "com.unity.modules.androidjni": "1.0.0", 15 | "com.unity.modules.animation": "1.0.0", 16 | "com.unity.modules.assetbundle": "1.0.0", 17 | "com.unity.modules.audio": "1.0.0", 18 | "com.unity.modules.cloth": "1.0.0", 19 | "com.unity.modules.director": "1.0.0", 20 | "com.unity.modules.imageconversion": "1.0.0", 21 | "com.unity.modules.imgui": "1.0.0", 22 | "com.unity.modules.jsonserialize": "1.0.0", 23 | "com.unity.modules.particlesystem": "1.0.0", 24 | "com.unity.modules.physics": "1.0.0", 25 | "com.unity.modules.physics2d": "1.0.0", 26 | "com.unity.modules.screencapture": "1.0.0", 27 | "com.unity.modules.terrain": "1.0.0", 28 | "com.unity.modules.terrainphysics": "1.0.0", 29 | "com.unity.modules.tilemap": "1.0.0", 30 | "com.unity.modules.ui": "1.0.0", 31 | "com.unity.modules.uielements": "1.0.0", 32 | "com.unity.modules.umbra": "1.0.0", 33 | "com.unity.modules.unityanalytics": "1.0.0", 34 | "com.unity.modules.unitywebrequest": "1.0.0", 35 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 36 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 37 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 38 | "com.unity.modules.unitywebrequestwww": "1.0.0", 39 | "com.unity.modules.vehicles": "1.0.0", 40 | "com.unity.modules.video": "1.0.0", 41 | "com.unity.modules.vr": "1.0.0", 42 | "com.unity.modules.wind": "1.0.0", 43 | "com.unity.modules.xr": "1.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": { 4 | "version": "2.0.5", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": {}, 8 | "url": "https://packages.unity.com" 9 | }, 10 | "com.unity.ext.nunit": { 11 | "version": "1.0.6", 12 | "depth": 1, 13 | "source": "registry", 14 | "dependencies": {}, 15 | "url": "https://packages.unity.com" 16 | }, 17 | "com.unity.ide.rider": { 18 | "version": "3.0.24", 19 | "depth": 0, 20 | "source": "registry", 21 | "dependencies": { 22 | "com.unity.ext.nunit": "1.0.6" 23 | }, 24 | "url": "https://packages.unity.com" 25 | }, 26 | "com.unity.ide.visualstudio": { 27 | "version": "2.0.18", 28 | "depth": 0, 29 | "source": "registry", 30 | "dependencies": { 31 | "com.unity.test-framework": "1.1.9" 32 | }, 33 | "url": "https://packages.unity.com" 34 | }, 35 | "com.unity.ide.vscode": { 36 | "version": "1.2.5", 37 | "depth": 0, 38 | "source": "registry", 39 | "dependencies": {}, 40 | "url": "https://packages.unity.com" 41 | }, 42 | "com.unity.settings-manager": { 43 | "version": "1.0.3", 44 | "depth": 1, 45 | "source": "registry", 46 | "dependencies": {}, 47 | "url": "https://packages.unity.com" 48 | }, 49 | "com.unity.test-framework": { 50 | "version": "1.1.33", 51 | "depth": 0, 52 | "source": "registry", 53 | "dependencies": { 54 | "com.unity.ext.nunit": "1.0.6", 55 | "com.unity.modules.imgui": "1.0.0", 56 | "com.unity.modules.jsonserialize": "1.0.0" 57 | }, 58 | "url": "https://packages.unity.com" 59 | }, 60 | "com.unity.test-framework.performance": { 61 | "version": "2.8.0-preview", 62 | "depth": 0, 63 | "source": "registry", 64 | "dependencies": { 65 | "com.unity.test-framework": "1.1.0", 66 | "com.unity.modules.jsonserialize": "1.0.0" 67 | }, 68 | "url": "https://packages.unity.com" 69 | }, 70 | "com.unity.testtools.codecoverage": { 71 | "version": "1.2.4", 72 | "depth": 0, 73 | "source": "registry", 74 | "dependencies": { 75 | "com.unity.test-framework": "1.0.16", 76 | "com.unity.settings-manager": "1.0.1" 77 | }, 78 | "url": "https://packages.unity.com" 79 | }, 80 | "com.unity.textmeshpro": { 81 | "version": "3.0.6", 82 | "depth": 0, 83 | "source": "registry", 84 | "dependencies": { 85 | "com.unity.ugui": "1.0.0" 86 | }, 87 | "url": "https://packages.unity.com" 88 | }, 89 | "com.unity.timeline": { 90 | "version": "1.6.5", 91 | "depth": 0, 92 | "source": "registry", 93 | "dependencies": { 94 | "com.unity.modules.director": "1.0.0", 95 | "com.unity.modules.animation": "1.0.0", 96 | "com.unity.modules.audio": "1.0.0", 97 | "com.unity.modules.particlesystem": "1.0.0" 98 | }, 99 | "url": "https://packages.unity.com" 100 | }, 101 | "com.unity.ugui": { 102 | "version": "1.0.0", 103 | "depth": 0, 104 | "source": "builtin", 105 | "dependencies": { 106 | "com.unity.modules.ui": "1.0.0", 107 | "com.unity.modules.imgui": "1.0.0" 108 | } 109 | }, 110 | "com.unity.modules.ai": { 111 | "version": "1.0.0", 112 | "depth": 0, 113 | "source": "builtin", 114 | "dependencies": {} 115 | }, 116 | "com.unity.modules.androidjni": { 117 | "version": "1.0.0", 118 | "depth": 0, 119 | "source": "builtin", 120 | "dependencies": {} 121 | }, 122 | "com.unity.modules.animation": { 123 | "version": "1.0.0", 124 | "depth": 0, 125 | "source": "builtin", 126 | "dependencies": {} 127 | }, 128 | "com.unity.modules.assetbundle": { 129 | "version": "1.0.0", 130 | "depth": 0, 131 | "source": "builtin", 132 | "dependencies": {} 133 | }, 134 | "com.unity.modules.audio": { 135 | "version": "1.0.0", 136 | "depth": 0, 137 | "source": "builtin", 138 | "dependencies": {} 139 | }, 140 | "com.unity.modules.cloth": { 141 | "version": "1.0.0", 142 | "depth": 0, 143 | "source": "builtin", 144 | "dependencies": { 145 | "com.unity.modules.physics": "1.0.0" 146 | } 147 | }, 148 | "com.unity.modules.director": { 149 | "version": "1.0.0", 150 | "depth": 0, 151 | "source": "builtin", 152 | "dependencies": { 153 | "com.unity.modules.audio": "1.0.0", 154 | "com.unity.modules.animation": "1.0.0" 155 | } 156 | }, 157 | "com.unity.modules.imageconversion": { 158 | "version": "1.0.0", 159 | "depth": 0, 160 | "source": "builtin", 161 | "dependencies": {} 162 | }, 163 | "com.unity.modules.imgui": { 164 | "version": "1.0.0", 165 | "depth": 0, 166 | "source": "builtin", 167 | "dependencies": {} 168 | }, 169 | "com.unity.modules.jsonserialize": { 170 | "version": "1.0.0", 171 | "depth": 0, 172 | "source": "builtin", 173 | "dependencies": {} 174 | }, 175 | "com.unity.modules.particlesystem": { 176 | "version": "1.0.0", 177 | "depth": 0, 178 | "source": "builtin", 179 | "dependencies": {} 180 | }, 181 | "com.unity.modules.physics": { 182 | "version": "1.0.0", 183 | "depth": 0, 184 | "source": "builtin", 185 | "dependencies": {} 186 | }, 187 | "com.unity.modules.physics2d": { 188 | "version": "1.0.0", 189 | "depth": 0, 190 | "source": "builtin", 191 | "dependencies": {} 192 | }, 193 | "com.unity.modules.screencapture": { 194 | "version": "1.0.0", 195 | "depth": 0, 196 | "source": "builtin", 197 | "dependencies": { 198 | "com.unity.modules.imageconversion": "1.0.0" 199 | } 200 | }, 201 | "com.unity.modules.subsystems": { 202 | "version": "1.0.0", 203 | "depth": 1, 204 | "source": "builtin", 205 | "dependencies": { 206 | "com.unity.modules.jsonserialize": "1.0.0" 207 | } 208 | }, 209 | "com.unity.modules.terrain": { 210 | "version": "1.0.0", 211 | "depth": 0, 212 | "source": "builtin", 213 | "dependencies": {} 214 | }, 215 | "com.unity.modules.terrainphysics": { 216 | "version": "1.0.0", 217 | "depth": 0, 218 | "source": "builtin", 219 | "dependencies": { 220 | "com.unity.modules.physics": "1.0.0", 221 | "com.unity.modules.terrain": "1.0.0" 222 | } 223 | }, 224 | "com.unity.modules.tilemap": { 225 | "version": "1.0.0", 226 | "depth": 0, 227 | "source": "builtin", 228 | "dependencies": { 229 | "com.unity.modules.physics2d": "1.0.0" 230 | } 231 | }, 232 | "com.unity.modules.ui": { 233 | "version": "1.0.0", 234 | "depth": 0, 235 | "source": "builtin", 236 | "dependencies": {} 237 | }, 238 | "com.unity.modules.uielements": { 239 | "version": "1.0.0", 240 | "depth": 0, 241 | "source": "builtin", 242 | "dependencies": { 243 | "com.unity.modules.ui": "1.0.0", 244 | "com.unity.modules.imgui": "1.0.0", 245 | "com.unity.modules.jsonserialize": "1.0.0", 246 | "com.unity.modules.uielementsnative": "1.0.0" 247 | } 248 | }, 249 | "com.unity.modules.uielementsnative": { 250 | "version": "1.0.0", 251 | "depth": 1, 252 | "source": "builtin", 253 | "dependencies": { 254 | "com.unity.modules.ui": "1.0.0", 255 | "com.unity.modules.imgui": "1.0.0", 256 | "com.unity.modules.jsonserialize": "1.0.0" 257 | } 258 | }, 259 | "com.unity.modules.umbra": { 260 | "version": "1.0.0", 261 | "depth": 0, 262 | "source": "builtin", 263 | "dependencies": {} 264 | }, 265 | "com.unity.modules.unityanalytics": { 266 | "version": "1.0.0", 267 | "depth": 0, 268 | "source": "builtin", 269 | "dependencies": { 270 | "com.unity.modules.unitywebrequest": "1.0.0", 271 | "com.unity.modules.jsonserialize": "1.0.0" 272 | } 273 | }, 274 | "com.unity.modules.unitywebrequest": { 275 | "version": "1.0.0", 276 | "depth": 0, 277 | "source": "builtin", 278 | "dependencies": {} 279 | }, 280 | "com.unity.modules.unitywebrequestassetbundle": { 281 | "version": "1.0.0", 282 | "depth": 0, 283 | "source": "builtin", 284 | "dependencies": { 285 | "com.unity.modules.assetbundle": "1.0.0", 286 | "com.unity.modules.unitywebrequest": "1.0.0" 287 | } 288 | }, 289 | "com.unity.modules.unitywebrequestaudio": { 290 | "version": "1.0.0", 291 | "depth": 0, 292 | "source": "builtin", 293 | "dependencies": { 294 | "com.unity.modules.unitywebrequest": "1.0.0", 295 | "com.unity.modules.audio": "1.0.0" 296 | } 297 | }, 298 | "com.unity.modules.unitywebrequesttexture": { 299 | "version": "1.0.0", 300 | "depth": 0, 301 | "source": "builtin", 302 | "dependencies": { 303 | "com.unity.modules.unitywebrequest": "1.0.0", 304 | "com.unity.modules.imageconversion": "1.0.0" 305 | } 306 | }, 307 | "com.unity.modules.unitywebrequestwww": { 308 | "version": "1.0.0", 309 | "depth": 0, 310 | "source": "builtin", 311 | "dependencies": { 312 | "com.unity.modules.unitywebrequest": "1.0.0", 313 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 314 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 315 | "com.unity.modules.audio": "1.0.0", 316 | "com.unity.modules.assetbundle": "1.0.0", 317 | "com.unity.modules.imageconversion": "1.0.0" 318 | } 319 | }, 320 | "com.unity.modules.vehicles": { 321 | "version": "1.0.0", 322 | "depth": 0, 323 | "source": "builtin", 324 | "dependencies": { 325 | "com.unity.modules.physics": "1.0.0" 326 | } 327 | }, 328 | "com.unity.modules.video": { 329 | "version": "1.0.0", 330 | "depth": 0, 331 | "source": "builtin", 332 | "dependencies": { 333 | "com.unity.modules.audio": "1.0.0", 334 | "com.unity.modules.ui": "1.0.0", 335 | "com.unity.modules.unitywebrequest": "1.0.0" 336 | } 337 | }, 338 | "com.unity.modules.vr": { 339 | "version": "1.0.0", 340 | "depth": 0, 341 | "source": "builtin", 342 | "dependencies": { 343 | "com.unity.modules.jsonserialize": "1.0.0", 344 | "com.unity.modules.physics": "1.0.0", 345 | "com.unity.modules.xr": "1.0.0" 346 | } 347 | }, 348 | "com.unity.modules.wind": { 349 | "version": "1.0.0", 350 | "depth": 0, 351 | "source": "builtin", 352 | "dependencies": {} 353 | }, 354 | "com.unity.modules.xr": { 355 | "version": "1.0.0", 356 | "depth": 0, 357 | "source": "builtin", 358 | "dependencies": { 359 | "com.unity.modules.physics": "1.0.0", 360 | "com.unity.modules.jsonserialize": "1.0.0", 361 | "com.unity.modules.subsystems": "1.0.0" 362 | } 363 | } 364 | } 365 | } 366 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_SerializeInlineMappingsOnOneLine: 1 -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "m_Name": "Settings", 3 | "m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json", 4 | "m_Dictionary": { 5 | "m_DictionaryValues": [ 6 | { 7 | "type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 8 | "key": "IncludeAssemblies", 9 | "value": "{\"m_Value\":\"MackySoft.XPool\"}" 10 | }, 11 | { 12 | "type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 13 | "key": "Path", 14 | "value": "{\"m_Value\":\"{ProjectPath}\"}" 15 | }, 16 | { 17 | "type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 18 | "key": "HistoryPath", 19 | "value": "{\"m_Value\":\"{ProjectPath}\"}" 20 | }, 21 | { 22 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 23 | "key": "EnableCodeCoverage", 24 | "value": "{\"m_Value\":false}" 25 | } 26 | ] 27 | } 28 | } -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2021.3.29f1 2 | m_EditorVersionWithRevision: 2021.3.29f1 (204d6dc9ae1c) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /ProjectSettings/boot.config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mackysoft/XPool/2e2bcc2fb721d2a9ce427273cc7e9ff6cb52bb30/ProjectSettings/boot.config -------------------------------------------------------------------------------- /XPool.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MackySoft.XPool", "MackySoft.XPool.csproj", "{74B3B2CE-DA6D-389E-C003-31F1BF1A8A2F}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MackySoft.XPool.Tests.Editor", "MackySoft.XPool.Tests.Editor.csproj", "{D4684E2D-47E8-5FBE-043E-247A51A7388F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MackySoft.XPool.Editor", "MackySoft.XPool.Editor.csproj", "{D26CF929-283A-B6C9-F1A4-CF7FC18C5A32}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{1554AA8B-EAFD-6297-EA79-851161F4D6A0}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {74B3B2CE-DA6D-389E-C003-31F1BF1A8A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {74B3B2CE-DA6D-389E-C003-31F1BF1A8A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {74B3B2CE-DA6D-389E-C003-31F1BF1A8A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {74B3B2CE-DA6D-389E-C003-31F1BF1A8A2F}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D4684E2D-47E8-5FBE-043E-247A51A7388F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D4684E2D-47E8-5FBE-043E-247A51A7388F}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D4684E2D-47E8-5FBE-043E-247A51A7388F}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D4684E2D-47E8-5FBE-043E-247A51A7388F}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {D26CF929-283A-B6C9-F1A4-CF7FC18C5A32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {D26CF929-283A-B6C9-F1A4-CF7FC18C5A32}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {D26CF929-283A-B6C9-F1A4-CF7FC18C5A32}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {D26CF929-283A-B6C9-F1A4-CF7FC18C5A32}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {1554AA8B-EAFD-6297-EA79-851161F4D6A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {1554AA8B-EAFD-6297-EA79-851161F4D6A0}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {1554AA8B-EAFD-6297-EA79-851161F4D6A0}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {1554AA8B-EAFD-6297-EA79-851161F4D6A0}.Release|Any CPU.Build.0 = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | --------------------------------------------------------------------------------