├── .editorconfig ├── .github ├── dependabot.yaml └── workflows │ ├── build-debug.yaml │ ├── build-release.yaml │ ├── prevent-github-change.yaml │ └── stale.yaml ├── .gitignore ├── LICENSE ├── NativeMemoryArray.sln ├── README.md ├── opensource.snk ├── sandbox └── ConsoleApp │ ├── ConsoleApp.csproj │ └── Program.cs ├── src ├── NativeMemoryArray.Unity │ ├── .vsconfig │ ├── Assets │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── PackageExporter.cs │ │ │ └── PackageExporter.cs.meta │ │ ├── Plugins.meta │ │ ├── Plugins │ │ │ ├── NativeMemoryArray.meta │ │ │ ├── NativeMemoryArray │ │ │ │ ├── Runtime.meta │ │ │ │ ├── Runtime │ │ │ │ │ ├── NativeMemoryArray.asmdef │ │ │ │ │ ├── NativeMemoryArray.asmdef.meta │ │ │ │ │ ├── NativeMemoryArray.cs │ │ │ │ │ ├── NativeMemoryArray.cs.meta │ │ │ │ │ ├── NativeMemoryArrayExtensions.cs │ │ │ │ │ ├── NativeMemoryArrayExtensions.cs.meta │ │ │ │ │ ├── PointerMemoryManager.cs │ │ │ │ │ ├── PointerMemoryManager.cs.meta │ │ │ │ │ ├── ThrowHelper.cs │ │ │ │ │ └── ThrowHelper.cs.meta │ │ │ │ ├── package.json │ │ │ │ └── package.json.meta │ │ │ ├── System.Buffers.dll │ │ │ ├── System.Buffers.dll.meta │ │ │ ├── System.Memory.dll │ │ │ ├── System.Memory.dll.meta │ │ │ ├── System.Runtime.CompilerServices.Unsafe.dll │ │ │ └── System.Runtime.CompilerServices.Unsafe.dll.meta │ │ ├── Scenes.meta │ │ └── Scenes │ │ │ ├── Sample.cs │ │ │ ├── Sample.cs.meta │ │ │ ├── SampleScene.unity │ │ │ └── SampleScene.unity.meta │ ├── NativeMemoryArray.Unity.sln │ ├── Packages │ │ ├── manifest.json │ │ └── packages-lock.json │ ├── ProjectSettings │ │ ├── AudioManager.asset │ │ ├── ClusterInputManager.asset │ │ ├── DynamicsManager.asset │ │ ├── EditorBuildSettings.asset │ │ ├── EditorSettings.asset │ │ ├── GraphicsSettings.asset │ │ ├── InputManager.asset │ │ ├── NavMeshAreas.asset │ │ ├── PackageManagerSettings.asset │ │ ├── Physics2DSettings.asset │ │ ├── PresetManager.asset │ │ ├── ProjectSettings.asset │ │ ├── ProjectVersion.txt │ │ ├── QualitySettings.asset │ │ ├── TagManager.asset │ │ ├── TimeManager.asset │ │ ├── UnityConnectSettings.asset │ │ ├── VFXManager.asset │ │ ├── VersionControlSettings.asset │ │ └── XRSettings.asset │ └── UserSettings │ │ └── EditorUserSettings.asset └── NativeMemoryArray │ ├── Icon.png │ ├── NativeMemoryArray.cs │ ├── NativeMemoryArray.csproj │ ├── NativeMemoryArrayExtensions.cs │ ├── PointerMemoryManager.cs │ └── ThrowHelper.cs └── tests └── NativeMemoryArray.Tests ├── NativeArrayTest.cs ├── NativeBufferTest.cs ├── NativeMemoryArray.Tests.csproj ├── _GlobalUsings.cs └── _Index.cs /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_style = space 8 | indent_size = 2 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | # Visual Studio Spell checker configs (https://learn.microsoft.com/en-us/visualstudio/ide/text-spell-checker?view=vs-2022#how-to-customize-the-spell-checker) 13 | spelling_exclusion_path = ./exclusion.dic 14 | 15 | [*.cs] 16 | indent_size = 4 17 | charset = utf-8-bom 18 | end_of_line = unset 19 | 20 | # Solution files 21 | [*.{sln,slnx}] 22 | end_of_line = unset 23 | 24 | # MSBuild project files 25 | [*.{csproj,props,targets}] 26 | end_of_line = unset 27 | 28 | # Xml config files 29 | [*.{ruleset,config,nuspec,resx,runsettings,DotSettings}] 30 | end_of_line = unset 31 | 32 | [*{_AssemblyInfo.cs,.notsupported.cs}] 33 | generated_code = true 34 | 35 | # C# code style settings 36 | [*.{cs}] 37 | dotnet_diagnostic.IDE0044.severity = none # IDE0044: Make field readonly 38 | 39 | # https://stackoverflow.com/questions/79195382/how-to-disable-fading-unused-methods-in-visual-studio-2022-17-12-0 40 | dotnet_diagnostic.IDE0051.severity = none # IDE0051: Remove unused private member 41 | dotnet_diagnostic.IDE0130.severity = none # IDE0130: Namespace does not match folder structure 42 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | # ref: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" # Check for updates to GitHub Actions every week 8 | ignore: 9 | # I just want update action when major/minor version is updated. patch updates are too noisy. 10 | - dependency-name: '*' 11 | update-types: 12 | - version-update:semver-patch 13 | -------------------------------------------------------------------------------- /.github/workflows/build-debug.yaml: -------------------------------------------------------------------------------- 1 | name: Build-Debug 2 | 3 | on: 4 | push: 5 | branches: 6 | - "master" 7 | pull_request: 8 | branches: 9 | - "master" 10 | 11 | jobs: 12 | build-dotnet: 13 | permissions: 14 | contents: read 15 | runs-on: ubuntu-24.04 16 | timeout-minutes: 10 17 | steps: 18 | - uses: Cysharp/Actions/.github/actions/checkout@main 19 | - uses: Cysharp/Actions/.github/actions/setup-dotnet@main 20 | - run: dotnet build -c Debug 21 | - run: dotnet test -c Debug --no-build 22 | 23 | build-unity: 24 | if: ${{ (github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:') }} 25 | strategy: 26 | matrix: 27 | unity: ["2020.2.1f1"] 28 | permissions: 29 | contents: read 30 | runs-on: ubuntu-24.04 31 | timeout-minutes: 15 32 | steps: 33 | - name: Load secrets 34 | id: op-load-secret 35 | uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0 # v2.0.0 36 | with: 37 | export-env: false 38 | env: 39 | OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} 40 | UNITY_EMAIL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/username" 41 | UNITY_PASSWORD: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/credential" 42 | UNITY_SERIAL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/serial" 43 | 44 | - uses: Cysharp/Actions/.github/actions/checkout@main 45 | # Execute scripts: Export Package 46 | # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export 47 | - name: Build Unity (.unitypacakge) 48 | uses: Cysharp/Actions/.github/actions/unity-builder@main 49 | env: 50 | UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }} 51 | UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }} 52 | UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }} 53 | with: 54 | projectPath: src/NativeMemoryArray.Unity 55 | unityVersion: ${{ matrix.unity }} 56 | targetPlatform: StandaloneLinux64 57 | buildMethod: PackageExporter.Export 58 | 59 | - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files 60 | with: 61 | directory: src/NativeMemoryArray.Unity 62 | 63 | # Store artifacts. 64 | - uses: Cysharp/Actions/.github/actions/upload-artifact@main 65 | with: 66 | name: NativeMemoryArray.Unity.unitypackage.zip 67 | path: ./src/NativeMemoryArray.Unity/*.unitypackage 68 | retention-days: 1 69 | -------------------------------------------------------------------------------- /.github/workflows/build-release.yaml: -------------------------------------------------------------------------------- 1 | name: Build-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 | dry-run: 10 | description: "dry-run: true will never create relase/nuget." 11 | required: true 12 | default: false 13 | type: boolean 14 | 15 | jobs: 16 | update-packagejson: 17 | permissions: 18 | actions: read 19 | contents: write 20 | uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main 21 | with: 22 | file-path: ./src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/package.json 23 | tag: ${{ inputs.tag }} 24 | dry-run: ${{ inputs.dry-run }} 25 | push-tag: false 26 | 27 | build-dotnet: 28 | needs: [update-packagejson] 29 | permissions: 30 | contents: read 31 | runs-on: ubuntu-24.04 32 | timeout-minutes: 10 33 | steps: 34 | - run: echo ${{ needs.update-packagejson.outputs.sha }} 35 | - uses: Cysharp/Actions/.github/actions/checkout@main 36 | with: 37 | ref: ${{ needs.update-packagejson.outputs.sha }} 38 | - uses: Cysharp/Actions/.github/actions/setup-dotnet@main 39 | - run: dotnet build -c Release -p:Version=${{ inputs.tag }} 40 | - run: dotnet test -c Release --no-build 41 | - run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish 42 | # Store artifacts. 43 | - uses: Cysharp/Actions/.github/actions/upload-artifact@main 44 | with: 45 | name: nuget 46 | path: ./publish/ 47 | retention-days: 1 48 | 49 | build-unity: 50 | needs: [update-packagejson] 51 | strategy: 52 | matrix: 53 | unity: ["2020.2.1f1"] 54 | permissions: 55 | contents: read 56 | runs-on: ubuntu-24.04 57 | timeout-minutes: 15 58 | steps: 59 | - name: Load secrets 60 | id: op-load-secret 61 | uses: 1password/load-secrets-action@581a835fb51b8e7ec56b71cf2ffddd7e68bb25e0 # v2.0.0 62 | with: 63 | export-env: false 64 | env: 65 | OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} 66 | UNITY_EMAIL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/username" 67 | UNITY_PASSWORD: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/credential" 68 | UNITY_SERIAL: "op://${{ vars.OP_VAULT_ACTIONS_PUBLIC }}/UNITY_LICENSE/serial" 69 | 70 | - uses: Cysharp/Actions/.github/actions/checkout@main 71 | with: 72 | ref: ${{ needs.update-packagejson.outputs.sha }} 73 | # Execute scripts: Export Package 74 | # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export 75 | - name: Build Unity (.unitypacakge) 76 | uses: Cysharp/Actions/.github/actions/unity-builder@main 77 | env: 78 | UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }} 79 | UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }} 80 | UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }} 81 | UNITY_PACKAGE_VERSION: ${{ inputs.tag }} 82 | with: 83 | projectPath: src/NativeMemoryArray.Unity 84 | unityVersion: ${{ matrix.unity }} 85 | targetPlatform: StandaloneLinux64 86 | buildMethod: PackageExporter.Export 87 | 88 | - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files 89 | with: 90 | directory: src/NativeMemoryArray.Unity 91 | 92 | # Store artifacts. 93 | - uses: Cysharp/Actions/.github/actions/upload-artifact@main 94 | with: 95 | name: NativeMemoryArray.Unity.${{ inputs.tag }}.unitypackage 96 | path: ./src/NativeMemoryArray.Unity/NativeMemoryArray.Unity.${{ inputs.tag }}.unitypackage 97 | retention-days: 1 98 | 99 | # release 100 | create-release: 101 | needs: [update-packagejson, build-dotnet, build-unity] 102 | permissions: 103 | contents: write 104 | uses: Cysharp/Actions/.github/workflows/create-release.yaml@main 105 | with: 106 | commit-id: ${{ needs.update-packagejson.outputs.sha }} 107 | dry-run: ${{ inputs.dry-run }} 108 | tag: ${{ inputs.tag }} 109 | nuget-push: true 110 | release-upload: true 111 | release-asset-path: ./NativeMemoryArray.Unity.${{ inputs.tag }}.unitypackage/NativeMemoryArray.Unity.${{ inputs.tag }}.unitypackage 112 | secrets: inherit 113 | 114 | cleanup: 115 | if: ${{ needs.update-packagejson.outputs.is-branch-created == 'true' }} 116 | needs: [update-packagejson, build-unity] 117 | permissions: 118 | contents: write 119 | uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main 120 | with: 121 | branch: ${{ needs.update-packagejson.outputs.branch-name }} 122 | -------------------------------------------------------------------------------- /.github/workflows/prevent-github-change.yaml: -------------------------------------------------------------------------------- 1 | name: Prevent github change 2 | on: 3 | pull_request: 4 | paths: 5 | - ".github/**/*.yaml" 6 | - ".github/**/*.yml" 7 | 8 | jobs: 9 | detect: 10 | permissions: 11 | contents: read 12 | uses: Cysharp/Actions/.github/workflows/prevent-github-change.yaml@main 13 | -------------------------------------------------------------------------------- /.github/workflows/stale.yaml: -------------------------------------------------------------------------------- 1 | name: "Close stale issues" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 0 * * *" 7 | 8 | jobs: 9 | stale: 10 | permissions: 11 | contents: read 12 | pull-requests: write 13 | issues: write 14 | uses: Cysharp/Actions/.github/workflows/stale-issue.yaml@main 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | *_i.c 20 | *_p.c 21 | *.ilk 22 | *.obj 23 | *.pch 24 | *.pdb 25 | *.pgc 26 | *.pgd 27 | *.rsp 28 | *.sbr 29 | *.tlb 30 | *.tli 31 | *.tlh 32 | *.tmp 33 | *.log 34 | *.vspscc 35 | *.vssscc 36 | .builds 37 | 38 | # Visual C++ cache files 39 | ipch/ 40 | *.aps 41 | *.ncb 42 | *.opensdf 43 | *.sdf 44 | 45 | # Visual Studio profiler 46 | *.psess 47 | *.vsp 48 | *.vspx 49 | 50 | # Guidance Automation Toolkit 51 | *.gpState 52 | 53 | # ReSharper is a .NET coding add-in 54 | _ReSharper* 55 | 56 | # NCrunch 57 | *.ncrunch* 58 | .*crunch*.local.xml 59 | 60 | # Installshield output folder 61 | [Ee]xpress 62 | 63 | # DocProject is a documentation generator add-in 64 | DocProject/buildhelp/ 65 | DocProject/Help/*.HxT 66 | DocProject/Help/*.HxC 67 | DocProject/Help/*.hhc 68 | DocProject/Help/*.hhk 69 | DocProject/Help/*.hhp 70 | DocProject/Help/Html2 71 | DocProject/Help/html 72 | 73 | # Click-Once directory 74 | publish 75 | 76 | # Publish Web Output 77 | *.Publish.xml 78 | 79 | # NuGet Packages Directory 80 | # packages # upm pacakge will use Packages 81 | 82 | # Windows Azure Build Output 83 | csx 84 | *.build.csdef 85 | 86 | # Windows Store app package directory 87 | AppPackages/ 88 | 89 | # Others 90 | [Bb]in 91 | [Oo]bj 92 | sql 93 | TestResults 94 | [Tt]est[Rr]esult* 95 | *.Cache 96 | ClientBin 97 | [Ss]tyle[Cc]op.* 98 | ~$* 99 | *.dbmdl 100 | Generated_Code #added for RIA/Silverlight projects 101 | 102 | # Backup & report files from converting an old project file to a newer 103 | # Visual Studio version. Backup files are not needed, because we have git ;-) 104 | _UpgradeReport_Files/ 105 | Backup*/ 106 | UpgradeLog*.XML 107 | .vs/config/applicationhost.config 108 | .vs/restore.dg 109 | 110 | nuget/tools/* 111 | nuget/*.nupkg 112 | nuget/*.unitypackage 113 | .vs/ 114 | 115 | # Jetbrains Rider 116 | .idea/ 117 | 118 | # Unity 119 | 120 | src/NativeMemoryArray.Unity/Library/* 121 | src/NativeMemoryArray.Unity/Temp/* 122 | src/NativeMemoryArray.Unity/Logs/* 123 | src/NativeMemoryArray.Unity/Assembly-CSharp.csproj 124 | 125 | src/NativeMemoryArray.Unity/Assembly-CSharp-Editor.csproj 126 | 127 | src/NativeMemoryArray.Unity/Assembly-CSharp-firstpass.csproj 128 | 129 | src/NativeMemoryArray.Unity/NativeMemoryArray.Unity.1.0.0.unitypackage 130 | 131 | src/NativeMemoryArray.Unity/NativeMemoryArray.Unity.unitypackage 132 | 133 | src/NativeMemoryArray.Unity/NativeMemoryArray.unitypackage 134 | 135 | src/NativeMemoryArray.Unity/NewAssembly.csproj 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Cysharp, Inc. 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. 22 | -------------------------------------------------------------------------------- /NativeMemoryArray.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31903.59 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9138598E-9FA3-4231-98F0-EBC4D54AC812}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeMemoryArray", "src\NativeMemoryArray\NativeMemoryArray.csproj", "{21F01F34-8DE0-448B-BE9F-D0E06D030C06}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8E15400D-C0AD-428C-B425-1FE366264F71}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeMemoryArray.Tests", "tests\NativeMemoryArray.Tests\NativeMemoryArray.Tests.csproj", "{57AB4D7D-CCF3-463C-A890-06F38952F7CD}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sandbox", "sandbox", "{23CFC43D-B628-48CF-95DA-3A3B840B5F9B}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "sandbox\ConsoleApp\ConsoleApp.csproj", "{47886A02-C521-4C84-99A9-8D85808521A6}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {21F01F34-8DE0-448B-BE9F-D0E06D030C06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {21F01F34-8DE0-448B-BE9F-D0E06D030C06}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {21F01F34-8DE0-448B-BE9F-D0E06D030C06}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {21F01F34-8DE0-448B-BE9F-D0E06D030C06}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {57AB4D7D-CCF3-463C-A890-06F38952F7CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {57AB4D7D-CCF3-463C-A890-06F38952F7CD}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {57AB4D7D-CCF3-463C-A890-06F38952F7CD}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {57AB4D7D-CCF3-463C-A890-06F38952F7CD}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {47886A02-C521-4C84-99A9-8D85808521A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {47886A02-C521-4C84-99A9-8D85808521A6}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {47886A02-C521-4C84-99A9-8D85808521A6}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {47886A02-C521-4C84-99A9-8D85808521A6}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(NestedProjects) = preSolution 41 | {21F01F34-8DE0-448B-BE9F-D0E06D030C06} = {9138598E-9FA3-4231-98F0-EBC4D54AC812} 42 | {57AB4D7D-CCF3-463C-A890-06F38952F7CD} = {8E15400D-C0AD-428C-B425-1FE366264F71} 43 | {47886A02-C521-4C84-99A9-8D85808521A6} = {23CFC43D-B628-48CF-95DA-3A3B840B5F9B} 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | SolutionGuid = {0394A9C5-7574-4828-9C25-DE10311D5381} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NativeMemoryArray 2 | === 3 | [![GitHub Actions](https://github.com/Cysharp/NativeMemoryArray/workflows/Build-Debug/badge.svg)](https://github.com/Cysharp/NativeMemoryArray/actions) [![Releases](https://img.shields.io/github/release/Cysharp/NativeMemoryArray.svg)](https://github.com/Cysharp/NativeMemoryArray/releases) 4 | 5 | NativeMemoryArray is a native-memory backed array for .NET and Unity. The array size of C# is limited to maximum index of 0x7FFFFFC7(2,147,483,591), [Array.MaxLength](https://docs.microsoft.com/en-us/dotnet/api/system.array.maxlength). In terms of `bytes[]`, it is about 2GB. This is very cheap in the modern world. We handle the 4K/8K videos, large data set of deep-learning, huge 3D scan data of point cloud, etc. 6 | 7 | `NativeMemoryArray` provides the native-memory backed array, it supports **infinity** length, `Span` and `Memory` slices, `IBufferWriter`, `ReadOnlySeqeunce` and .NET 6's new Scatter/Gather I/O API. 8 | 9 | For example, easy to read huge data in-memory. 10 | 11 | ```csharp 12 | // for example, load large file. 13 | using var handle = File.OpenHandle("4GBfile.bin", FileMode.Open, FileAccess.Read, options: FileOptions.Asynchronous); 14 | var size = RandomAccess.GetLength(handle); 15 | 16 | // via .NET 6 Scatter/Gather API 17 | using var array = new NativeMemoryArray(size); 18 | await RandomAccess.ReadAsync(handle, array.AsMemoryList(), 0); 19 | ``` 20 | 21 | For example, easy to read/write huge data in streaming via `IBufferWriter`, `MemorySequence`. 22 | 23 | ```csharp 24 | public static async Task ReadFromAsync(NativeMemoryArray buffer, Stream stream, CancellationToken cancellationToken = default) 25 | { 26 | var writer = buffer.CreateBufferWriter(); 27 | 28 | int read; 29 | while ((read = await stream.ReadAsync(writer.GetMemory(), cancellationToken).ConfigureAwait(false)) != 0) 30 | { 31 | writer.Advance(read); 32 | } 33 | } 34 | 35 | public static async Task WriteToAsync(NativeMemoryArray buffer, Stream stream, CancellationToken cancellationToken = default) 36 | { 37 | foreach (var item in buffer.AsMemorySequence()) 38 | { 39 | await stream.WriteAsync(item, cancellationToken); 40 | } 41 | } 42 | ``` 43 | 44 | Even if you don't need to deal with huge data, this uses native-memory, so it doesn't use the C# heap. If you are in a situation where you can manage the memory properly, you will have a performance advantage. 45 | 46 | Getting Started 47 | --- 48 | For .NET, use NuGet. For Unity, please read [Unity](#Unity) section. 49 | 50 | > PM> Install-Package [NativeMemoryArray](https://www.nuget.org/packages/NativeMemoryArray) 51 | 52 | NativeMemoryArray provides only simple `Cysharp.Collections.NativeMemoryArray` class. It has `where T : unmanaged` constraint so you can only use struct that not includes reference type. 53 | 54 | ```csharp 55 | // call ctor with length, when Dispose free memory. 56 | using var buffer = new NativeMemoryArray(10); 57 | 58 | buffer[0] = 100; 59 | buffer[1] = 100; 60 | 61 | // T allows all unmanaged(struct that not includes reference type) type. 62 | using var mesh = new NativeMemoryArray(100); 63 | 64 | // AsSpan() can create Span view so you can use all Span APIs(CopyTo/From, Write/Read etc.). 65 | var otherMeshArray = new Vector3[100]; 66 | otherMeshArray.CopyTo(mesh.AsSpan()); 67 | ``` 68 | 69 | The difference with `Span` is that `NativeMemoryArray` itself is a class, so it can be placed in a field. This means that, unlike `Span`, it is possible to ensure some long lifetime. Since you can make a slice of `Memory`, you can also pass it into Async methods. Also, the length limit of `Span` is up to int.MaxValue (roughly 2GB), however `NativeMemoryArray` can be larger than that. 70 | 71 | The main advantages are as follows 72 | 73 | * Allocates from native memory, so it does not use the C# heap. 74 | * There is no limit of 2GB, and infinite length can be allocated as long as memory allows. 75 | * Can pass directly via `IBufferWriter` to `MessagePackSerializer`, `System.Text.Json.Utf8JsonWriter`, `System.IO.Pipelines`, etc. 76 | * Can pass directly via `ReadOnlySequence` to `Utf8JsonWriter`, `System.IO.Pipelines`, etc. 77 | * Can pass huge data directly via `IReadOnlyList<(ReadOnly)Memory>` to `RandomAccess` (Scatter/Gather API). 78 | 79 | All `NativeMemoryArray` APIs are as follows 80 | 81 | * `NativeMemoryArray(long length, bool skipZeroClear = false, bool addMemoryPressure = false)` 82 | * `long Length` 83 | * `ref T this[long index]` 84 | * `ref T GetPinnableReference()` 85 | * `byte* StealPointer()` 86 | * `Span AsSpan()` 87 | * `Span AsSpan(long start)` 88 | * `Span AsSpan(long start, int length)` 89 | * `Memory AsMemory()` 90 | * `Memory AsMemory(long start)` 91 | * `Memory AsMemory(long start, int length)` 92 | * `Stream AsStream()` 93 | * `Stream AsStream(long offset)` 94 | * `Stream AsStream(FileAccess fileAccess)` 95 | * `Stream AsStream(long offset, FileAccess fileAccess)` 96 | * `bool TryGetFullSpan(out Span span)` 97 | * `IBufferWriter CreateBufferWriter()` 98 | * `SpanSequence AsSpanSequence(int chunkSize = int.MaxValue)` 99 | * `MemorySequence AsMemorySequence(int chunkSize = int.MaxValue)` 100 | * `IReadOnlyList> AsMemoryList(int chunkSize = int.MaxValue)` 101 | * `IReadOnlyList> AsReadOnlyMemoryList(int chunkSize = int.MaxValue)` 102 | * `ReadOnlySequence AsReadOnlySequence(int chunkSize = int.MaxValue)` 103 | * `SpanSequence GetEnumerator()` 104 | * `void Dispose()` 105 | 106 | `NativeMemoryArray` allocates memory by [NativeMemory.Alloc/AllocZeroed](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.nativememory) so you need to call `Dispose()` or use `using scope`. In the default, allocated memory is zero-cleared. You can configure via `bool skipZeroClear`. When `bool addMemoryPressure` is true, calls [GC.AddMemoryPressure](https://docs.microsoft.com/en-us/dotnet/api/system.gc.addmemorypressure) and [GC.RemoveMemoryPressure](https://docs.microsoft.com/en-us/dotnet/api/system.gc.removememorypressure) at alloc/free memory. Default is false but if you want to inform allocated memory size to managed GC, set to true. 107 | 108 | `AsSpan()` and `AsMemory()` are APIs for Slice. Returned `Span` and `Memory` possible to allow write operation so you can pass to the Span operation methods. `Span` and `Memory` have limitation of length(int.MaxValue) so if length is omitted, throws exception if array is larger. Using `TryGetFullSpan()` detect can get single full span or not. `AsSpanSequence()` and `AsMemorySequence()` are iterate chunked all data via foreach. Using foreach directly as same as `AsSpanSequence()`. 109 | 110 | ```csharp 111 | long written = 0; 112 | foreach (var chunk in array) 113 | { 114 | // do anything 115 | written += chunk.Length; 116 | } 117 | ``` 118 | 119 | Getting a pointer is almost the same as getting an array. It can be passed as is or with an indexer. 120 | 121 | ```csharp 122 | // buffer = NativeArray 123 | 124 | fixed (byte* p = buffer) 125 | { 126 | } 127 | 128 | fixed (byte* p = &buffer[42]) 129 | { 130 | } 131 | ``` 132 | 133 | `CreateBufferWriter()` allows you to get an `IBufferWriter`. This can be passed directly to `MessagePackSerializer.Serialize`, etc., or used in cases such as reading from a `Stream`, where it is retrieved and written chunk by chunk from the beginning. 134 | 135 | The `ReadOnlySequence` you can get with `AsReadOnlySequence()` can be passed directly to `MessagePackSerializer.Deserialize`, and [SequenceReader](https://docs.microsoft.com/en-us/dotnet/api/system.buffers.sequencereader-1) is useful to processing large data via streaming. 136 | 137 | `AsMemoryList()` and `AsReadOnlySequence()` are convinient data structure for [RandomAccess](https://docs.microsoft.com/en-us/dotnet/api/system.io.randomaccess).`Read/Write` API. 138 | 139 | `AsStream()` convert to the [UnmanagedMemoryStream](https://docs.microsoft.com/en-us/dotnet/api/system.io.unmanagedmemorystream), if you want to do write operation, use `FileAccess.Write`. 140 | 141 | For the simple buffer processing, we provide some utility extension methods. 142 | 143 | ```csharp 144 | public static async Task ReadFromAsync(this NativeMemoryArray buffer, Stream stream, IProgress? progress = null, CancellationToken cancellationToken = default) 145 | public static async Task WriteToFileAsync(this NativeMemoryArray buffer, string path, FileMode mode = FileMode.Create, IProgress? progress = null, CancellationToken cancellationToken = default) 146 | public static async Task WriteToAsync(this NativeMemoryArray buffer, Stream stream, int chunkSize = int.MaxValue, IProgress? progress = null, CancellationToken cancellationToken = default) 147 | ``` 148 | 149 | This utility is excluded the .NET Standard 2.0 environment since runtime API limitation. 150 | 151 | Unity 152 | --- 153 | You can install via UPM git URL package or asset package(NativeMemoryArray.*.unitypackage) available in [NativeMemoryArray/releases](https://github.com/Cysharp/NativeMemoryArray/releases) page. 154 | 155 | * `https://github.com/Cysharp/NativeMemoryArray.git?path=src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray` 156 | 157 | NativeMemoryArray requires `System.Memory.dll`, `System.Buffer.dll`, `System.Runtime.CompilerServices.Unsafe.dll`. It is not included in git URL so you need get from others or install via .unitypackage only once. 158 | 159 | The difference between `NativeArray` and `NativeMemoryArray` in Unity is that `NativeArray` is a container for efficient interaction with the Unity Engine(C++) side. `NativeMemoryArray` has a different role because it is for C# side only. 160 | 161 | License 162 | --- 163 | This library is licensed under the MIT License. 164 | -------------------------------------------------------------------------------- /opensource.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cysharp/NativeMemoryArray/d8a3290788ff765f423e4105d2587191f8e45672/opensource.snk -------------------------------------------------------------------------------- /sandbox/ConsoleApp/ConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | 10.0 8 | true 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sandbox/ConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using Cysharp.Collections; 2 | using System; 3 | using System.IO; 4 | using System.Linq; 5 | 6 | 7 | var yaki = new NativeMemoryArray(100); 8 | var tako = new NativeMemoryArray(100, skipZeroClear: true, addMemoryPressure: true); 9 | 10 | yaki.Dispose(); 11 | tako.Dispose(); 12 | 13 | var z = new NativeMemoryArray(100); 14 | _ = z[0]; 15 | //_ = z[-1]; // System.IndexOutOfRangeException: Index was outside the bounds of the array. 16 | 17 | 18 | var bin1 = new NativeMemoryArray((long)int.MaxValue + 1024); 19 | var bin2 = new NativeMemoryArray((long)int.MaxValue + 1024); 20 | Fill(ref bin1); 21 | 22 | { 23 | using var handle = File.OpenHandle("foo.bin", FileMode.Create, FileAccess.Write, options: FileOptions.Asynchronous); 24 | await RandomAccess.WriteAsync(handle, bin1.AsReadOnlyMemoryList(), 0); 25 | } 26 | 27 | { 28 | using var handle = File.OpenHandle("foo.bin", FileMode.Open, FileAccess.Read, options: FileOptions.Asynchronous); 29 | await RandomAccess.ReadAsync(handle, bin2.AsMemoryList(), 0); 30 | } 31 | 32 | var a = bin1.AsReadOnlyMemoryList(); 33 | var b = bin2.AsReadOnlyMemoryList(); 34 | 35 | Console.WriteLine(a[0].Span.SequenceEqual(b[0].Span)); 36 | Console.WriteLine(a[1].Span.SequenceEqual(b[1].Span)); 37 | 38 | bin1.Dispose(); 39 | bin2.Dispose(); 40 | 41 | // allow use Span in async context. 42 | static void Fill(ref NativeMemoryArray bin) 43 | { 44 | var i = 0; 45 | foreach (var item in bin) 46 | { 47 | if (i++ == 0) 48 | { 49 | item.Fill(100); 50 | } 51 | else 52 | { 53 | item.Fill(200); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.VisualStudio.Workload.ManagedGame" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd6b1bbc7cadc1a44b3bfaeba3f40abc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Editor/PackageExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | public static class PackageExporter 8 | { 9 | [MenuItem("Tools/Export Unitypackage")] 10 | public static void Export() 11 | { 12 | var root = "Plugins/NativeMemoryArray"; 13 | var version = GetVersion(root); 14 | 15 | var fileName = string.IsNullOrEmpty(version) ? "NativeMemoryArray.Unity.unitypackage" : $"NativeMemoryArray.Unity.{version}.unitypackage"; 16 | var exportPath = "./" + fileName; 17 | 18 | var path = Path.Combine(Application.dataPath, root); 19 | var assets = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) 20 | .Where(x => Path.GetExtension(x) == ".cs" || Path.GetExtension(x) == ".meta" || Path.GetExtension(x) == ".asmdef" || Path.GetExtension(x) == ".json") 21 | .Where(x => Path.GetFileNameWithoutExtension(x) != "_InternalVisibleTo") 22 | .Select(x => "Assets" + x.Replace(Application.dataPath, "").Replace(@"\", "/")) 23 | .ToArray(); 24 | 25 | var netStandardsAsset = Directory.EnumerateFiles(Path.Combine(Application.dataPath, "Plugins/"), "*", SearchOption.TopDirectoryOnly) 26 | .Select(x => "Assets" + x.Replace(Application.dataPath, "").Replace(@"\", "/")) 27 | .ToArray(); 28 | 29 | assets = assets.Concat(netStandardsAsset).ToArray(); 30 | 31 | UnityEngine.Debug.Log("Export below files" + Environment.NewLine + string.Join(Environment.NewLine, assets)); 32 | 33 | var dir = new FileInfo(exportPath).Directory; 34 | if (!dir.Exists) dir.Create(); 35 | AssetDatabase.ExportPackage( 36 | assets, 37 | exportPath, 38 | ExportPackageOptions.Default); 39 | 40 | UnityEngine.Debug.Log("Export complete: " + Path.GetFullPath(exportPath)); 41 | } 42 | 43 | static string GetVersion(string root) 44 | { 45 | var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION"); 46 | var versionJson = Path.Combine(Application.dataPath, root, "package.json"); 47 | 48 | if (File.Exists(versionJson)) 49 | { 50 | var v = JsonUtility.FromJson(File.ReadAllText(versionJson)); 51 | 52 | if (!string.IsNullOrEmpty(version)) 53 | { 54 | if (v.version != version) 55 | { 56 | var msg = $"package.json and env version are mismatched. UNITY_PACKAGE_VERSION:{version}, package.json:{v.version}"; 57 | 58 | if (Application.isBatchMode) 59 | { 60 | Console.WriteLine(msg); 61 | Application.Quit(1); 62 | } 63 | 64 | throw new Exception("package.json and env version are mismatched."); 65 | } 66 | } 67 | 68 | version = v.version; 69 | } 70 | 71 | return version; 72 | } 73 | 74 | public class Version 75 | { 76 | public string version; 77 | } 78 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Editor/PackageExporter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34885e00b06e4c847b8e2958ebb2d26b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7879a2d5f169bb7418850314c5c11271 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25293fbf30d13a34e9efb27cbbc4ea95 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4accbc00b0fea374b974829ca20b998f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArray.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewAssembly", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": true 14 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArray.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b2a8587c2023644e9884243cd2b3739 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArray.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | using System; 4 | using System.Buffers; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Runtime.CompilerServices; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace Cysharp.Collections 12 | { 13 | [DebuggerTypeProxy(typeof(NativeMemoryArrayDebugView<>))] 14 | public sealed unsafe class NativeMemoryArray : IDisposable 15 | where T : unmanaged 16 | { 17 | public static readonly NativeMemoryArray Empty; 18 | 19 | readonly long length; 20 | readonly bool addMemoryPressure; 21 | internal readonly byte* buffer; 22 | bool isDisposed; 23 | 24 | public long Length => length; 25 | 26 | static NativeMemoryArray() 27 | { 28 | Empty = new NativeMemoryArray(0); 29 | Empty.Dispose(); 30 | } 31 | 32 | public NativeMemoryArray(long length, bool skipZeroClear = false, bool addMemoryPressure = false) 33 | { 34 | this.length = length; 35 | this.addMemoryPressure = addMemoryPressure; 36 | 37 | if (length == 0) 38 | { 39 | #if UNITY_2019_1_OR_NEWER 40 | buffer = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(null)); 41 | #else 42 | buffer = (byte*)Unsafe.AsPointer(ref Unsafe.NullRef()); 43 | #endif 44 | } 45 | else 46 | { 47 | var allocSize = length * Unsafe.SizeOf(); 48 | #if NET6_0_OR_GREATER 49 | if (skipZeroClear) 50 | { 51 | buffer = (byte*)NativeMemory.Alloc(checked((nuint)length), (nuint)Unsafe.SizeOf()); 52 | } 53 | else 54 | { 55 | buffer = (byte*)NativeMemory.AllocZeroed(checked((nuint)length), (nuint)Unsafe.SizeOf()); 56 | } 57 | #else 58 | buffer = (byte*)Marshal.AllocHGlobal((IntPtr)allocSize); 59 | if (!skipZeroClear) 60 | { 61 | foreach (var span in this) 62 | { 63 | span.Clear(); 64 | } 65 | } 66 | #endif 67 | if (addMemoryPressure) 68 | { 69 | GC.AddMemoryPressure(allocSize); 70 | } 71 | } 72 | } 73 | 74 | public ref T this[long index] 75 | { 76 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 77 | get 78 | { 79 | if ((ulong)index >= (ulong)length) ThrowHelper.ThrowIndexOutOfRangeException(); 80 | var memoryIndex = index * Unsafe.SizeOf(); 81 | return ref Unsafe.AsRef(buffer + memoryIndex); 82 | } 83 | } 84 | 85 | public Span AsSpan() 86 | { 87 | return AsSpan(0); 88 | } 89 | 90 | public Span AsSpan(long start) 91 | { 92 | if ((ulong)start > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(start)); 93 | return AsSpan(start, checked((int)(length - start))); 94 | } 95 | 96 | public Span AsSpan(long start, int length) 97 | { 98 | if ((ulong)(start + length) > (ulong)this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 99 | return new Span(buffer + start * Unsafe.SizeOf(), length); 100 | } 101 | 102 | public Memory AsMemory() 103 | { 104 | return AsMemory(0); 105 | } 106 | 107 | public Memory AsMemory(long start) 108 | { 109 | if ((ulong)start > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(start)); 110 | return AsMemory(start, checked((int)(length - start))); 111 | } 112 | 113 | public Memory AsMemory(long start, int length) 114 | { 115 | if ((ulong)(start + length) > (ulong)(this.length)) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 116 | return new PointerMemoryManager(buffer + start * Unsafe.SizeOf(), length).Memory; 117 | } 118 | 119 | public Stream AsStream() 120 | { 121 | return new UnmanagedMemoryStream(buffer, length * Unsafe.SizeOf()); 122 | } 123 | 124 | public Stream AsStream(long offset) 125 | { 126 | if ((ulong)offset > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 127 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), length * Unsafe.SizeOf()); 128 | } 129 | 130 | public Stream AsStream(FileAccess fileAccess) 131 | { 132 | var len = length * Unsafe.SizeOf(); 133 | return new UnmanagedMemoryStream(buffer, len, len, fileAccess); 134 | } 135 | 136 | public Stream AsStream(long offset, FileAccess fileAccess) 137 | { 138 | if ((ulong)offset > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 139 | var len = length * Unsafe.SizeOf(); 140 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), len, len, fileAccess); 141 | } 142 | 143 | public ref T GetPinnableReference() 144 | { 145 | if (length == 0) 146 | { 147 | #if UNITY_2019_1_OR_NEWER 148 | return ref Unsafe.AsRef(null); 149 | #else 150 | return ref Unsafe.NullRef(); 151 | #endif 152 | } 153 | return ref this[0]; 154 | } 155 | 156 | public bool TryGetFullSpan(out Span span) 157 | { 158 | if (length < int.MaxValue) 159 | { 160 | span = new Span(buffer, (int)length); 161 | return true; 162 | } 163 | else 164 | { 165 | span = default; 166 | return false; 167 | } 168 | } 169 | 170 | public IBufferWriter CreateBufferWriter() 171 | { 172 | return new NativeMemoryArrayBufferWriter(this); 173 | } 174 | 175 | public SpanSequence AsSpanSequence(int chunkSize = int.MaxValue) 176 | { 177 | return new SpanSequence(this, chunkSize); 178 | } 179 | 180 | public MemorySequence AsMemorySequence(int chunkSize = int.MaxValue) 181 | { 182 | return new MemorySequence(this, chunkSize); 183 | } 184 | 185 | public IReadOnlyList> AsMemoryList(int chunkSize = int.MaxValue) 186 | { 187 | if (length == 0) return Array.Empty>(); 188 | 189 | var array = new Memory[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 190 | { 191 | var i = 0; 192 | foreach (var item in AsMemorySequence(chunkSize)) 193 | { 194 | array[i++] = item; 195 | } 196 | } 197 | 198 | return array; 199 | } 200 | 201 | public IReadOnlyList> AsReadOnlyMemoryList(int chunkSize = int.MaxValue) 202 | { 203 | if (length == 0) return Array.Empty>(); 204 | 205 | var array = new ReadOnlyMemory[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 206 | { 207 | var i = 0; 208 | foreach (var item in AsMemorySequence(chunkSize)) 209 | { 210 | array[i++] = item; 211 | } 212 | } 213 | 214 | return array; 215 | } 216 | 217 | public ReadOnlySequence AsReadOnlySequence(int chunkSize = int.MaxValue) 218 | { 219 | if (length == 0) return ReadOnlySequence.Empty; 220 | 221 | var array = new Segment[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 222 | { 223 | var i = 0; 224 | foreach (var item in AsMemorySequence(chunkSize)) 225 | { 226 | array[i++] = new Segment(item); 227 | } 228 | } 229 | 230 | long running = 0; 231 | for (int i = 0; i < array.Length; i++) 232 | { 233 | var next = i < array.Length - 1 ? array[i + 1] : null; 234 | array[i].SetRunningIndexAndNext(running, next); 235 | running += array[i].Memory.Length; 236 | } 237 | 238 | var firstSegment = array[0]; 239 | var lastSegment = array[array.Length - 1]; 240 | return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); 241 | } 242 | 243 | public SpanSequence GetEnumerator() 244 | { 245 | return AsSpanSequence(int.MaxValue); 246 | } 247 | 248 | public override string ToString() 249 | { 250 | return typeof(T).Name + "[" + length + "]"; 251 | } 252 | 253 | public void Dispose() 254 | { 255 | DisposeCore(); 256 | GC.SuppressFinalize(this); 257 | } 258 | 259 | void DisposeCore() 260 | { 261 | if (!isDisposed) 262 | { 263 | isDisposed = true; 264 | #if UNITY_2019_1_OR_NEWER 265 | if (buffer == null) return; 266 | #else 267 | if (Unsafe.IsNullRef(ref Unsafe.AsRef(buffer))) return; 268 | #endif 269 | 270 | #if NET6_0_OR_GREATER 271 | NativeMemory.Free(buffer); 272 | #else 273 | Marshal.FreeHGlobal((IntPtr)buffer); 274 | #endif 275 | if (addMemoryPressure) 276 | { 277 | GC.RemoveMemoryPressure(length * Unsafe.SizeOf()); 278 | } 279 | } 280 | } 281 | 282 | ~NativeMemoryArray() 283 | { 284 | DisposeCore(); 285 | } 286 | 287 | public struct SpanSequence 288 | { 289 | readonly NativeMemoryArray nativeArray; 290 | readonly int chunkSize; 291 | long index; 292 | long sliceStart; 293 | 294 | internal SpanSequence(NativeMemoryArray nativeArray, int chunkSize) 295 | { 296 | this.nativeArray = nativeArray; 297 | index = 0; 298 | sliceStart = 0; 299 | this.chunkSize = chunkSize; 300 | } 301 | 302 | public SpanSequence GetEnumerator() => this; 303 | 304 | public Span Current 305 | { 306 | get 307 | { 308 | return nativeArray.AsSpan(sliceStart, (int)Math.Min(chunkSize, nativeArray.length - sliceStart)); 309 | } 310 | } 311 | 312 | public bool MoveNext() 313 | { 314 | if (index < nativeArray.length) 315 | { 316 | sliceStart = index; 317 | index += chunkSize; 318 | return true; 319 | } 320 | return false; 321 | } 322 | } 323 | 324 | public struct MemorySequence 325 | { 326 | readonly NativeMemoryArray nativeArray; 327 | readonly int chunkSize; 328 | long index; 329 | long sliceStart; 330 | 331 | internal MemorySequence(NativeMemoryArray nativeArray, int chunkSize) 332 | { 333 | this.nativeArray = nativeArray; 334 | index = 0; 335 | sliceStart = 0; 336 | this.chunkSize = chunkSize; 337 | } 338 | 339 | public MemorySequence GetEnumerator() => this; 340 | 341 | public Memory Current 342 | { 343 | get 344 | { 345 | return nativeArray.AsMemory(sliceStart, (int)Math.Min(chunkSize, nativeArray.length - sliceStart)); 346 | } 347 | } 348 | 349 | public bool MoveNext() 350 | { 351 | if (index < nativeArray.length) 352 | { 353 | sliceStart = index; 354 | index += chunkSize; 355 | return true; 356 | } 357 | return false; 358 | } 359 | } 360 | 361 | class Segment : ReadOnlySequenceSegment 362 | { 363 | public Segment(Memory buffer) 364 | { 365 | Memory = buffer; 366 | } 367 | 368 | internal void SetRunningIndexAndNext(long runningIndex, Segment? nextSegment) 369 | { 370 | RunningIndex = runningIndex; 371 | Next = nextSegment; 372 | } 373 | } 374 | } 375 | 376 | internal sealed unsafe class NativeMemoryArrayBufferWriter : IBufferWriter 377 | where T : unmanaged 378 | { 379 | readonly NativeMemoryArray nativeArray; 380 | PointerMemoryManager? pointerMemoryManager; 381 | long written; 382 | 383 | internal NativeMemoryArrayBufferWriter(NativeMemoryArray nativeArray) 384 | { 385 | this.nativeArray = nativeArray; 386 | pointerMemoryManager = null; 387 | } 388 | 389 | public void Advance(int count) 390 | { 391 | written += count; 392 | if (pointerMemoryManager != null) 393 | { 394 | pointerMemoryManager.AllowReuse(); 395 | } 396 | } 397 | 398 | public Span GetSpan(int sizeHint = 0) 399 | { 400 | if (sizeHint < 0) throw new InvalidOperationException($"sizeHint:{sizeHint} is invalid range."); 401 | if (nativeArray.Length - written < sizeHint) throw new InvalidOperationException($"sizeHint:{sizeHint} is capacity:{nativeArray.Length} - written:{written} over"); 402 | var length = (int)Math.Min(int.MaxValue, nativeArray.Length - written); 403 | 404 | if (length == 0) return Array.Empty(); 405 | return new Span(nativeArray.buffer + written * Unsafe.SizeOf(), length); 406 | } 407 | 408 | public Memory GetMemory(int sizeHint = 0) 409 | { 410 | if (sizeHint < 0) throw new InvalidOperationException($"sizeHint:{sizeHint} is invalid range."); 411 | if (nativeArray.Length - written < sizeHint) throw new InvalidOperationException($"sizeHint:{sizeHint} is capacity:{nativeArray.Length} - written:{written} over"); 412 | var length = (int)Math.Min(int.MaxValue, nativeArray.Length - written); 413 | if (length == 0) return Array.Empty(); 414 | 415 | if (pointerMemoryManager == null) 416 | { 417 | pointerMemoryManager = new PointerMemoryManager(nativeArray.buffer + written * Unsafe.SizeOf(), length); 418 | } 419 | else 420 | { 421 | pointerMemoryManager.Reset(nativeArray.buffer + written * Unsafe.SizeOf(), length); 422 | } 423 | 424 | return pointerMemoryManager.Memory; 425 | } 426 | } 427 | 428 | internal sealed class NativeMemoryArrayDebugView 429 | where T : unmanaged 430 | { 431 | private readonly NativeMemoryArray array; 432 | 433 | public NativeMemoryArrayDebugView(NativeMemoryArray array) 434 | { 435 | if (array == null) 436 | { 437 | throw new ArgumentNullException(nameof(array)); 438 | } 439 | this.array = array; 440 | } 441 | 442 | [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] 443 | public Span Items 444 | { 445 | get 446 | { 447 | if (array.TryGetFullSpan(out var span)) 448 | { 449 | return span; 450 | } 451 | else 452 | { 453 | return array.AsSpan(0, 1000000); // limit 454 | } 455 | } 456 | } 457 | } 458 | } 459 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bd21246e45018f4893a3128b39637a4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArrayExtensions.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 4 | 5 | using System; 6 | using System.IO; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Cysharp.Collections 11 | { 12 | public static class NativeMemoryArrayExtensions 13 | { 14 | public static async Task ReadFromAsync(this NativeMemoryArray buffer, Stream stream, IProgress? progress = null, CancellationToken cancellationToken = default) 15 | { 16 | var writer = buffer.CreateBufferWriter(); 17 | 18 | int read; 19 | while ((read = await stream.ReadAsync(writer.GetMemory(), cancellationToken).ConfigureAwait(false)) != 0) 20 | { 21 | progress?.Report(read); 22 | writer.Advance(read); 23 | } 24 | } 25 | 26 | public static async Task WriteToFileAsync(this NativeMemoryArray buffer, string path, FileMode mode = FileMode.Create, IProgress? progress = null, CancellationToken cancellationToken = default) 27 | { 28 | using (var fs = new FileStream(path, mode, FileAccess.Write, FileShare.ReadWrite, 1, useAsync: true)) 29 | { 30 | await buffer.WriteToAsync(fs, progress: progress, cancellationToken: cancellationToken); 31 | } 32 | } 33 | 34 | public static async Task WriteToAsync(this NativeMemoryArray buffer, Stream stream, int chunkSize = int.MaxValue, IProgress? progress = null, CancellationToken cancellationToken = default) 35 | { 36 | foreach (var item in buffer.AsReadOnlyMemoryList(chunkSize)) 37 | { 38 | await stream.WriteAsync(item, cancellationToken); 39 | progress?.Report(item.Length); 40 | } 41 | } 42 | } 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/NativeMemoryArrayExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fca34b2d2ac8ae449406028223843d9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/PointerMemoryManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Buffers; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace Cysharp.Collections 6 | { 7 | internal sealed unsafe class PointerMemoryManager : MemoryManager 8 | where T : unmanaged 9 | { 10 | byte* pointer; 11 | int length; 12 | bool usingMemory; 13 | 14 | internal PointerMemoryManager(byte* pointer, int length) 15 | { 16 | this.pointer = pointer; 17 | this.length = length; 18 | usingMemory = false; 19 | } 20 | 21 | protected override void Dispose(bool disposing) 22 | { 23 | } 24 | 25 | public override Span GetSpan() 26 | { 27 | usingMemory = true; 28 | return new Span(pointer, length); 29 | } 30 | 31 | public override MemoryHandle Pin(int elementIndex = 0) 32 | { 33 | if ((uint)elementIndex >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); 34 | return new MemoryHandle(pointer + elementIndex * Unsafe.SizeOf(), default, this); 35 | } 36 | 37 | public override void Unpin() 38 | { 39 | } 40 | 41 | public void AllowReuse() 42 | { 43 | usingMemory = false; 44 | } 45 | 46 | public void Reset(byte* pointer, int length) 47 | { 48 | if (usingMemory) throw new InvalidOperationException("Memory is using, can not reset."); 49 | this.pointer = pointer; 50 | this.length = length; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/PointerMemoryManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e9b51d0bb0922f44848ee3fd9801984 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/ThrowHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace Cysharp.Collections 6 | { 7 | internal static class ThrowHelper 8 | { 9 | [MethodImpl(MethodImplOptions.NoInlining)] 10 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 11 | [DoesNotReturn] 12 | #endif 13 | public static void ThrowIndexOutOfRangeException() 14 | { 15 | throw new IndexOutOfRangeException(); 16 | } 17 | 18 | [MethodImpl(MethodImplOptions.NoInlining)] 19 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 20 | [DoesNotReturn] 21 | #endif 22 | public static void ThrowArgumentOutOfRangeException(string paramName) 23 | { 24 | throw new ArgumentOutOfRangeException(paramName); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/Runtime/ThrowHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a35ce35277116e54f9460edb68baca72 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.cysharp.nativememoryarray", 3 | "displayName": "NativeMemoryArray", 4 | "author": { "name": "Cysharp, Inc.", "url": "https://cysharp.co.jp/en/" }, 5 | "version": "1.2.2", 6 | "unity": "2020.1", 7 | "description": "Utilized native-memory backed array.", 8 | "keywords": [ "array", "unsafe", "memory", "buffer" ], 9 | "license": "MIT", 10 | "category": "Scripting", 11 | "dependencies": {} 12 | } 13 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/NativeMemoryArray/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2905a822078b6494eb5205bd1e1bf703 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Buffers.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cysharp/NativeMemoryArray/d8a3290788ff765f423e4105d2587191f8e45672/src/NativeMemoryArray.Unity/Assets/Plugins/System.Buffers.dll -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Buffers.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7c35ce1ba3816ae2ac38342247f9692 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Memory.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cysharp/NativeMemoryArray/d8a3290788ff765f423e4105d2587191f8e45672/src/NativeMemoryArray.Unity/Assets/Plugins/System.Memory.dll -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Memory.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f25cb5ab550d39d4a8cd4ad7bf6ba253 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cysharp/NativeMemoryArray/d8a3290788ff765f423e4105d2587191f8e45672/src/NativeMemoryArray.Unity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eae2d45a08791e845b3132791a643278 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b4106bf08544b346b0a03496d7673b8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Scenes/Sample.cs: -------------------------------------------------------------------------------- 1 | using Cysharp.Collections; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class Sample : MonoBehaviour 7 | { 8 | // Start is called before the first frame update 9 | void Start() 10 | { 11 | using (var array = new NativeMemoryArray(5)) 12 | { 13 | array[0] = 100; 14 | array[1] = 200; 15 | array[2] = 300; 16 | array[3] = 400; 17 | array[4] = 500; 18 | 19 | 20 | foreach (var item in array.AsSpan()) 21 | { 22 | Debug.Log(item); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Scenes/Sample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6379560a16969b641b075f50755e96f2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Scenes/SampleScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 0 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 2 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &519420028 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 519420032} 135 | - component: {fileID: 519420031} 136 | - component: {fileID: 519420029} 137 | m_Layer: 0 138 | m_Name: Main Camera 139 | m_TagString: MainCamera 140 | m_Icon: {fileID: 0} 141 | m_NavMeshLayer: 0 142 | m_StaticEditorFlags: 0 143 | m_IsActive: 1 144 | --- !u!81 &519420029 145 | AudioListener: 146 | m_ObjectHideFlags: 0 147 | m_CorrespondingSourceObject: {fileID: 0} 148 | m_PrefabInstance: {fileID: 0} 149 | m_PrefabAsset: {fileID: 0} 150 | m_GameObject: {fileID: 519420028} 151 | m_Enabled: 1 152 | --- !u!20 &519420031 153 | Camera: 154 | m_ObjectHideFlags: 0 155 | m_CorrespondingSourceObject: {fileID: 0} 156 | m_PrefabInstance: {fileID: 0} 157 | m_PrefabAsset: {fileID: 0} 158 | m_GameObject: {fileID: 519420028} 159 | m_Enabled: 1 160 | serializedVersion: 2 161 | m_ClearFlags: 2 162 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 163 | m_projectionMatrixMode: 1 164 | m_GateFitMode: 2 165 | m_FOVAxisMode: 0 166 | m_SensorSize: {x: 36, y: 24} 167 | m_LensShift: {x: 0, y: 0} 168 | m_FocalLength: 50 169 | m_NormalizedViewPortRect: 170 | serializedVersion: 2 171 | x: 0 172 | y: 0 173 | width: 1 174 | height: 1 175 | near clip plane: 0.3 176 | far clip plane: 1000 177 | field of view: 60 178 | orthographic: 1 179 | orthographic size: 5 180 | m_Depth: -1 181 | m_CullingMask: 182 | serializedVersion: 2 183 | m_Bits: 4294967295 184 | m_RenderingPath: -1 185 | m_TargetTexture: {fileID: 0} 186 | m_TargetDisplay: 0 187 | m_TargetEye: 0 188 | m_HDR: 1 189 | m_AllowMSAA: 0 190 | m_AllowDynamicResolution: 0 191 | m_ForceIntoRT: 0 192 | m_OcclusionCulling: 0 193 | m_StereoConvergence: 10 194 | m_StereoSeparation: 0.022 195 | --- !u!4 &519420032 196 | Transform: 197 | m_ObjectHideFlags: 0 198 | m_CorrespondingSourceObject: {fileID: 0} 199 | m_PrefabInstance: {fileID: 0} 200 | m_PrefabAsset: {fileID: 0} 201 | m_GameObject: {fileID: 519420028} 202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 203 | m_LocalPosition: {x: 0, y: 0, z: -10} 204 | m_LocalScale: {x: 1, y: 1, z: 1} 205 | m_Children: [] 206 | m_Father: {fileID: 0} 207 | m_RootOrder: 0 208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 209 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cda990e2423bbf4892e6590ba056729 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/NativeMemoryArray.Unity.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewAssembly", "NewAssembly.csproj", "{663A79CD-854F-0AD2-B2EC-65E48DD30F0C}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{0E958E61-A54C-6A19-55CF-A7F98B12DB99}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{A8FC468B-D008-9875-AB76-607A29E13C72}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {663A79CD-854F-0AD2-B2EC-65E48DD30F0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {663A79CD-854F-0AD2-B2EC-65E48DD30F0C}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {663A79CD-854F-0AD2-B2EC-65E48DD30F0C}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {663A79CD-854F-0AD2-B2EC-65E48DD30F0C}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {0E958E61-A54C-6A19-55CF-A7F98B12DB99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {0E958E61-A54C-6A19-55CF-A7F98B12DB99}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {0E958E61-A54C-6A19-55CF-A7F98B12DB99}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {0E958E61-A54C-6A19-55CF-A7F98B12DB99}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {A8FC468B-D008-9875-AB76-607A29E13C72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {A8FC468B-D008-9875-AB76-607A29E13C72}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {A8FC468B-D008-9875-AB76-607A29E13C72}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {A8FC468B-D008-9875-AB76-607A29E13C72}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.3.9", 4 | "com.unity.ide.rider": "2.0.7", 5 | "com.unity.ide.visualstudio": "2.0.5", 6 | "com.unity.ide.vscode": "1.2.3", 7 | "com.unity.test-framework": "1.1.24", 8 | "com.unity.textmeshpro": "3.0.1", 9 | "com.unity.timeline": "1.2.18", 10 | "com.unity.ugui": "1.0.0", 11 | "com.unity.modules.ai": "1.0.0", 12 | "com.unity.modules.androidjni": "1.0.0", 13 | "com.unity.modules.animation": "1.0.0", 14 | "com.unity.modules.assetbundle": "1.0.0", 15 | "com.unity.modules.audio": "1.0.0", 16 | "com.unity.modules.cloth": "1.0.0", 17 | "com.unity.modules.director": "1.0.0", 18 | "com.unity.modules.imageconversion": "1.0.0", 19 | "com.unity.modules.imgui": "1.0.0", 20 | "com.unity.modules.jsonserialize": "1.0.0", 21 | "com.unity.modules.particlesystem": "1.0.0", 22 | "com.unity.modules.physics": "1.0.0", 23 | "com.unity.modules.physics2d": "1.0.0", 24 | "com.unity.modules.screencapture": "1.0.0", 25 | "com.unity.modules.terrain": "1.0.0", 26 | "com.unity.modules.terrainphysics": "1.0.0", 27 | "com.unity.modules.tilemap": "1.0.0", 28 | "com.unity.modules.ui": "1.0.0", 29 | "com.unity.modules.uielements": "1.0.0", 30 | "com.unity.modules.umbra": "1.0.0", 31 | "com.unity.modules.unityanalytics": "1.0.0", 32 | "com.unity.modules.unitywebrequest": "1.0.0", 33 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 34 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 35 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 36 | "com.unity.modules.unitywebrequestwww": "1.0.0", 37 | "com.unity.modules.vehicles": "1.0.0", 38 | "com.unity.modules.video": "1.0.0", 39 | "com.unity.modules.vr": "1.0.0", 40 | "com.unity.modules.wind": "1.0.0", 41 | "com.unity.modules.xr": "1.0.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": { 4 | "version": "1.3.9", 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": "2.0.7", 19 | "depth": 0, 20 | "source": "registry", 21 | "dependencies": { 22 | "com.unity.test-framework": "1.1.1" 23 | }, 24 | "url": "https://packages.unity.com" 25 | }, 26 | "com.unity.ide.visualstudio": { 27 | "version": "2.0.5", 28 | "depth": 0, 29 | "source": "registry", 30 | "dependencies": {}, 31 | "url": "https://packages.unity.com" 32 | }, 33 | "com.unity.ide.vscode": { 34 | "version": "1.2.3", 35 | "depth": 0, 36 | "source": "registry", 37 | "dependencies": {}, 38 | "url": "https://packages.unity.com" 39 | }, 40 | "com.unity.test-framework": { 41 | "version": "1.1.24", 42 | "depth": 0, 43 | "source": "registry", 44 | "dependencies": { 45 | "com.unity.ext.nunit": "1.0.6", 46 | "com.unity.modules.imgui": "1.0.0", 47 | "com.unity.modules.jsonserialize": "1.0.0" 48 | }, 49 | "url": "https://packages.unity.com" 50 | }, 51 | "com.unity.textmeshpro": { 52 | "version": "3.0.1", 53 | "depth": 0, 54 | "source": "registry", 55 | "dependencies": { 56 | "com.unity.ugui": "1.0.0" 57 | }, 58 | "url": "https://packages.unity.com" 59 | }, 60 | "com.unity.timeline": { 61 | "version": "1.2.18", 62 | "depth": 0, 63 | "source": "registry", 64 | "dependencies": { 65 | "com.unity.modules.director": "1.0.0", 66 | "com.unity.modules.animation": "1.0.0", 67 | "com.unity.modules.audio": "1.0.0", 68 | "com.unity.modules.particlesystem": "1.0.0" 69 | }, 70 | "url": "https://packages.unity.com" 71 | }, 72 | "com.unity.ugui": { 73 | "version": "1.0.0", 74 | "depth": 0, 75 | "source": "builtin", 76 | "dependencies": { 77 | "com.unity.modules.ui": "1.0.0", 78 | "com.unity.modules.imgui": "1.0.0" 79 | } 80 | }, 81 | "com.unity.modules.ai": { 82 | "version": "1.0.0", 83 | "depth": 0, 84 | "source": "builtin", 85 | "dependencies": {} 86 | }, 87 | "com.unity.modules.androidjni": { 88 | "version": "1.0.0", 89 | "depth": 0, 90 | "source": "builtin", 91 | "dependencies": {} 92 | }, 93 | "com.unity.modules.animation": { 94 | "version": "1.0.0", 95 | "depth": 0, 96 | "source": "builtin", 97 | "dependencies": {} 98 | }, 99 | "com.unity.modules.assetbundle": { 100 | "version": "1.0.0", 101 | "depth": 0, 102 | "source": "builtin", 103 | "dependencies": {} 104 | }, 105 | "com.unity.modules.audio": { 106 | "version": "1.0.0", 107 | "depth": 0, 108 | "source": "builtin", 109 | "dependencies": {} 110 | }, 111 | "com.unity.modules.cloth": { 112 | "version": "1.0.0", 113 | "depth": 0, 114 | "source": "builtin", 115 | "dependencies": { 116 | "com.unity.modules.physics": "1.0.0" 117 | } 118 | }, 119 | "com.unity.modules.director": { 120 | "version": "1.0.0", 121 | "depth": 0, 122 | "source": "builtin", 123 | "dependencies": { 124 | "com.unity.modules.audio": "1.0.0", 125 | "com.unity.modules.animation": "1.0.0" 126 | } 127 | }, 128 | "com.unity.modules.imageconversion": { 129 | "version": "1.0.0", 130 | "depth": 0, 131 | "source": "builtin", 132 | "dependencies": {} 133 | }, 134 | "com.unity.modules.imgui": { 135 | "version": "1.0.0", 136 | "depth": 0, 137 | "source": "builtin", 138 | "dependencies": {} 139 | }, 140 | "com.unity.modules.jsonserialize": { 141 | "version": "1.0.0", 142 | "depth": 0, 143 | "source": "builtin", 144 | "dependencies": {} 145 | }, 146 | "com.unity.modules.particlesystem": { 147 | "version": "1.0.0", 148 | "depth": 0, 149 | "source": "builtin", 150 | "dependencies": {} 151 | }, 152 | "com.unity.modules.physics": { 153 | "version": "1.0.0", 154 | "depth": 0, 155 | "source": "builtin", 156 | "dependencies": {} 157 | }, 158 | "com.unity.modules.physics2d": { 159 | "version": "1.0.0", 160 | "depth": 0, 161 | "source": "builtin", 162 | "dependencies": {} 163 | }, 164 | "com.unity.modules.screencapture": { 165 | "version": "1.0.0", 166 | "depth": 0, 167 | "source": "builtin", 168 | "dependencies": { 169 | "com.unity.modules.imageconversion": "1.0.0" 170 | } 171 | }, 172 | "com.unity.modules.subsystems": { 173 | "version": "1.0.0", 174 | "depth": 1, 175 | "source": "builtin", 176 | "dependencies": { 177 | "com.unity.modules.jsonserialize": "1.0.0" 178 | } 179 | }, 180 | "com.unity.modules.terrain": { 181 | "version": "1.0.0", 182 | "depth": 0, 183 | "source": "builtin", 184 | "dependencies": {} 185 | }, 186 | "com.unity.modules.terrainphysics": { 187 | "version": "1.0.0", 188 | "depth": 0, 189 | "source": "builtin", 190 | "dependencies": { 191 | "com.unity.modules.physics": "1.0.0", 192 | "com.unity.modules.terrain": "1.0.0" 193 | } 194 | }, 195 | "com.unity.modules.tilemap": { 196 | "version": "1.0.0", 197 | "depth": 0, 198 | "source": "builtin", 199 | "dependencies": { 200 | "com.unity.modules.physics2d": "1.0.0" 201 | } 202 | }, 203 | "com.unity.modules.ui": { 204 | "version": "1.0.0", 205 | "depth": 0, 206 | "source": "builtin", 207 | "dependencies": {} 208 | }, 209 | "com.unity.modules.uielements": { 210 | "version": "1.0.0", 211 | "depth": 0, 212 | "source": "builtin", 213 | "dependencies": { 214 | "com.unity.modules.ui": "1.0.0", 215 | "com.unity.modules.imgui": "1.0.0", 216 | "com.unity.modules.jsonserialize": "1.0.0", 217 | "com.unity.modules.uielementsnative": "1.0.0" 218 | } 219 | }, 220 | "com.unity.modules.uielementsnative": { 221 | "version": "1.0.0", 222 | "depth": 1, 223 | "source": "builtin", 224 | "dependencies": { 225 | "com.unity.modules.ui": "1.0.0", 226 | "com.unity.modules.imgui": "1.0.0", 227 | "com.unity.modules.jsonserialize": "1.0.0" 228 | } 229 | }, 230 | "com.unity.modules.umbra": { 231 | "version": "1.0.0", 232 | "depth": 0, 233 | "source": "builtin", 234 | "dependencies": {} 235 | }, 236 | "com.unity.modules.unityanalytics": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": { 241 | "com.unity.modules.unitywebrequest": "1.0.0", 242 | "com.unity.modules.jsonserialize": "1.0.0" 243 | } 244 | }, 245 | "com.unity.modules.unitywebrequest": { 246 | "version": "1.0.0", 247 | "depth": 0, 248 | "source": "builtin", 249 | "dependencies": {} 250 | }, 251 | "com.unity.modules.unitywebrequestassetbundle": { 252 | "version": "1.0.0", 253 | "depth": 0, 254 | "source": "builtin", 255 | "dependencies": { 256 | "com.unity.modules.assetbundle": "1.0.0", 257 | "com.unity.modules.unitywebrequest": "1.0.0" 258 | } 259 | }, 260 | "com.unity.modules.unitywebrequestaudio": { 261 | "version": "1.0.0", 262 | "depth": 0, 263 | "source": "builtin", 264 | "dependencies": { 265 | "com.unity.modules.unitywebrequest": "1.0.0", 266 | "com.unity.modules.audio": "1.0.0" 267 | } 268 | }, 269 | "com.unity.modules.unitywebrequesttexture": { 270 | "version": "1.0.0", 271 | "depth": 0, 272 | "source": "builtin", 273 | "dependencies": { 274 | "com.unity.modules.unitywebrequest": "1.0.0", 275 | "com.unity.modules.imageconversion": "1.0.0" 276 | } 277 | }, 278 | "com.unity.modules.unitywebrequestwww": { 279 | "version": "1.0.0", 280 | "depth": 0, 281 | "source": "builtin", 282 | "dependencies": { 283 | "com.unity.modules.unitywebrequest": "1.0.0", 284 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 285 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 286 | "com.unity.modules.audio": "1.0.0", 287 | "com.unity.modules.assetbundle": "1.0.0", 288 | "com.unity.modules.imageconversion": "1.0.0" 289 | } 290 | }, 291 | "com.unity.modules.vehicles": { 292 | "version": "1.0.0", 293 | "depth": 0, 294 | "source": "builtin", 295 | "dependencies": { 296 | "com.unity.modules.physics": "1.0.0" 297 | } 298 | }, 299 | "com.unity.modules.video": { 300 | "version": "1.0.0", 301 | "depth": 0, 302 | "source": "builtin", 303 | "dependencies": { 304 | "com.unity.modules.audio": "1.0.0", 305 | "com.unity.modules.ui": "1.0.0", 306 | "com.unity.modules.unitywebrequest": "1.0.0" 307 | } 308 | }, 309 | "com.unity.modules.vr": { 310 | "version": "1.0.0", 311 | "depth": 0, 312 | "source": "builtin", 313 | "dependencies": { 314 | "com.unity.modules.jsonserialize": "1.0.0", 315 | "com.unity.modules.physics": "1.0.0", 316 | "com.unity.modules.xr": "1.0.0" 317 | } 318 | }, 319 | "com.unity.modules.wind": { 320 | "version": "1.0.0", 321 | "depth": 0, 322 | "source": "builtin", 323 | "dependencies": {} 324 | }, 325 | "com.unity.modules.xr": { 326 | "version": "1.0.0", 327 | "depth": 0, 328 | "source": "builtin", 329 | "dependencies": { 330 | "com.unity.modules.physics": "1.0.0", 331 | "com.unity.modules.jsonserialize": "1.0.0", 332 | "com.unity.modules.subsystems": "1.0.0" 333 | } 334 | } 335 | } 336 | } 337 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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_EnableOutputSuspension: 1 16 | m_SpatializerPlugin: 17 | m_AmbisonicDecoderPlugin: 18 | m_DisableAudio: 0 19 | m_VirtualizeEffects: 1 20 | m_RequestedDSPBufferSize: 0 21 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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: 13 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.1 18 | m_ClothInterCollisionStiffness: 0.2 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 0 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ClothGravity: {x: 0, y: -9.81, z: 0} 26 | m_ContactPairsMode: 0 27 | m_BroadphaseType: 0 28 | m_WorldBounds: 29 | m_Center: {x: 0, y: 0, z: 0} 30 | m_Extent: {x: 250, y: 250, z: 250} 31 | m_WorldSubdivisions: 8 32 | m_FrictionType: 0 33 | m_EnableEnhancedDeterminism: 0 34 | m_EnableUnifiedHeightmaps: 1 35 | m_SolverType: 0 36 | m_DefaultMaxAngularSpeed: 50 37 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 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;asmref;rsp 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_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | m_LogWhenShaderIsCompiled: 0 64 | m_AllowEnlightenSupportForUpgradedProject: 0 65 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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_ScopedRegistriesSettingsExpanded: 1 16 | oneTimeWarningShown: 0 17 | m_Registries: 18 | - m_Id: main 19 | m_Name: 20 | m_Url: https://packages.unity.com 21 | m_Scopes: [] 22 | m_IsDefault: 1 23 | m_UserSelectedRegistryName: 24 | m_UserAddingNewScopedRegistry: 0 25 | m_RegistryInfoDraft: 26 | m_ErrorMessage: 27 | m_Original: 28 | m_Id: 29 | m_Name: 30 | m_Url: 31 | m_Scopes: [] 32 | m_IsDefault: 0 33 | m_Modified: 0 34 | m_Name: 35 | m_Url: 36 | m_Scopes: 37 | - 38 | m_SelectedScopeIndex: 0 39 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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: 0 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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 20 7 | productGUID: 8655e574d0e62e34c97478e638c17ae6 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: DefaultCompany 16 | productName: NativeMemoryArray.Unity 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 1 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_HolographicTrackingLossScreen: {fileID: 0} 45 | defaultScreenWidth: 1024 46 | defaultScreenHeight: 768 47 | defaultScreenWidthWeb: 960 48 | defaultScreenHeightWeb: 600 49 | m_StereoRenderingPath: 0 50 | m_ActiveColorSpace: 0 51 | m_MTRendering: 1 52 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 53 | iosShowActivityIndicatorOnLoading: -1 54 | androidShowActivityIndicatorOnLoading: -1 55 | iosUseCustomAppBackgroundBehavior: 0 56 | iosAllowHTTPDownload: 1 57 | allowedAutorotateToPortrait: 1 58 | allowedAutorotateToPortraitUpsideDown: 1 59 | allowedAutorotateToLandscapeRight: 1 60 | allowedAutorotateToLandscapeLeft: 1 61 | useOSAutorotation: 1 62 | use32BitDisplayBuffer: 1 63 | preserveFramebufferAlpha: 0 64 | disableDepthAndStencilBuffers: 0 65 | androidStartInFullscreen: 1 66 | androidRenderOutsideSafeArea: 1 67 | androidUseSwappy: 0 68 | androidBlitType: 0 69 | defaultIsNativeResolution: 1 70 | macRetinaSupport: 1 71 | runInBackground: 0 72 | captureSingleScreen: 0 73 | muteOtherAudioSources: 0 74 | Prepare IOS For Recording: 0 75 | Force IOS Speakers When Recording: 0 76 | deferSystemGesturesMode: 0 77 | hideHomeButton: 0 78 | submitAnalytics: 1 79 | usePlayerLog: 1 80 | bakeCollisionMeshes: 0 81 | forceSingleInstance: 0 82 | useFlipModelSwapchain: 1 83 | resizableWindow: 0 84 | useMacAppStoreValidation: 0 85 | macAppStoreCategory: public.app-category.games 86 | gpuSkinning: 0 87 | xboxPIXTextureCapture: 0 88 | xboxEnableAvatar: 0 89 | xboxEnableKinect: 0 90 | xboxEnableKinectAutoTracking: 0 91 | xboxEnableFitness: 0 92 | visibleInBackground: 1 93 | allowFullscreenSwitch: 1 94 | fullscreenMode: 1 95 | xboxSpeechDB: 0 96 | xboxEnableHeadOrientation: 0 97 | xboxEnableGuest: 0 98 | xboxEnablePIXSampling: 0 99 | metalFramebufferOnly: 0 100 | xboxOneResolution: 0 101 | xboxOneSResolution: 0 102 | xboxOneXResolution: 3 103 | xboxOneMonoLoggingLevel: 0 104 | xboxOneLoggingLevel: 1 105 | xboxOneDisableEsram: 0 106 | xboxOneEnableTypeOptimization: 0 107 | xboxOnePresentImmediateThreshold: 0 108 | switchQueueCommandMemory: 1048576 109 | switchQueueControlMemory: 16384 110 | switchQueueComputeMemory: 262144 111 | switchNVNShaderPoolsGranularity: 33554432 112 | switchNVNDefaultPoolsGranularity: 16777216 113 | switchNVNOtherPoolsGranularity: 16777216 114 | switchNVNMaxPublicTextureIDCount: 0 115 | switchNVNMaxPublicSamplerIDCount: 0 116 | stadiaPresentMode: 0 117 | stadiaTargetFramerate: 0 118 | vulkanNumSwapchainBuffers: 3 119 | vulkanEnableSetSRGBWrite: 0 120 | vulkanEnableLateAcquireNextImage: 0 121 | m_SupportedAspectRatios: 122 | 4:3: 1 123 | 5:4: 1 124 | 16:10: 1 125 | 16:9: 1 126 | Others: 1 127 | bundleVersion: 1.0 128 | preloadedAssets: [] 129 | metroInputSource: 0 130 | wsaTransparentSwapchain: 0 131 | m_HolographicPauseOnTrackingLoss: 1 132 | xboxOneDisableKinectGpuReservation: 1 133 | xboxOneEnable7thCore: 1 134 | vrSettings: 135 | cardboard: 136 | depthFormat: 0 137 | enableTransitionView: 0 138 | daydream: 139 | depthFormat: 0 140 | useSustainedPerformanceMode: 0 141 | enableVideoLayer: 0 142 | useProtectedVideoMemory: 0 143 | minimumSupportedHeadTracking: 0 144 | maximumSupportedHeadTracking: 1 145 | hololens: 146 | depthFormat: 1 147 | depthBufferSharingEnabled: 1 148 | lumin: 149 | depthFormat: 0 150 | frameTiming: 2 151 | enableGLCache: 0 152 | glCacheMaxBlobSize: 524288 153 | glCacheMaxFileSize: 8388608 154 | oculus: 155 | sharedDepthBuffer: 1 156 | dashSupport: 1 157 | lowOverheadMode: 0 158 | protectedContext: 0 159 | v2Signing: 1 160 | enable360StereoCapture: 0 161 | isWsaHolographicRemotingEnabled: 0 162 | enableFrameTimingStats: 0 163 | useHDRDisplay: 0 164 | D3DHDRBitDepth: 0 165 | m_ColorGamuts: 00000000 166 | targetPixelDensity: 0 167 | resolutionScalingMode: 0 168 | androidSupportedAspectRatio: 1 169 | androidMaxAspectRatio: 2.1 170 | applicationIdentifier: {} 171 | buildNumber: {} 172 | AndroidBundleVersionCode: 1 173 | AndroidMinSdkVersion: 19 174 | AndroidTargetSdkVersion: 0 175 | AndroidPreferredInstallLocation: 1 176 | aotOptions: 177 | stripEngineCode: 1 178 | iPhoneStrippingLevel: 0 179 | iPhoneScriptCallOptimization: 0 180 | ForceInternetPermission: 0 181 | ForceSDCardPermission: 0 182 | CreateWallpaper: 0 183 | APKExpansionFiles: 0 184 | keepLoadedShadersAlive: 0 185 | StripUnusedMeshComponents: 0 186 | VertexChannelCompressionMask: 4054 187 | iPhoneSdkVersion: 988 188 | iOSTargetOSVersionString: 189 | tvOSSdkVersion: 0 190 | tvOSRequireExtendedGameController: 0 191 | tvOSTargetOSVersionString: 192 | uIPrerenderedIcon: 0 193 | uIRequiresPersistentWiFi: 0 194 | uIRequiresFullScreen: 1 195 | uIStatusBarHidden: 1 196 | uIExitOnSuspend: 0 197 | uIStatusBarStyle: 0 198 | appleTVSplashScreen: {fileID: 0} 199 | appleTVSplashScreen2x: {fileID: 0} 200 | tvOSSmallIconLayers: [] 201 | tvOSSmallIconLayers2x: [] 202 | tvOSLargeIconLayers: [] 203 | tvOSLargeIconLayers2x: [] 204 | tvOSTopShelfImageLayers: [] 205 | tvOSTopShelfImageLayers2x: [] 206 | tvOSTopShelfImageWideLayers: [] 207 | tvOSTopShelfImageWideLayers2x: [] 208 | iOSLaunchScreenType: 0 209 | iOSLaunchScreenPortrait: {fileID: 0} 210 | iOSLaunchScreenLandscape: {fileID: 0} 211 | iOSLaunchScreenBackgroundColor: 212 | serializedVersion: 2 213 | rgba: 0 214 | iOSLaunchScreenFillPct: 100 215 | iOSLaunchScreenSize: 100 216 | iOSLaunchScreenCustomXibPath: 217 | iOSLaunchScreeniPadType: 0 218 | iOSLaunchScreeniPadImage: {fileID: 0} 219 | iOSLaunchScreeniPadBackgroundColor: 220 | serializedVersion: 2 221 | rgba: 0 222 | iOSLaunchScreeniPadFillPct: 100 223 | iOSLaunchScreeniPadSize: 100 224 | iOSLaunchScreeniPadCustomXibPath: 225 | iOSUseLaunchScreenStoryboard: 0 226 | iOSLaunchScreenCustomStoryboardPath: 227 | iOSDeviceRequirements: [] 228 | iOSURLSchemes: [] 229 | iOSBackgroundModes: 0 230 | iOSMetalForceHardShadows: 0 231 | metalEditorSupport: 1 232 | metalAPIValidation: 1 233 | iOSRenderExtraFrameOnPause: 0 234 | iosCopyPluginsCodeInsteadOfSymlink: 0 235 | appleDeveloperTeamID: 236 | iOSManualSigningProvisioningProfileID: 237 | tvOSManualSigningProvisioningProfileID: 238 | iOSManualSigningProvisioningProfileType: 0 239 | tvOSManualSigningProvisioningProfileType: 0 240 | appleEnableAutomaticSigning: 0 241 | iOSRequireARKit: 0 242 | iOSAutomaticallyDetectAndAddCapabilities: 1 243 | appleEnableProMotion: 0 244 | clonedFromGUID: 00000000000000000000000000000000 245 | templatePackageId: 246 | templateDefaultScene: 247 | AndroidTargetArchitectures: 1 248 | AndroidSplashScreenScale: 0 249 | androidSplashScreen: {fileID: 0} 250 | AndroidKeystoreName: 251 | AndroidKeyaliasName: 252 | AndroidBuildApkPerCpuArchitecture: 0 253 | AndroidTVCompatibility: 0 254 | AndroidIsGame: 1 255 | AndroidEnableTango: 0 256 | androidEnableBanner: 1 257 | androidUseLowAccuracyLocation: 0 258 | androidUseCustomKeystore: 0 259 | m_AndroidBanners: 260 | - width: 320 261 | height: 180 262 | banner: {fileID: 0} 263 | androidGamepadSupportLevel: 0 264 | AndroidValidateAppBundleSize: 1 265 | AndroidAppBundleSizeToValidate: 150 266 | m_BuildTargetIcons: [] 267 | m_BuildTargetPlatformIcons: [] 268 | m_BuildTargetBatching: [] 269 | m_BuildTargetGraphicsJobs: [] 270 | m_BuildTargetGraphicsJobMode: [] 271 | m_BuildTargetGraphicsAPIs: [] 272 | m_BuildTargetVRSettings: [] 273 | openGLRequireES31: 0 274 | openGLRequireES31AEP: 0 275 | openGLRequireES32: 0 276 | m_TemplateCustomTags: {} 277 | mobileMTRendering: 278 | Android: 1 279 | iPhone: 1 280 | tvOS: 1 281 | m_BuildTargetGroupLightmapEncodingQuality: [] 282 | m_BuildTargetGroupLightmapSettings: [] 283 | playModeTestRunnerEnabled: 0 284 | runPlayModeTestAsEditModeTest: 0 285 | actionOnDotNetUnhandledException: 1 286 | enableInternalProfiler: 0 287 | logObjCUncaughtExceptions: 1 288 | enableCrashReportAPI: 0 289 | cameraUsageDescription: 290 | locationUsageDescription: 291 | microphoneUsageDescription: 292 | switchNetLibKey: 293 | switchSocketMemoryPoolSize: 6144 294 | switchSocketAllocatorPoolSize: 128 295 | switchSocketConcurrencyLimit: 14 296 | switchScreenResolutionBehavior: 2 297 | switchUseCPUProfiler: 0 298 | switchApplicationID: 0x01004b9000490000 299 | switchNSODependencies: 300 | switchTitleNames_0: 301 | switchTitleNames_1: 302 | switchTitleNames_2: 303 | switchTitleNames_3: 304 | switchTitleNames_4: 305 | switchTitleNames_5: 306 | switchTitleNames_6: 307 | switchTitleNames_7: 308 | switchTitleNames_8: 309 | switchTitleNames_9: 310 | switchTitleNames_10: 311 | switchTitleNames_11: 312 | switchTitleNames_12: 313 | switchTitleNames_13: 314 | switchTitleNames_14: 315 | switchTitleNames_15: 316 | switchPublisherNames_0: 317 | switchPublisherNames_1: 318 | switchPublisherNames_2: 319 | switchPublisherNames_3: 320 | switchPublisherNames_4: 321 | switchPublisherNames_5: 322 | switchPublisherNames_6: 323 | switchPublisherNames_7: 324 | switchPublisherNames_8: 325 | switchPublisherNames_9: 326 | switchPublisherNames_10: 327 | switchPublisherNames_11: 328 | switchPublisherNames_12: 329 | switchPublisherNames_13: 330 | switchPublisherNames_14: 331 | switchPublisherNames_15: 332 | switchIcons_0: {fileID: 0} 333 | switchIcons_1: {fileID: 0} 334 | switchIcons_2: {fileID: 0} 335 | switchIcons_3: {fileID: 0} 336 | switchIcons_4: {fileID: 0} 337 | switchIcons_5: {fileID: 0} 338 | switchIcons_6: {fileID: 0} 339 | switchIcons_7: {fileID: 0} 340 | switchIcons_8: {fileID: 0} 341 | switchIcons_9: {fileID: 0} 342 | switchIcons_10: {fileID: 0} 343 | switchIcons_11: {fileID: 0} 344 | switchIcons_12: {fileID: 0} 345 | switchIcons_13: {fileID: 0} 346 | switchIcons_14: {fileID: 0} 347 | switchIcons_15: {fileID: 0} 348 | switchSmallIcons_0: {fileID: 0} 349 | switchSmallIcons_1: {fileID: 0} 350 | switchSmallIcons_2: {fileID: 0} 351 | switchSmallIcons_3: {fileID: 0} 352 | switchSmallIcons_4: {fileID: 0} 353 | switchSmallIcons_5: {fileID: 0} 354 | switchSmallIcons_6: {fileID: 0} 355 | switchSmallIcons_7: {fileID: 0} 356 | switchSmallIcons_8: {fileID: 0} 357 | switchSmallIcons_9: {fileID: 0} 358 | switchSmallIcons_10: {fileID: 0} 359 | switchSmallIcons_11: {fileID: 0} 360 | switchSmallIcons_12: {fileID: 0} 361 | switchSmallIcons_13: {fileID: 0} 362 | switchSmallIcons_14: {fileID: 0} 363 | switchSmallIcons_15: {fileID: 0} 364 | switchManualHTML: 365 | switchAccessibleURLs: 366 | switchLegalInformation: 367 | switchMainThreadStackSize: 1048576 368 | switchPresenceGroupId: 369 | switchLogoHandling: 0 370 | switchReleaseVersion: 0 371 | switchDisplayVersion: 1.0.0 372 | switchStartupUserAccount: 0 373 | switchTouchScreenUsage: 0 374 | switchSupportedLanguagesMask: 0 375 | switchLogoType: 0 376 | switchApplicationErrorCodeCategory: 377 | switchUserAccountSaveDataSize: 0 378 | switchUserAccountSaveDataJournalSize: 0 379 | switchApplicationAttribute: 0 380 | switchCardSpecSize: -1 381 | switchCardSpecClock: -1 382 | switchRatingsMask: 0 383 | switchRatingsInt_0: 0 384 | switchRatingsInt_1: 0 385 | switchRatingsInt_2: 0 386 | switchRatingsInt_3: 0 387 | switchRatingsInt_4: 0 388 | switchRatingsInt_5: 0 389 | switchRatingsInt_6: 0 390 | switchRatingsInt_7: 0 391 | switchRatingsInt_8: 0 392 | switchRatingsInt_9: 0 393 | switchRatingsInt_10: 0 394 | switchRatingsInt_11: 0 395 | switchRatingsInt_12: 0 396 | switchLocalCommunicationIds_0: 397 | switchLocalCommunicationIds_1: 398 | switchLocalCommunicationIds_2: 399 | switchLocalCommunicationIds_3: 400 | switchLocalCommunicationIds_4: 401 | switchLocalCommunicationIds_5: 402 | switchLocalCommunicationIds_6: 403 | switchLocalCommunicationIds_7: 404 | switchParentalControl: 0 405 | switchAllowsScreenshot: 1 406 | switchAllowsVideoCapturing: 1 407 | switchAllowsRuntimeAddOnContentInstall: 0 408 | switchDataLossConfirmation: 0 409 | switchUserAccountLockEnabled: 0 410 | switchSystemResourceMemory: 16777216 411 | switchSupportedNpadStyles: 22 412 | switchNativeFsCacheSize: 32 413 | switchIsHoldTypeHorizontal: 0 414 | switchSupportedNpadCount: 8 415 | switchSocketConfigEnabled: 0 416 | switchTcpInitialSendBufferSize: 32 417 | switchTcpInitialReceiveBufferSize: 64 418 | switchTcpAutoSendBufferSizeMax: 256 419 | switchTcpAutoReceiveBufferSizeMax: 256 420 | switchUdpSendBufferSize: 9 421 | switchUdpReceiveBufferSize: 42 422 | switchSocketBufferEfficiency: 4 423 | switchSocketInitializeEnabled: 1 424 | switchNetworkInterfaceManagerInitializeEnabled: 1 425 | switchPlayerConnectionEnabled: 1 426 | switchUseMicroSleepForYield: 1 427 | switchMicroSleepForYieldTime: 25 428 | ps4NPAgeRating: 12 429 | ps4NPTitleSecret: 430 | ps4NPTrophyPackPath: 431 | ps4ParentalLevel: 11 432 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 433 | ps4Category: 0 434 | ps4MasterVersion: 01.00 435 | ps4AppVersion: 01.00 436 | ps4AppType: 0 437 | ps4ParamSfxPath: 438 | ps4VideoOutPixelFormat: 0 439 | ps4VideoOutInitialWidth: 1920 440 | ps4VideoOutBaseModeInitialWidth: 1920 441 | ps4VideoOutReprojectionRate: 60 442 | ps4PronunciationXMLPath: 443 | ps4PronunciationSIGPath: 444 | ps4BackgroundImagePath: 445 | ps4StartupImagePath: 446 | ps4StartupImagesFolder: 447 | ps4IconImagesFolder: 448 | ps4SaveDataImagePath: 449 | ps4SdkOverride: 450 | ps4BGMPath: 451 | ps4ShareFilePath: 452 | ps4ShareOverlayImagePath: 453 | ps4PrivacyGuardImagePath: 454 | ps4ExtraSceSysFile: 455 | ps4NPtitleDatPath: 456 | ps4RemotePlayKeyAssignment: -1 457 | ps4RemotePlayKeyMappingDir: 458 | ps4PlayTogetherPlayerCount: 0 459 | ps4EnterButtonAssignment: 2 460 | ps4ApplicationParam1: 0 461 | ps4ApplicationParam2: 0 462 | ps4ApplicationParam3: 0 463 | ps4ApplicationParam4: 0 464 | ps4DownloadDataSize: 0 465 | ps4GarlicHeapSize: 2048 466 | ps4ProGarlicHeapSize: 2560 467 | playerPrefsMaxSize: 32768 468 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 469 | ps4pnSessions: 1 470 | ps4pnPresence: 1 471 | ps4pnFriends: 1 472 | ps4pnGameCustomData: 1 473 | playerPrefsSupport: 0 474 | enableApplicationExit: 0 475 | resetTempFolder: 1 476 | restrictedAudioUsageRights: 0 477 | ps4UseResolutionFallback: 0 478 | ps4ReprojectionSupport: 0 479 | ps4UseAudio3dBackend: 0 480 | ps4UseLowGarlicFragmentationMode: 1 481 | ps4SocialScreenEnabled: 0 482 | ps4ScriptOptimizationLevel: 2 483 | ps4Audio3dVirtualSpeakerCount: 14 484 | ps4attribCpuUsage: 0 485 | ps4PatchPkgPath: 486 | ps4PatchLatestPkgPath: 487 | ps4PatchChangeinfoPath: 488 | ps4PatchDayOne: 0 489 | ps4attribUserManagement: 0 490 | ps4attribMoveSupport: 0 491 | ps4attrib3DSupport: 0 492 | ps4attribShareSupport: 0 493 | ps4attribExclusiveVR: 0 494 | ps4disableAutoHideSplash: 0 495 | ps4videoRecordingFeaturesUsed: 0 496 | ps4contentSearchFeaturesUsed: 0 497 | ps4CompatibilityPS5: 0 498 | ps4GPU800MHz: 1 499 | ps4attribEyeToEyeDistanceSettingVR: 0 500 | ps4IncludedModules: [] 501 | ps4attribVROutputEnabled: 0 502 | ps5ParamFilePath: 503 | ps5VideoOutPixelFormat: 0 504 | ps5VideoOutInitialWidth: 1920 505 | ps5VideoOutOutputMode: 1 506 | ps5BackgroundImagePath: 507 | ps5StartupImagePath: 508 | ps5Pic2Path: 509 | ps5StartupImagesFolder: 510 | ps5IconImagesFolder: 511 | ps5SaveDataImagePath: 512 | ps5SdkOverride: 513 | ps5BGMPath: 514 | ps5ShareOverlayImagePath: 515 | ps5NPConfigZipPath: 516 | ps5Passcode: F69AzBlax3CF3EDNhm3soLBPh71Yexui 517 | ps5UseResolutionFallback: 0 518 | ps5UseAudio3dBackend: 0 519 | ps5ScriptOptimizationLevel: 2 520 | ps5Audio3dVirtualSpeakerCount: 14 521 | ps5UpdateReferencePackage: 522 | ps5disableAutoHideSplash: 0 523 | ps5OperatingSystemCanDisableSplashScreen: 0 524 | ps5IncludedModules: [] 525 | ps5SharedBinaryContentLabels: [] 526 | ps5SharedBinarySystemFolders: [] 527 | monoEnv: 528 | splashScreenBackgroundSourceLandscape: {fileID: 0} 529 | splashScreenBackgroundSourcePortrait: {fileID: 0} 530 | blurSplashScreenBackground: 1 531 | spritePackerPolicy: 532 | webGLMemorySize: 32 533 | webGLExceptionSupport: 1 534 | webGLNameFilesAsHashes: 0 535 | webGLDataCaching: 1 536 | webGLDebugSymbols: 0 537 | webGLEmscriptenArgs: 538 | webGLModulesDirectory: 539 | webGLTemplate: APPLICATION:Default 540 | webGLAnalyzeBuildSize: 0 541 | webGLUseEmbeddedResources: 0 542 | webGLCompressionFormat: 0 543 | webGLLinkerTarget: 1 544 | webGLThreadsSupport: 0 545 | webGLWasmStreaming: 0 546 | scriptingDefineSymbols: {} 547 | platformArchitecture: {} 548 | scriptingBackend: {} 549 | il2cppCompilerConfiguration: {} 550 | managedStrippingLevel: {} 551 | incrementalIl2cppBuild: {} 552 | allowUnsafeCode: 0 553 | additionalIl2CppArgs: 554 | scriptingRuntimeVersion: 1 555 | gcIncremental: 0 556 | assemblyVersionValidation: 1 557 | gcWBarrierValidation: 0 558 | apiCompatibilityLevelPerPlatform: {} 559 | m_RenderingPath: 1 560 | m_MobileRenderingPath: 1 561 | metroPackageName: NativeMemoryArray.Unity 562 | metroPackageVersion: 563 | metroCertificatePath: 564 | metroCertificatePassword: 565 | metroCertificateSubject: 566 | metroCertificateIssuer: 567 | metroCertificateNotAfter: 0000000000000000 568 | metroApplicationDescription: NativeMemoryArray.Unity 569 | wsaImages: {} 570 | metroTileShortName: 571 | metroTileShowName: 0 572 | metroMediumTileShowName: 0 573 | metroLargeTileShowName: 0 574 | metroWideTileShowName: 0 575 | metroSupportStreamingInstall: 0 576 | metroLastRequiredScene: 0 577 | metroDefaultTileSize: 1 578 | metroTileForegroundText: 2 579 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 580 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 581 | a: 1} 582 | metroSplashScreenUseBackgroundColor: 0 583 | platformCapabilities: {} 584 | metroTargetDeviceFamilies: {} 585 | metroFTAName: 586 | metroFTAFileTypes: [] 587 | metroProtocolName: 588 | XboxOneProductId: 589 | XboxOneUpdateKey: 590 | XboxOneSandboxId: 591 | XboxOneContentId: 592 | XboxOneTitleId: 593 | XboxOneSCId: 594 | XboxOneGameOsOverridePath: 595 | XboxOnePackagingOverridePath: 596 | XboxOneAppManifestOverridePath: 597 | XboxOneVersion: 1.0.0.0 598 | XboxOnePackageEncryption: 0 599 | XboxOnePackageUpdateGranularity: 2 600 | XboxOneDescription: 601 | XboxOneLanguage: 602 | - enus 603 | XboxOneCapability: [] 604 | XboxOneGameRating: {} 605 | XboxOneIsContentPackage: 0 606 | XboxOneEnhancedXboxCompatibilityMode: 0 607 | XboxOneEnableGPUVariability: 1 608 | XboxOneSockets: {} 609 | XboxOneSplashScreen: {fileID: 0} 610 | XboxOneAllowedProductIds: [] 611 | XboxOnePersistentLocalStorageSize: 0 612 | XboxOneXTitleMemory: 8 613 | XboxOneOverrideIdentityName: 614 | XboxOneOverrideIdentityPublisher: 615 | vrEditorSettings: 616 | daydream: 617 | daydreamIconForeground: {fileID: 0} 618 | daydreamIconBackground: {fileID: 0} 619 | cloudServicesEnabled: {} 620 | luminIcon: 621 | m_Name: 622 | m_ModelFolderPath: 623 | m_PortalFolderPath: 624 | luminCert: 625 | m_CertPath: 626 | m_SignPackage: 1 627 | luminIsChannelApp: 0 628 | luminVersion: 629 | m_VersionCode: 1 630 | m_VersionName: 631 | apiCompatibilityLevel: 6 632 | cloudProjectId: 633 | framebufferDepthMemorylessMode: 0 634 | projectName: 635 | organizationId: 636 | cloudEnabled: 0 637 | enableNativePlatformBackendsForNewInputSystem: 0 638 | disableOldInputManagerSupport: 0 639 | legacyClampBlendShapeWeights: 0 640 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.2.1f1 2 | m_EditorVersionWithRevision: 2020.2.1f1 (270dd8c3da1c) 3 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | skinWeights: 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 | customRenderPipeline: {fileID: 0} 44 | excludedTargetPlatforms: [] 45 | - serializedVersion: 2 46 | name: Low 47 | pixelLightCount: 0 48 | shadows: 0 49 | shadowResolution: 0 50 | shadowProjection: 1 51 | shadowCascades: 1 52 | shadowDistance: 20 53 | shadowNearPlaneOffset: 3 54 | shadowCascade2Split: 0.33333334 55 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 56 | shadowmaskMode: 0 57 | skinWeights: 2 58 | textureQuality: 0 59 | anisotropicTextures: 0 60 | antiAliasing: 0 61 | softParticles: 0 62 | softVegetation: 0 63 | realtimeReflectionProbes: 0 64 | billboardsFaceCameraPosition: 0 65 | vSyncCount: 0 66 | lodBias: 0.4 67 | maximumLODLevel: 0 68 | streamingMipmapsActive: 0 69 | streamingMipmapsAddAllCameras: 1 70 | streamingMipmapsMemoryBudget: 512 71 | streamingMipmapsRenderersPerFrame: 512 72 | streamingMipmapsMaxLevelReduction: 2 73 | streamingMipmapsMaxFileIORequests: 1024 74 | particleRaycastBudget: 16 75 | asyncUploadTimeSlice: 2 76 | asyncUploadBufferSize: 16 77 | asyncUploadPersistentBuffer: 1 78 | resolutionScalingFixedDPIFactor: 1 79 | customRenderPipeline: {fileID: 0} 80 | excludedTargetPlatforms: [] 81 | - serializedVersion: 2 82 | name: Medium 83 | pixelLightCount: 1 84 | shadows: 1 85 | shadowResolution: 0 86 | shadowProjection: 1 87 | shadowCascades: 1 88 | shadowDistance: 20 89 | shadowNearPlaneOffset: 3 90 | shadowCascade2Split: 0.33333334 91 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 92 | shadowmaskMode: 0 93 | skinWeights: 2 94 | textureQuality: 0 95 | anisotropicTextures: 1 96 | antiAliasing: 0 97 | softParticles: 0 98 | softVegetation: 0 99 | realtimeReflectionProbes: 0 100 | billboardsFaceCameraPosition: 0 101 | vSyncCount: 1 102 | lodBias: 0.7 103 | maximumLODLevel: 0 104 | streamingMipmapsActive: 0 105 | streamingMipmapsAddAllCameras: 1 106 | streamingMipmapsMemoryBudget: 512 107 | streamingMipmapsRenderersPerFrame: 512 108 | streamingMipmapsMaxLevelReduction: 2 109 | streamingMipmapsMaxFileIORequests: 1024 110 | particleRaycastBudget: 64 111 | asyncUploadTimeSlice: 2 112 | asyncUploadBufferSize: 16 113 | asyncUploadPersistentBuffer: 1 114 | resolutionScalingFixedDPIFactor: 1 115 | customRenderPipeline: {fileID: 0} 116 | excludedTargetPlatforms: [] 117 | - serializedVersion: 2 118 | name: High 119 | pixelLightCount: 2 120 | shadows: 2 121 | shadowResolution: 1 122 | shadowProjection: 1 123 | shadowCascades: 2 124 | shadowDistance: 40 125 | shadowNearPlaneOffset: 3 126 | shadowCascade2Split: 0.33333334 127 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 128 | shadowmaskMode: 1 129 | skinWeights: 2 130 | textureQuality: 0 131 | anisotropicTextures: 1 132 | antiAliasing: 0 133 | softParticles: 0 134 | softVegetation: 1 135 | realtimeReflectionProbes: 1 136 | billboardsFaceCameraPosition: 1 137 | vSyncCount: 1 138 | lodBias: 1 139 | maximumLODLevel: 0 140 | streamingMipmapsActive: 0 141 | streamingMipmapsAddAllCameras: 1 142 | streamingMipmapsMemoryBudget: 512 143 | streamingMipmapsRenderersPerFrame: 512 144 | streamingMipmapsMaxLevelReduction: 2 145 | streamingMipmapsMaxFileIORequests: 1024 146 | particleRaycastBudget: 256 147 | asyncUploadTimeSlice: 2 148 | asyncUploadBufferSize: 16 149 | asyncUploadPersistentBuffer: 1 150 | resolutionScalingFixedDPIFactor: 1 151 | customRenderPipeline: {fileID: 0} 152 | excludedTargetPlatforms: [] 153 | - serializedVersion: 2 154 | name: Very High 155 | pixelLightCount: 3 156 | shadows: 2 157 | shadowResolution: 2 158 | shadowProjection: 1 159 | shadowCascades: 2 160 | shadowDistance: 70 161 | shadowNearPlaneOffset: 3 162 | shadowCascade2Split: 0.33333334 163 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 164 | shadowmaskMode: 1 165 | skinWeights: 4 166 | textureQuality: 0 167 | anisotropicTextures: 2 168 | antiAliasing: 2 169 | softParticles: 1 170 | softVegetation: 1 171 | realtimeReflectionProbes: 1 172 | billboardsFaceCameraPosition: 1 173 | vSyncCount: 1 174 | lodBias: 1.5 175 | maximumLODLevel: 0 176 | streamingMipmapsActive: 0 177 | streamingMipmapsAddAllCameras: 1 178 | streamingMipmapsMemoryBudget: 512 179 | streamingMipmapsRenderersPerFrame: 512 180 | streamingMipmapsMaxLevelReduction: 2 181 | streamingMipmapsMaxFileIORequests: 1024 182 | particleRaycastBudget: 1024 183 | asyncUploadTimeSlice: 2 184 | asyncUploadBufferSize: 16 185 | asyncUploadPersistentBuffer: 1 186 | resolutionScalingFixedDPIFactor: 1 187 | customRenderPipeline: {fileID: 0} 188 | excludedTargetPlatforms: [] 189 | - serializedVersion: 2 190 | name: Ultra 191 | pixelLightCount: 4 192 | shadows: 2 193 | shadowResolution: 2 194 | shadowProjection: 1 195 | shadowCascades: 4 196 | shadowDistance: 150 197 | shadowNearPlaneOffset: 3 198 | shadowCascade2Split: 0.33333334 199 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 200 | shadowmaskMode: 1 201 | skinWeights: 255 202 | textureQuality: 0 203 | anisotropicTextures: 2 204 | antiAliasing: 2 205 | softParticles: 1 206 | softVegetation: 1 207 | realtimeReflectionProbes: 1 208 | billboardsFaceCameraPosition: 1 209 | vSyncCount: 1 210 | lodBias: 2 211 | maximumLODLevel: 0 212 | streamingMipmapsActive: 0 213 | streamingMipmapsAddAllCameras: 1 214 | streamingMipmapsMemoryBudget: 512 215 | streamingMipmapsRenderersPerFrame: 512 216 | streamingMipmapsMaxLevelReduction: 2 217 | streamingMipmapsMaxFileIORequests: 1024 218 | particleRaycastBudget: 4096 219 | asyncUploadTimeSlice: 2 220 | asyncUploadBufferSize: 16 221 | asyncUploadPersistentBuffer: 1 222 | resolutionScalingFixedDPIFactor: 1 223 | customRenderPipeline: {fileID: 0} 224 | excludedTargetPlatforms: [] 225 | m_PerPlatformDefaultQuality: 226 | Android: 2 227 | CloudRendering: 5 228 | GameCoreScarlett: 5 229 | GameCoreXboxOne: 5 230 | Lumin: 5 231 | Nintendo Switch: 5 232 | PS4: 5 233 | PS5: 5 234 | Stadia: 5 235 | Standalone: 5 236 | WebGL: 3 237 | Windows Store Apps: 5 238 | XboxOne: 5 239 | iPhone: 2 240 | tvOS: 2 241 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/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 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray.Unity/UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedSceneGuid-0: 9 | value: 515250075c0c595e5f5a5e71122159444e4e4a2f7a7d7f602f284d66b4b76661 10 | flags: 0 11 | vcSharedLogLevel: 12 | value: 0d5e400f0650 13 | flags: 0 14 | m_VCAutomaticAdd: 1 15 | m_VCDebugCom: 0 16 | m_VCDebugCmd: 0 17 | m_VCDebugOut: 0 18 | m_SemanticMergeMode: 2 19 | m_DesiredImportWorkerCount: 9 20 | m_StandbyImportWorkerCount: 2 21 | m_IdleImportWorkerShutdownDelay: 60000 22 | m_VCShowFailedCheckout: 1 23 | m_VCOverwriteFailedCheckoutAssets: 1 24 | m_VCProjectOverlayIcons: 1 25 | m_VCHierarchyOverlayIcons: 1 26 | m_VCOtherOverlayIcons: 1 27 | m_VCAllowAsyncUpdate: 1 28 | m_ArtifactGarbageCollection: 1 29 | -------------------------------------------------------------------------------- /src/NativeMemoryArray/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cysharp/NativeMemoryArray/d8a3290788ff765f423e4105d2587191f8e45672/src/NativeMemoryArray/Icon.png -------------------------------------------------------------------------------- /src/NativeMemoryArray/NativeMemoryArray.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | using System; 4 | using System.Buffers; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.IO; 8 | using System.Runtime.CompilerServices; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace Cysharp.Collections 12 | { 13 | [DebuggerTypeProxy(typeof(NativeMemoryArrayDebugView<>))] 14 | public sealed unsafe class NativeMemoryArray : IDisposable 15 | where T : unmanaged 16 | { 17 | public static readonly NativeMemoryArray Empty; 18 | 19 | readonly long length; 20 | readonly bool addMemoryPressure; 21 | internal readonly byte* buffer; 22 | bool isDisposed; 23 | bool isStolen; 24 | 25 | public long Length => length; 26 | 27 | static NativeMemoryArray() 28 | { 29 | Empty = new NativeMemoryArray(0); 30 | Empty.Dispose(); 31 | } 32 | 33 | public NativeMemoryArray(long length, bool skipZeroClear = false, bool addMemoryPressure = false) 34 | { 35 | this.length = length; 36 | this.addMemoryPressure = addMemoryPressure; 37 | 38 | if (length == 0) 39 | { 40 | #if UNITY_2019_1_OR_NEWER 41 | buffer = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(null)); 42 | #else 43 | buffer = (byte*)Unsafe.AsPointer(ref Unsafe.NullRef()); 44 | #endif 45 | } 46 | else 47 | { 48 | var allocSize = length * Unsafe.SizeOf(); 49 | #if NET6_0_OR_GREATER 50 | if (skipZeroClear) 51 | { 52 | buffer = (byte*)NativeMemory.Alloc(checked((nuint)length), (nuint)Unsafe.SizeOf()); 53 | } 54 | else 55 | { 56 | buffer = (byte*)NativeMemory.AllocZeroed(checked((nuint)length), (nuint)Unsafe.SizeOf()); 57 | } 58 | #else 59 | buffer = (byte*)Marshal.AllocHGlobal((IntPtr)allocSize); 60 | if (!skipZeroClear) 61 | { 62 | foreach (var span in this) 63 | { 64 | span.Clear(); 65 | } 66 | } 67 | #endif 68 | if (addMemoryPressure) 69 | { 70 | GC.AddMemoryPressure(allocSize); 71 | } 72 | } 73 | } 74 | 75 | public ref T this[long index] 76 | { 77 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 78 | get 79 | { 80 | if ((ulong)index >= (ulong)length) ThrowHelper.ThrowIndexOutOfRangeException(); 81 | var memoryIndex = index * Unsafe.SizeOf(); 82 | return ref Unsafe.AsRef(buffer + memoryIndex); 83 | } 84 | } 85 | 86 | public Span AsSpan() 87 | { 88 | return AsSpan(0); 89 | } 90 | 91 | public Span AsSpan(long start) 92 | { 93 | if ((ulong)start > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(start)); 94 | return AsSpan(start, checked((int)(length - start))); 95 | } 96 | 97 | public Span AsSpan(long start, int length) 98 | { 99 | if ((ulong)(start + length) > (ulong)this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 100 | return new Span(buffer + start * Unsafe.SizeOf(), length); 101 | } 102 | 103 | public Memory AsMemory() 104 | { 105 | return AsMemory(0); 106 | } 107 | 108 | public Memory AsMemory(long start) 109 | { 110 | if ((ulong)start > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(start)); 111 | return AsMemory(start, checked((int)(length - start))); 112 | } 113 | 114 | public Memory AsMemory(long start, int length) 115 | { 116 | if ((ulong)(start + length) > (ulong)(this.length)) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 117 | return new PointerMemoryManager(buffer + start * Unsafe.SizeOf(), length).Memory; 118 | } 119 | 120 | public Stream AsStream() 121 | { 122 | return new UnmanagedMemoryStream(buffer, length * Unsafe.SizeOf()); 123 | } 124 | 125 | public Stream AsStream(long offset) 126 | { 127 | if ((ulong)offset > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 128 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), length * Unsafe.SizeOf()); 129 | } 130 | 131 | public Stream AsStream(FileAccess fileAccess) 132 | { 133 | var len = length * Unsafe.SizeOf(); 134 | return new UnmanagedMemoryStream(buffer, len, len, fileAccess); 135 | } 136 | 137 | public Stream AsStream(long offset, FileAccess fileAccess) 138 | { 139 | if ((ulong)offset > (ulong)length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 140 | var len = length * Unsafe.SizeOf(); 141 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), len, len, fileAccess); 142 | } 143 | 144 | public Stream AsStream(long offset, long length) 145 | { 146 | if ((ulong)offset > (ulong)this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 147 | if (offset + length > this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 148 | 149 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), length * Unsafe.SizeOf()); 150 | } 151 | 152 | public Stream AsStream(long offset, long length, FileAccess fileAccess) 153 | { 154 | if ((ulong)offset > (ulong)this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(offset)); 155 | if (offset + length > this.length) ThrowHelper.ThrowArgumentOutOfRangeException(nameof(length)); 156 | 157 | var len = length * Unsafe.SizeOf(); 158 | return new UnmanagedMemoryStream(buffer + offset * Unsafe.SizeOf(), len, len, fileAccess); 159 | } 160 | 161 | public ref T GetPinnableReference() 162 | { 163 | if (length == 0) 164 | { 165 | #if UNITY_2019_1_OR_NEWER 166 | return ref Unsafe.AsRef(null); 167 | #else 168 | return ref Unsafe.NullRef(); 169 | #endif 170 | } 171 | return ref this[0]; 172 | } 173 | 174 | public byte* StealPointer() 175 | { 176 | isStolen = true; 177 | return buffer; 178 | } 179 | 180 | public bool TryGetFullSpan(out Span span) 181 | { 182 | if (length < int.MaxValue) 183 | { 184 | span = new Span(buffer, (int)length); 185 | return true; 186 | } 187 | else 188 | { 189 | span = default; 190 | return false; 191 | } 192 | } 193 | 194 | public IBufferWriter CreateBufferWriter() 195 | { 196 | return new NativeMemoryArrayBufferWriter(this); 197 | } 198 | 199 | public SpanSequence AsSpanSequence(int chunkSize = int.MaxValue) 200 | { 201 | return new SpanSequence(this, chunkSize); 202 | } 203 | 204 | public MemorySequence AsMemorySequence(int chunkSize = int.MaxValue) 205 | { 206 | return new MemorySequence(this, chunkSize); 207 | } 208 | 209 | public IReadOnlyList> AsMemoryList(int chunkSize = int.MaxValue) 210 | { 211 | if (length == 0) return Array.Empty>(); 212 | 213 | var array = new Memory[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 214 | { 215 | var i = 0; 216 | foreach (var item in AsMemorySequence(chunkSize)) 217 | { 218 | array[i++] = item; 219 | } 220 | } 221 | 222 | return array; 223 | } 224 | 225 | public IReadOnlyList> AsReadOnlyMemoryList(int chunkSize = int.MaxValue) 226 | { 227 | if (length == 0) return Array.Empty>(); 228 | 229 | var array = new ReadOnlyMemory[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 230 | { 231 | var i = 0; 232 | foreach (var item in AsMemorySequence(chunkSize)) 233 | { 234 | array[i++] = item; 235 | } 236 | } 237 | 238 | return array; 239 | } 240 | 241 | public ReadOnlySequence AsReadOnlySequence(int chunkSize = int.MaxValue) 242 | { 243 | if (length == 0) return ReadOnlySequence.Empty; 244 | 245 | var array = new Segment[(long)length <= chunkSize ? 1 : (long)length / chunkSize + 1]; 246 | { 247 | var i = 0; 248 | foreach (var item in AsMemorySequence(chunkSize)) 249 | { 250 | array[i++] = new Segment(item); 251 | } 252 | } 253 | 254 | long running = 0; 255 | for (int i = 0; i < array.Length; i++) 256 | { 257 | var next = i < array.Length - 1 ? array[i + 1] : null; 258 | array[i].SetRunningIndexAndNext(running, next); 259 | running += array[i].Memory.Length; 260 | } 261 | 262 | var firstSegment = array[0]; 263 | var lastSegment = array[array.Length - 1]; 264 | return new ReadOnlySequence(firstSegment, 0, lastSegment, lastSegment.Memory.Length); 265 | } 266 | 267 | public SpanSequence GetEnumerator() 268 | { 269 | return AsSpanSequence(int.MaxValue); 270 | } 271 | 272 | public override string ToString() 273 | { 274 | return typeof(T).Name + "[" + length + "]"; 275 | } 276 | 277 | public void Dispose() 278 | { 279 | DisposeCore(); 280 | GC.SuppressFinalize(this); 281 | } 282 | 283 | void DisposeCore() 284 | { 285 | if (!isDisposed && !isStolen) 286 | { 287 | isDisposed = true; 288 | #if UNITY_2019_1_OR_NEWER 289 | if (buffer == null) return; 290 | #else 291 | if (Unsafe.IsNullRef(ref Unsafe.AsRef(buffer))) return; 292 | #endif 293 | 294 | #if NET6_0_OR_GREATER 295 | NativeMemory.Free(buffer); 296 | #else 297 | Marshal.FreeHGlobal((IntPtr)buffer); 298 | #endif 299 | if (addMemoryPressure) 300 | { 301 | GC.RemoveMemoryPressure(length * Unsafe.SizeOf()); 302 | } 303 | } 304 | } 305 | 306 | ~NativeMemoryArray() 307 | { 308 | DisposeCore(); 309 | } 310 | 311 | public struct SpanSequence 312 | { 313 | readonly NativeMemoryArray nativeArray; 314 | readonly int chunkSize; 315 | long index; 316 | long sliceStart; 317 | 318 | internal SpanSequence(NativeMemoryArray nativeArray, int chunkSize) 319 | { 320 | this.nativeArray = nativeArray; 321 | index = 0; 322 | sliceStart = 0; 323 | this.chunkSize = chunkSize; 324 | } 325 | 326 | public SpanSequence GetEnumerator() => this; 327 | 328 | public Span Current 329 | { 330 | get 331 | { 332 | return nativeArray.AsSpan(sliceStart, (int)Math.Min(chunkSize, nativeArray.length - sliceStart)); 333 | } 334 | } 335 | 336 | public bool MoveNext() 337 | { 338 | if (index < nativeArray.length) 339 | { 340 | sliceStart = index; 341 | index += chunkSize; 342 | return true; 343 | } 344 | return false; 345 | } 346 | } 347 | 348 | public struct MemorySequence 349 | { 350 | readonly NativeMemoryArray nativeArray; 351 | readonly int chunkSize; 352 | long index; 353 | long sliceStart; 354 | 355 | internal MemorySequence(NativeMemoryArray nativeArray, int chunkSize) 356 | { 357 | this.nativeArray = nativeArray; 358 | index = 0; 359 | sliceStart = 0; 360 | this.chunkSize = chunkSize; 361 | } 362 | 363 | public MemorySequence GetEnumerator() => this; 364 | 365 | public Memory Current 366 | { 367 | get 368 | { 369 | return nativeArray.AsMemory(sliceStart, (int)Math.Min(chunkSize, nativeArray.length - sliceStart)); 370 | } 371 | } 372 | 373 | public bool MoveNext() 374 | { 375 | if (index < nativeArray.length) 376 | { 377 | sliceStart = index; 378 | index += chunkSize; 379 | return true; 380 | } 381 | return false; 382 | } 383 | } 384 | 385 | class Segment : ReadOnlySequenceSegment 386 | { 387 | public Segment(Memory buffer) 388 | { 389 | Memory = buffer; 390 | } 391 | 392 | internal void SetRunningIndexAndNext(long runningIndex, Segment? nextSegment) 393 | { 394 | RunningIndex = runningIndex; 395 | Next = nextSegment; 396 | } 397 | } 398 | } 399 | 400 | internal sealed unsafe class NativeMemoryArrayBufferWriter : IBufferWriter 401 | where T : unmanaged 402 | { 403 | readonly NativeMemoryArray nativeArray; 404 | PointerMemoryManager? pointerMemoryManager; 405 | long written; 406 | 407 | internal NativeMemoryArrayBufferWriter(NativeMemoryArray nativeArray) 408 | { 409 | this.nativeArray = nativeArray; 410 | pointerMemoryManager = null; 411 | } 412 | 413 | public void Advance(int count) 414 | { 415 | written += count; 416 | if (pointerMemoryManager != null) 417 | { 418 | pointerMemoryManager.AllowReuse(); 419 | } 420 | } 421 | 422 | public Span GetSpan(int sizeHint = 0) 423 | { 424 | if (sizeHint < 0) throw new InvalidOperationException($"sizeHint:{sizeHint} is invalid range."); 425 | if (nativeArray.Length - written < sizeHint) throw new InvalidOperationException($"sizeHint:{sizeHint} is capacity:{nativeArray.Length} - written:{written} over"); 426 | var length = (int)Math.Min(int.MaxValue, nativeArray.Length - written); 427 | 428 | if (length == 0) return Array.Empty(); 429 | return new Span(nativeArray.buffer + written * Unsafe.SizeOf(), length); 430 | } 431 | 432 | public Memory GetMemory(int sizeHint = 0) 433 | { 434 | if (sizeHint < 0) throw new InvalidOperationException($"sizeHint:{sizeHint} is invalid range."); 435 | if (nativeArray.Length - written < sizeHint) throw new InvalidOperationException($"sizeHint:{sizeHint} is capacity:{nativeArray.Length} - written:{written} over"); 436 | var length = (int)Math.Min(int.MaxValue, nativeArray.Length - written); 437 | if (length == 0) return Array.Empty(); 438 | 439 | if (pointerMemoryManager == null) 440 | { 441 | pointerMemoryManager = new PointerMemoryManager(nativeArray.buffer + written * Unsafe.SizeOf(), length); 442 | } 443 | else 444 | { 445 | pointerMemoryManager.Reset(nativeArray.buffer + written * Unsafe.SizeOf(), length); 446 | } 447 | 448 | return pointerMemoryManager.Memory; 449 | } 450 | } 451 | 452 | internal sealed class NativeMemoryArrayDebugView 453 | where T : unmanaged 454 | { 455 | private readonly NativeMemoryArray array; 456 | 457 | public NativeMemoryArrayDebugView(NativeMemoryArray array) 458 | { 459 | if (array == null) 460 | { 461 | throw new ArgumentNullException(nameof(array)); 462 | } 463 | this.array = array; 464 | } 465 | 466 | [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] 467 | public Span Items 468 | { 469 | get 470 | { 471 | if (array.TryGetFullSpan(out var span)) 472 | { 473 | return span; 474 | } 475 | else 476 | { 477 | return array.AsSpan(0, 1000000); // limit 478 | } 479 | } 480 | } 481 | } 482 | } 483 | -------------------------------------------------------------------------------- /src/NativeMemoryArray/NativeMemoryArray.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0;netstandard2.1;net5.0;net6.0 5 | disable 6 | enable 7 | 9.0 8 | Cysharp.Collections 9 | true 10 | true 11 | 1701;1702;1591 12 | 13 | 14 | $(Version) 15 | Cysharp 16 | Cysharp 17 | © Cysharp, Inc. 18 | memory 19 | Utilized native-memory backed array for .NET and Unity. 20 | https://github.com/Cysharp/NativeMemoryArray 21 | $(PackageProjectUrl) 22 | git 23 | MIT 24 | true 25 | ../../opensource.snk 26 | Icon.png 27 | true 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | $(MSBuildProjectDirectory)\..\NativeMemoryArray.Unity\Assets\Plugins\NativeMemoryArray\Runtime\ 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/NativeMemoryArray/NativeMemoryArrayExtensions.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | 3 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 4 | 5 | using System; 6 | using System.IO; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | 10 | namespace Cysharp.Collections 11 | { 12 | public static class NativeMemoryArrayExtensions 13 | { 14 | public static async Task ReadFromAsync(this NativeMemoryArray buffer, Stream stream, IProgress? progress = null, CancellationToken cancellationToken = default) 15 | { 16 | var writer = buffer.CreateBufferWriter(); 17 | 18 | int read; 19 | while ((read = await stream.ReadAsync(writer.GetMemory(), cancellationToken).ConfigureAwait(false)) != 0) 20 | { 21 | progress?.Report(read); 22 | writer.Advance(read); 23 | } 24 | } 25 | 26 | public static async Task WriteToFileAsync(this NativeMemoryArray buffer, string path, FileMode mode = FileMode.Create, IProgress? progress = null, CancellationToken cancellationToken = default) 27 | { 28 | using (var fs = new FileStream(path, mode, FileAccess.Write, FileShare.ReadWrite, 1, useAsync: true)) 29 | { 30 | await buffer.WriteToAsync(fs, progress: progress, cancellationToken: cancellationToken); 31 | } 32 | } 33 | 34 | public static async Task WriteToAsync(this NativeMemoryArray buffer, Stream stream, int chunkSize = int.MaxValue, IProgress? progress = null, CancellationToken cancellationToken = default) 35 | { 36 | foreach (var item in buffer.AsReadOnlyMemoryList(chunkSize)) 37 | { 38 | await stream.WriteAsync(item, cancellationToken); 39 | progress?.Report(item.Length); 40 | } 41 | } 42 | } 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/NativeMemoryArray/PointerMemoryManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Buffers; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace Cysharp.Collections 6 | { 7 | internal sealed unsafe class PointerMemoryManager : MemoryManager 8 | where T : unmanaged 9 | { 10 | byte* pointer; 11 | int length; 12 | bool usingMemory; 13 | 14 | internal PointerMemoryManager(byte* pointer, int length) 15 | { 16 | this.pointer = pointer; 17 | this.length = length; 18 | usingMemory = false; 19 | } 20 | 21 | protected override void Dispose(bool disposing) 22 | { 23 | } 24 | 25 | public override Span GetSpan() 26 | { 27 | usingMemory = true; 28 | return new Span(pointer, length); 29 | } 30 | 31 | public override MemoryHandle Pin(int elementIndex = 0) 32 | { 33 | if ((uint)elementIndex >= (uint)length) ThrowHelper.ThrowIndexOutOfRangeException(); 34 | return new MemoryHandle(pointer + elementIndex * Unsafe.SizeOf(), default, this); 35 | } 36 | 37 | public override void Unpin() 38 | { 39 | } 40 | 41 | public void AllowReuse() 42 | { 43 | usingMemory = false; 44 | } 45 | 46 | public void Reset(byte* pointer, int length) 47 | { 48 | if (usingMemory) throw new InvalidOperationException("Memory is using, can not reset."); 49 | this.pointer = pointer; 50 | this.length = length; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/NativeMemoryArray/ThrowHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace Cysharp.Collections 6 | { 7 | internal static class ThrowHelper 8 | { 9 | [MethodImpl(MethodImplOptions.NoInlining)] 10 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 11 | [DoesNotReturn] 12 | #endif 13 | public static void ThrowIndexOutOfRangeException() 14 | { 15 | throw new IndexOutOfRangeException(); 16 | } 17 | 18 | [MethodImpl(MethodImplOptions.NoInlining)] 19 | #if !NETSTANDARD2_0 && !UNITY_2019_1_OR_NEWER 20 | [DoesNotReturn] 21 | #endif 22 | public static void ThrowArgumentOutOfRangeException(string paramName) 23 | { 24 | throw new ArgumentOutOfRangeException(paramName); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/NativeMemoryArray.Tests/NativeArrayTest.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers; 2 | 3 | namespace NativeMemoryArrayTests 4 | { 5 | public class NativeArrayTest 6 | { 7 | [Fact] 8 | public void Int() 9 | { 10 | using var array = new NativeMemoryArray(1024); 11 | 12 | array.TryGetFullSpan(out var span).Should().BeTrue(); 13 | span.Length.Should().Be(1024); 14 | 15 | var refarray = Enumerable.Range(1, 1024).ToArray(); 16 | refarray.CopyTo(span); 17 | 18 | array.AsSpan().SequenceEqual(refarray).Should().BeTrue(); 19 | 20 | for (long i = 0; i < array.Length; i++) 21 | { 22 | array[i].Should().Be(refarray[i]); 23 | } 24 | } 25 | 26 | [Fact] 27 | public void ValueType() 28 | { 29 | using var array = new NativeMemoryArray(15); 30 | 31 | for (int i = 0; i < 15; i++) 32 | { 33 | array[(long)i] = new ValueTypeSample { X = i, Y = i * i, Z = i * i * i }; 34 | } 35 | 36 | for (int i = 0; i < 15; i++) 37 | { 38 | var v = array[(long)i]; 39 | v.X.Should().Be(i); 40 | v.Y.Should().Be(i * i); 41 | v.Z.Should().Be(i * i * i); 42 | } 43 | } 44 | 45 | [Fact] 46 | public void As() 47 | { 48 | using var array = new NativeMemoryArray(10); 49 | var range = Enumerable.Range(0, 10).ToArray(); 50 | range.AsSpan().CopyTo(array.AsSpan()); // 0..9 51 | 52 | range.AsSpan(3)[0].Should().Be(3); 53 | { 54 | var slice = array.AsSpan(3, 4); 55 | slice.Length.Should().Be(4); 56 | 57 | slice[0].Should().Be(3); 58 | slice[1].Should().Be(4); 59 | slice[2].Should().Be(5); 60 | slice[3].Should().Be(6); 61 | } 62 | { 63 | var slice = array.AsMemory(3, 4); 64 | slice.Length.Should().Be(4); 65 | 66 | slice.Span[0].Should().Be(3); 67 | slice.Span[1].Should().Be(4); 68 | slice.Span[2].Should().Be(5); 69 | slice.Span[3].Should().Be(6); 70 | } 71 | 72 | { 73 | var writer = array.CreateBufferWriter(); 74 | var span = writer.GetSpan(4); 75 | span[0] = 1000; 76 | span[1] = 2000; 77 | span[2] = 3000; 78 | writer.Advance(3); 79 | span = writer.GetSpan(4); 80 | span[0] = 4000; 81 | span[1] = 5000; 82 | span[2] = 6000; 83 | writer.Advance(3); 84 | 85 | array.AsSpan(0, 6).ToArray().Should().Equal(1000, 2000, 3000, 4000, 5000, 6000); 86 | } 87 | 88 | { 89 | var writer = array.CreateBufferWriter(); 90 | var span = writer.GetMemory(4).Span; 91 | span[0] = 1000; 92 | span[1] = 2000; 93 | span[2] = 3000; 94 | writer.Advance(3); 95 | span = writer.GetMemory(4).Span; 96 | span[0] = 4000; 97 | span[1] = 5000; 98 | span[2] = 6000; 99 | writer.Advance(3); 100 | 101 | array.AsSpan(0, 6).ToArray().Should().Equal(1000, 2000, 3000, 4000, 5000, 6000); 102 | } 103 | } 104 | 105 | [Fact] 106 | public void Stream() 107 | { 108 | using var array = new NativeMemoryArray(1024); 109 | Enumerable.Range(1, 1024).Select(x => (byte)x).ToArray().CopyTo(array.AsSpan()); 110 | 111 | var readStream = array.AsStream(); 112 | var writeStream = array.AsStream(FileAccess.Write); 113 | 114 | var buffer = new byte[1024]; 115 | readStream.Read(buffer, 0, 10); 116 | 117 | var span = array.AsSpan(); 118 | span[0].Should().Be(1); 119 | span[1].Should().Be(2); 120 | span[2].Should().Be(3); 121 | span[3].Should().Be(4); 122 | span[4].Should().Be(5); 123 | span[5].Should().Be(6); 124 | 125 | writeStream.WriteByte(10); 126 | writeStream.WriteByte(20); 127 | writeStream.WriteByte(30); 128 | writeStream.WriteByte(40); 129 | writeStream.Flush(); 130 | span[0].Should().Be(10); 131 | span[1].Should().Be(20); 132 | span[2].Should().Be(30); 133 | span[3].Should().Be(40); 134 | } 135 | } 136 | 137 | public class ReferenceTypeSample 138 | { 139 | public int MyProperty { get; set; } 140 | } 141 | 142 | public struct ValueTypeSample 143 | { 144 | public int X; 145 | public int Y; 146 | public int Z; 147 | } 148 | } -------------------------------------------------------------------------------- /tests/NativeMemoryArray.Tests/NativeBufferTest.cs: -------------------------------------------------------------------------------- 1 | using Cysharp.Collections; 2 | using System; 3 | using System.Buffers; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Xunit.Sdk; 10 | 11 | namespace NativeMemoryArrayTests 12 | { 13 | // NativeMemoryArray 14 | 15 | public class NativeBufferTest 16 | { 17 | [Fact] 18 | public void Lower2GB() 19 | { 20 | using var nbuffer = new NativeMemoryArray(1024); 21 | ((long)nbuffer.Length).Should().Be(1024); 22 | 23 | var shareRand = new Random(); 24 | 25 | var rand = Enumerable.Range(0, (int)nbuffer.Length).Select(x => (byte)shareRand.Next(0, byte.MaxValue)).ToArray(); 26 | 27 | // copy all 28 | for (uint i = 0; i < nbuffer.Length; i++) 29 | { 30 | nbuffer[i] = rand[i]; 31 | } 32 | 33 | // check indexer 34 | for (uint i = 0; i < nbuffer.Length; i++) 35 | { 36 | nbuffer[i].Should().Be(rand[i]); 37 | } 38 | 39 | // indexer:out of range 40 | nbuffer[1023].Should().Be(rand.Last()); 41 | Assert.Throws(() => nbuffer[1024]); 42 | Assert.Throws(() => nbuffer[9999]); 43 | 44 | // Single span 45 | nbuffer.TryGetFullSpan(out var fullspan).Should().BeTrue(); 46 | fullspan.SequenceEqual(rand).Should().BeTrue(); 47 | 48 | // Slice 49 | nbuffer.AsSpan(114, 99).SequenceEqual(rand.AsSpan().Slice(114, 99)).Should().BeTrue(); 50 | nbuffer.AsSpan(35).SequenceEqual(rand.AsSpan().Slice(35)).Should().BeTrue(); 51 | nbuffer.AsMemory(114, 99).Span.SequenceEqual(rand.AsSpan().Slice(114, 99)).Should().BeTrue(); 52 | nbuffer.AsMemory(35).Span.SequenceEqual(rand.AsSpan().Slice(35)).Should().BeTrue(); 53 | 54 | // Slice:out of range 55 | rand.AsSpan().Slice(14, 1010).SequenceEqual(rand.AsSpan().Slice(14, 1010)).Should().BeTrue(); 56 | nbuffer.AsSpan(14, 1010).SequenceEqual(rand.AsSpan().Slice(14, 1010)).Should().BeTrue(); 57 | nbuffer.AsMemory(14, 1010).Span.SequenceEqual(rand.AsSpan().Slice(14, 1010)).Should().BeTrue(); 58 | Assert.Throws(() => rand.AsSpan().Slice(14, 1011)); 59 | Assert.Throws(() => nbuffer.AsSpan(14, 1011)); 60 | Assert.Throws(() => nbuffer.AsMemory(14, 1011)); 61 | 62 | // pointer 63 | unsafe 64 | { 65 | fixed (byte* p = nbuffer) 66 | { 67 | (*p).Should().Be(rand[0]); 68 | (*(p + 143)).Should().Be(rand[143]); 69 | } 70 | 71 | fixed (byte* p = &nbuffer[43]) 72 | { 73 | (*p).Should().Be(rand[43]); 74 | (*(p + 143)).Should().Be(rand[43 + 143]); 75 | } 76 | } 77 | 78 | // AsSpanSeqeunce 79 | var ii = 0; 80 | foreach (var item in nbuffer.AsSpanSequence(333)) 81 | { 82 | if (ii == 0) // 333 83 | { 84 | item.Length.Should().Be(333); 85 | item.SequenceEqual(rand.AsSpan(0, 333)).Should().BeTrue(); 86 | } 87 | else if (ii == 1) // 666 88 | { 89 | item.Length.Should().Be(333); 90 | item.SequenceEqual(rand.AsSpan(333, 333)).Should().BeTrue(); 91 | } 92 | else if (ii == 2) // 999 93 | { 94 | item.Length.Should().Be(333); 95 | item.SequenceEqual(rand.AsSpan(666, 333)).Should().BeTrue(); 96 | } 97 | else if (ii == 3) // 1332 98 | { 99 | item.Length.Should().Be(25); 100 | item.SequenceEqual(rand.AsSpan(999)).Should().BeTrue(); 101 | } 102 | else 103 | { 104 | throw new XunitException(); 105 | } 106 | ii++; 107 | } 108 | ii.Should().Be(4); 109 | 110 | foreach (var item in nbuffer) 111 | { 112 | item.SequenceEqual(rand).Should().BeTrue(); 113 | } 114 | 115 | // AsMemorySequeunce 116 | ii = 0; 117 | foreach (var item in nbuffer.AsMemorySequence(333)) 118 | { 119 | if (ii == 0) // 333 120 | { 121 | item.Length.Should().Be(333); 122 | item.Span.SequenceEqual(rand.AsSpan(0, 333)).Should().BeTrue(); 123 | } 124 | else if (ii == 1) // 666 125 | { 126 | item.Length.Should().Be(333); 127 | item.Span.SequenceEqual(rand.AsSpan(333, 333)).Should().BeTrue(); 128 | } 129 | else if (ii == 2) // 999 130 | { 131 | item.Length.Should().Be(333); 132 | item.Span.SequenceEqual(rand.AsSpan(666, 333)).Should().BeTrue(); 133 | } 134 | else if (ii == 3) // 1332 135 | { 136 | item.Length.Should().Be(25); 137 | item.Span.SequenceEqual(rand.AsSpan(999)).Should().BeTrue(); 138 | } 139 | else 140 | { 141 | throw new XunitException(); 142 | } 143 | ii++; 144 | } 145 | ii.Should().Be(4); 146 | 147 | // AsReadOnlyList 148 | ii = 0; 149 | foreach (var item in nbuffer.AsReadOnlyMemoryList(333)) 150 | { 151 | if (ii == 0) // 333 152 | { 153 | item.Length.Should().Be(333); 154 | item.Span.SequenceEqual(rand.AsSpan(0, 333)).Should().BeTrue(); 155 | } 156 | else if (ii == 1) // 666 157 | { 158 | item.Length.Should().Be(333); 159 | item.Span.SequenceEqual(rand.AsSpan(333, 333)).Should().BeTrue(); 160 | } 161 | else if (ii == 2) // 999 162 | { 163 | item.Length.Should().Be(333); 164 | item.Span.SequenceEqual(rand.AsSpan(666, 333)).Should().BeTrue(); 165 | } 166 | else if (ii == 3) // 1332 167 | { 168 | item.Length.Should().Be(25); 169 | item.Span.SequenceEqual(rand.AsSpan(999)).Should().BeTrue(); 170 | } 171 | else 172 | { 173 | throw new XunitException(); 174 | } 175 | ii++; 176 | } 177 | ii.Should().Be(4); 178 | 179 | // AsReadOnlySeqeunce 180 | ii = 0; 181 | foreach (var item in nbuffer.AsReadOnlySequence(333)) 182 | { 183 | if (ii == 0) // 333 184 | { 185 | item.Length.Should().Be(333); 186 | item.Span.SequenceEqual(rand.AsSpan(0, 333)).Should().BeTrue(); 187 | } 188 | else if (ii == 1) // 666 189 | { 190 | item.Length.Should().Be(333); 191 | item.Span.SequenceEqual(rand.AsSpan(333, 333)).Should().BeTrue(); 192 | } 193 | else if (ii == 2) // 999 194 | { 195 | item.Length.Should().Be(333); 196 | item.Span.SequenceEqual(rand.AsSpan(666, 333)).Should().BeTrue(); 197 | } 198 | else if (ii == 3) // 1332 199 | { 200 | item.Length.Should().Be(25); 201 | item.Span.SequenceEqual(rand.AsSpan(999)).Should().BeTrue(); 202 | } 203 | else 204 | { 205 | throw new XunitException(); 206 | } 207 | ii++; 208 | } 209 | ii.Should().Be(4); 210 | 211 | nbuffer.AsReadOnlySequence().Length.Should().Be(1024L); 212 | nbuffer.AsReadOnlySequence().ToArray().Should().Equal(rand); 213 | nbuffer.AsReadOnlySequence().Slice(555, 200).Should().Equals(rand.AsSpan(555, 200).ToArray()); 214 | 215 | // CreateBufferWriter 216 | { 217 | var bufferWriter = nbuffer.CreateBufferWriter(); 218 | 219 | var span = bufferWriter.GetSpan(); 220 | span[0] = 100; 221 | span[1] = 200; 222 | bufferWriter.Advance(2); 223 | 224 | nbuffer[0].Should().Be(100); 225 | nbuffer[1].Should().Be(200); 226 | 227 | var memory = bufferWriter.GetMemory(); 228 | memory.Span[0] = 201; 229 | memory.Span[1] = 202; 230 | bufferWriter.Advance(2); 231 | 232 | memory = bufferWriter.GetMemory(); 233 | memory.Span[0] = 203; 234 | memory.Span[1] = 204; 235 | bufferWriter.Advance(2); 236 | 237 | span = bufferWriter.GetSpan(); 238 | span[0] = 101; 239 | span[1] = 102; 240 | bufferWriter.Advance(2); 241 | 242 | nbuffer.AsSpan(0, 8).ToArray().Should().Equal(100, 200, 201, 202, 203, 204, 101, 102); 243 | 244 | // too large sizehint. 245 | Assert.Throws(() => bufferWriter.GetSpan(1017)); 246 | Assert.Throws(() => bufferWriter.GetMemory(1017)); 247 | 248 | bufferWriter.GetSpan(1016)[^1] = 255; 249 | bufferWriter.Advance(1016); 250 | 251 | nbuffer.TryGetFullSpan(out var ss).Should().BeTrue(); 252 | ss[^1].Should().Be(255); 253 | } 254 | } 255 | 256 | #if NET48 257 | [Fact(Skip = "32bit.")] 258 | #else 259 | [Fact] 260 | #endif 261 | public unsafe void Over2GB() 262 | { 263 | var len = (long)int.MaxValue + 1024; 264 | using var nbuffer = new NativeMemoryArray(len); 265 | nbuffer.Length.Should().Be(len); 266 | 267 | 268 | nbuffer[len - 1] = 100; 269 | nbuffer[len - 1].Should().Be(100); 270 | 271 | // indexer:out of range 272 | Assert.Throws(() => nbuffer[len]); 273 | 274 | // Single span 275 | nbuffer.TryGetFullSpan(out var fullspan).Should().BeFalse(); 276 | 277 | var ii = 0; 278 | foreach (var item in nbuffer) 279 | { 280 | if (ii == 0) 281 | { 282 | item.Length.Should().Be(int.MaxValue); 283 | } 284 | else if (ii == 1) 285 | { 286 | item.Length.Should().Be(1024); 287 | } 288 | ii++; 289 | } 290 | ii.Should().Be(2); 291 | 292 | var bufferWriter = nbuffer.CreateBufferWriter(); 293 | bufferWriter.GetSpan().Length.Should().Be(int.MaxValue); 294 | bufferWriter.Advance(int.MaxValue); 295 | bufferWriter.GetSpan().Length.Should().Be(1024); 296 | bufferWriter.Advance(1024); 297 | bufferWriter.GetSpan().Length.Should().Be(0); 298 | } 299 | 300 | [Fact] 301 | public unsafe void Empty() 302 | { 303 | var reference = Array.Empty(); 304 | var nbuffer = NativeMemoryArray.Empty; 305 | 306 | Assert.Throws(() => reference[0]); 307 | Assert.Throws(() => nbuffer[0]); 308 | 309 | Assert.Throws(() => reference.AsSpan().Slice(0, 1)); 310 | Assert.Throws(() => nbuffer.AsSpan(0, 1)); 311 | Assert.Throws(() => nbuffer.AsMemory(0, 1)); 312 | 313 | fixed (byte* p = reference) 314 | { 315 | if (p != null) 316 | { 317 | throw new XunitException(); 318 | } 319 | } 320 | 321 | fixed (byte* p = nbuffer) 322 | { 323 | if (p != null) 324 | { 325 | throw new XunitException(); 326 | } 327 | } 328 | 329 | nbuffer.TryGetFullSpan(out var span).Should().BeTrue(); 330 | span.Length.Should().Be(0); 331 | 332 | var writer = nbuffer.CreateBufferWriter(); 333 | writer.GetSpan().Length.Should().Be(0); 334 | writer.GetMemory().Length.Should().Be(0); 335 | 336 | nbuffer.AsSpanSequence().MoveNext().Should().BeFalse(); 337 | nbuffer.AsMemorySequence().MoveNext().Should().BeFalse(); 338 | nbuffer.AsReadOnlyMemoryList().Count.Should().Be(0); 339 | } 340 | } 341 | } -------------------------------------------------------------------------------- /tests/NativeMemoryArray.Tests/NativeMemoryArray.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net480;net6.0 5 | false 6 | 7 | 8 | net6.0 9 | 10 | 11 | 12 | enable 13 | enable 14 | false 15 | 10.0 16 | true 17 | NativeMemoryArrayTests 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | runtime; build; native; contentfiles; analyzers; buildtransitive 26 | all 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/NativeMemoryArray.Tests/_GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; 2 | global using FluentAssertions; 3 | global using Cysharp.Collections; -------------------------------------------------------------------------------- /tests/NativeMemoryArray.Tests/_Index.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | #if !NET6_0 5 | 6 | using System.Diagnostics; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Runtime.CompilerServices; 9 | 10 | namespace System 11 | { 12 | /// Represent a type can be used to index a collection either from the start or the end. 13 | /// 14 | /// Index is used by the C# compiler to support the new index syntax 15 | /// 16 | /// int[] someArray = new int[5] { 1, 2, 3, 4, 5 } ; 17 | /// int lastElement = someArray[^1]; // lastElement = 5 18 | /// 19 | /// 20 | public readonly struct Index : IEquatable 21 | { 22 | private readonly int _value; 23 | 24 | /// Construct an Index using a value and indicating if the index is from the start or from the end. 25 | /// The index value. it has to be zero or positive number. 26 | /// Indicating if the index is from the start or from the end. 27 | /// 28 | /// If the Index constructed from the end, index value 1 means pointing at the last element and index value 0 means pointing at beyond last element. 29 | /// 30 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 31 | public Index(int value, bool fromEnd = false) 32 | { 33 | if (value < 0) 34 | { 35 | // ThrowHelper.ThrowValueArgumentOutOfRange_NeedNonNegNumException(); 36 | throw new ArgumentOutOfRangeException(); 37 | } 38 | 39 | if (fromEnd) 40 | _value = ~value; 41 | else 42 | _value = value; 43 | } 44 | 45 | // The following private constructors mainly created for perf reason to avoid the checks 46 | private Index(int value) 47 | { 48 | _value = value; 49 | } 50 | 51 | /// Create an Index pointing at first element. 52 | public static Index Start => new Index(0); 53 | 54 | /// Create an Index pointing at beyond last element. 55 | public static Index End => new Index(~0); 56 | 57 | /// Create an Index from the start at the position indicated by the value. 58 | /// The index value from the start. 59 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 60 | public static Index FromStart(int value) 61 | { 62 | if (value < 0) 63 | { 64 | // ThrowHelper.ThrowValueArgumentOutOfRange_NeedNonNegNumException(); 65 | throw new ArgumentOutOfRangeException(); 66 | } 67 | 68 | return new Index(value); 69 | } 70 | 71 | /// Create an Index from the end at the position indicated by the value. 72 | /// The index value from the end. 73 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 74 | public static Index FromEnd(int value) 75 | { 76 | if (value < 0) 77 | { 78 | //ThrowHelper.ThrowValueArgumentOutOfRange_NeedNonNegNumException(); 79 | throw new ArgumentOutOfRangeException(); 80 | } 81 | 82 | return new Index(~value); 83 | } 84 | 85 | /// Returns the index value. 86 | public int Value 87 | { 88 | get 89 | { 90 | if (_value < 0) 91 | return ~_value; 92 | else 93 | return _value; 94 | } 95 | } 96 | 97 | /// Indicates whether the index is from the start or the end. 98 | public bool IsFromEnd => _value < 0; 99 | 100 | /// Calculate the offset from the start using the giving collection length. 101 | /// The length of the collection that the Index will be used with. length has to be a positive value 102 | /// 103 | /// For performance reason, we don't validate the input length parameter and the returned offset value against negative values. 104 | /// we don't validate either the returned offset is greater than the input length. 105 | /// It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and 106 | /// then used to index a collection will get out of range exception which will be same affect as the validation. 107 | /// 108 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 109 | public int GetOffset(int length) 110 | { 111 | int offset = _value; 112 | if (IsFromEnd) 113 | { 114 | // offset = length - (~value) 115 | // offset = length + (~(~value) + 1) 116 | // offset = length + value + 1 117 | 118 | offset += length + 1; 119 | } 120 | return offset; 121 | } 122 | 123 | /// Indicates whether the current Index object is equal to another object of the same type. 124 | /// An object to compare with this object 125 | public override bool Equals(object? value) => value is Index && _value == ((Index)value)._value; 126 | 127 | /// Indicates whether the current Index object is equal to another Index object. 128 | /// An object to compare with this object 129 | public bool Equals(Index other) => _value == other._value; 130 | 131 | /// Returns the hash code for this instance. 132 | public override int GetHashCode() => _value; 133 | 134 | /// Converts integer number to an Index. 135 | public static implicit operator Index(int value) => FromStart(value); 136 | 137 | /// Converts the value of the current Index object to its equivalent string representation. 138 | public override string ToString() 139 | { 140 | if (IsFromEnd) 141 | return ToStringFromEnd(); 142 | 143 | return ((uint)Value).ToString(); 144 | } 145 | 146 | private string ToStringFromEnd() 147 | { 148 | #if (!NETSTANDARD2_0 && !NETFRAMEWORK) 149 | Span span = stackalloc char[11]; // 1 for ^ and 10 for longest possible uint value 150 | bool formatted = ((uint)Value).TryFormat(span.Slice(1), out int charsWritten); 151 | Debug.Assert(formatted); 152 | span[0] = '^'; 153 | return new string(span.Slice(0, charsWritten + 1)); 154 | #else 155 | return '^' + Value.ToString(); 156 | #endif 157 | } 158 | } 159 | } 160 | 161 | #endif --------------------------------------------------------------------------------