├── .github └── workflows │ ├── release-upm.yml │ └── unit-test.yml ├── .gitignore ├── Assets ├── Example.cs ├── Example.cs.meta ├── Scenes.meta ├── Scenes │ ├── SampleScene.unity │ └── SampleScene.unity.meta ├── TestBlobBuilder.cs ├── TestBlobBuilder.cs.meta ├── TestComplexBlobBuilder.cs ├── TestComplexBlobBuilder.cs.meta ├── TestCustomBuilder.cs ├── TestCustomBuilder.cs.meta ├── TestMathBlobBuilder.cs ├── TestMathBlobBuilder.cs.meta ├── TestSingleBlobBuilder.cs └── TestSingleBlobBuilder.cs.meta ├── LICENSE ├── Packages ├── blob-editor │ ├── Editor.meta │ ├── Editor │ │ ├── Blob.Editor.asmdef │ │ ├── Blob.Editor.asmdef.meta │ │ ├── BuilderDrawer.meta │ │ ├── BuilderDrawer │ │ │ ├── ArrayBuilderDrawer.cs │ │ │ ├── ArrayBuilderDrawer.cs.meta │ │ │ ├── BlobAssetDrawer.cs │ │ │ ├── BlobAssetDrawer.cs.meta │ │ │ ├── BlobAssetV1Drawer.cs │ │ │ ├── BlobAssetV1Drawer.cs.meta │ │ │ ├── BlobDataBuilderDrawer.cs │ │ │ ├── BlobDataBuilderDrawer.cs.meta │ │ │ ├── DynamicBuilderFactoryRegister.cs │ │ │ ├── DynamicBuilderFactoryRegister.cs.meta │ │ │ ├── EnumBuilderDrawer.cs │ │ │ ├── EnumBuilderDrawer.cs.meta │ │ │ ├── PtrBuilderDrawer.cs │ │ │ └── PtrBuilderDrawer.cs.meta │ │ ├── Extensions.cs │ │ ├── Extensions.cs.meta │ │ ├── MultiProperty.meta │ │ ├── MultiProperty │ │ │ ├── BaseMultiPropertyDrawer.cs │ │ │ ├── BaseMultiPropertyDrawer.cs.meta │ │ │ ├── CustomMultiPropertyDrawerAttribute.cs │ │ │ ├── CustomMultiPropertyDrawerAttribute.cs.meta │ │ │ ├── IMultiPropertyDrawer.cs │ │ │ ├── IMultiPropertyDrawer.cs.meta │ │ │ ├── MultiPropertyDrawerRegister.cs │ │ │ ├── MultiPropertyDrawerRegister.cs.meta │ │ │ ├── MultiPropertyUnityDrawer.cs │ │ │ ├── MultiPropertyUnityDrawer.cs.meta │ │ │ ├── UnboxSinglePropertyAttributeDrawer.cs │ │ │ ├── UnboxSinglePropertyAttributeDrawer.cs.meta │ │ │ ├── UnityDrawPropertyAttributeDrawer.cs │ │ │ └── UnityDrawPropertyAttributeDrawer.cs.meta │ │ ├── ViewerDrawer.meta │ │ └── ViewerDrawer │ │ │ ├── BlobDataViewerDrawer.cs │ │ │ ├── BlobDataViewerDrawer.cs.meta │ │ │ ├── BlobViewerDrawer.cs │ │ │ ├── BlobViewerDrawer.cs.meta │ │ │ ├── EnumViewerDrawer.cs │ │ │ └── EnumViewerDrawer.cs.meta │ ├── Runtime.meta │ ├── Runtime │ │ ├── Attribute.meta │ │ ├── Attribute │ │ │ ├── MultiPropertyAttribute.cs │ │ │ ├── MultiPropertyAttribute.cs.meta │ │ │ ├── UnboxSinglePropertyAttribute.cs │ │ │ ├── UnboxSinglePropertyAttribute.cs.meta │ │ │ ├── UnityDrawPropertyAttribute.cs │ │ │ └── UnityDrawPropertyAttribute.cs.meta │ │ ├── BlobEditor.Runtime.asmdef │ │ ├── BlobEditor.Runtime.asmdef.meta │ │ ├── Builder.meta │ │ ├── Builder │ │ │ ├── AnimationCurveBlobBuilder.cs │ │ │ ├── AnimationCurveBlobBuilder.cs.meta │ │ │ ├── AssemblyInfo.cs │ │ │ ├── AssemblyInfo.cs.meta │ │ │ ├── Blob.Builder.asmdef │ │ │ ├── Blob.Builder.asmdef.meta │ │ │ ├── BlobAsset.cs │ │ │ ├── BlobAsset.cs.meta │ │ │ ├── BlobAssetV1.cs │ │ │ ├── BlobAssetV1.cs.meta │ │ │ ├── Builders.cs │ │ │ ├── Builders.cs.meta │ │ │ ├── CustomBuilderAttribute.cs │ │ │ ├── CustomBuilderAttribute.cs.meta │ │ │ ├── DefaultBuilderAttribute.cs │ │ │ ├── DefaultBuilderAttribute.cs.meta │ │ │ ├── DynamicBuilders.cs │ │ │ ├── DynamicBuilders.cs.meta │ │ │ ├── GenerateBuilders.ttinclude │ │ │ ├── GenerateBuilders.ttinclude.meta │ │ │ ├── MathematicsBuilder.cs │ │ │ ├── MathematicsBuilder.cs.meta │ │ │ ├── MathematicsBuilder.tt │ │ │ ├── MathematicsBuilder.tt.meta │ │ │ ├── PrimitiveBuilder.cs │ │ │ ├── PrimitiveBuilder.cs.meta │ │ │ ├── PrimitiveBuilder.tt │ │ │ └── PrimitiveBuilder.tt.meta │ │ ├── DynamicBlobBuilderArray.cs │ │ ├── DynamicBlobBuilderArray.cs.meta │ │ ├── Mathematics.ttinclude │ │ ├── Mathematics.ttinclude.meta │ │ ├── Primitives.ttinclude │ │ ├── Primitives.ttinclude.meta │ │ ├── Utility.cs │ │ ├── Utility.cs.meta │ │ ├── Viewer.meta │ │ └── Viewer │ │ │ ├── AssemblyInfo.cs │ │ │ ├── AssemblyInfo.cs.meta │ │ │ ├── Blob.Viewer.asmdef │ │ │ ├── Blob.Viewer.asmdef.meta │ │ │ ├── BlobViewer.cs │ │ │ ├── BlobViewer.cs.meta │ │ │ ├── GenerateViewers.cs │ │ │ ├── GenerateViewers.cs.meta │ │ │ ├── GenerateViewers.tt │ │ │ ├── GenerateViewers.tt.meta │ │ │ ├── Viewers.cs │ │ │ └── Viewers.cs.meta │ ├── package.json │ └── package.json.meta ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── BurstAotSettings_StandaloneWindows.json ├── 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 ├── TimelineSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset └── README.md /.github/workflows/release-upm.yml: -------------------------------------------------------------------------------- 1 | name: Publish UPM Package 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | upm-release: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Create Release for OpenUPM 15 | id: create_release 16 | uses: quabug/create-upm-release@v2 17 | with: 18 | target: main 19 | upm_tag_prefix: v 20 | upm_package_path: Packages/blob-editor 21 | create_unitypackage: true 22 | unitypackage_name: BlobEditor 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | -------------------------------------------------------------------------------- /.github/workflows/unit-test.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | pull_request: 9 | branches: [ main ] 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | # This workflow contains a single job called "build" 17 | build: 18 | # The type of runner that the job will run on 19 | runs-on: ubuntu-latest 20 | 21 | # Steps represent a sequence of tasks that will be executed as part of the job 22 | steps: 23 | - uses: actions/checkout@master 24 | - uses: actions/cache@v2 25 | with: 26 | path: Library 27 | key: Library 28 | - uses: game-ci/unity-test-runner@v2 29 | env: 30 | UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} 31 | with: 32 | projectPath: . 33 | githubToken: ${{ secrets.GITHUB_TOKEN }} 34 | - uses: game-ci/unity-builder@v2 35 | env: 36 | UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} 37 | with: 38 | targetPlatform: StandaloneLinux64 39 | allowDirtyBuild: true 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Rider cache directory 26 | .idea/ 27 | 28 | # Gradle cache directory 29 | .gradle/ 30 | 31 | # Autogenerated VS/MD/Consulo solution and project files 32 | ExportedObj/ 33 | .consulo/ 34 | *.csproj 35 | *.unityproj 36 | *.sln 37 | *.suo 38 | *.tmp 39 | *.user 40 | *.userprefs 41 | *.pidb 42 | *.booproj 43 | *.svd 44 | *.pdb 45 | *.mdb 46 | *.opendb 47 | *.VC.db 48 | 49 | # Unity3D generated meta files 50 | *.pidb.meta 51 | *.pdb.meta 52 | *.mdb.meta 53 | 54 | # Unity3D generated file on crash reports 55 | sysinfo.txt 56 | 57 | # Builds 58 | *.apk 59 | *.unitypackage 60 | 61 | # Crashlytics generated file 62 | crashlytics-build.properties 63 | 64 | UserSettings/ 65 | -------------------------------------------------------------------------------- /Assets/Example.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Blob; 3 | using Unity.Animation; 4 | using Unity.Entities; 5 | using Unity.Mathematics; 6 | using UnityEngine; 7 | 8 | public class Example : MonoBehaviour 9 | { 10 | public BlobAsset Blob; 11 | public BlobViewer Viewer; 12 | 13 | private void Awake() 14 | { 15 | // get `BlobAssetReference` from `BlobAsset` 16 | BlobAssetReference blob = Blob.Reference; 17 | // or use blob value directly 18 | var _ = Blob.Value.Float3; 19 | 20 | Viewer.View(Blob.Reference); 21 | } 22 | } 23 | 24 | public struct ExampleBlob 25 | { 26 | public int Int; 27 | public float3 Float3; 28 | public BlobString String; 29 | public BlobArray Double2Array; 30 | public BlobArray StringArray; 31 | public BlobPtr LongPtr; 32 | public Guid Guid; 33 | [CustomBuilder(typeof(ObjectName))] public BlobString GameObjectName; 34 | public AnimationCurveBlob AnimationCurve; 35 | public ComponentType.AccessMode Enum; 36 | public BlobArray>>> Arrays; 37 | } -------------------------------------------------------------------------------- /Assets/Example.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c32608f3ea0ddca4e8e18274c2e0eab3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5873f05340e97494d94735c2f6bbd4d1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TestBlobBuilder.cs: -------------------------------------------------------------------------------- 1 | using Blob; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | 6 | public class TestBlobBuilder : MonoBehaviour 7 | { 8 | public BlobAsset Blob; 9 | 10 | public void Awake() 11 | { 12 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.Int)} = {Blob.Value.Int}"); 13 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.Long)} = {Blob.Value.Long}"); 14 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.String)} = {Blob.Value.String.ToString()}"); 15 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.IntArray)} = {string.Join(",", Blob.Value.IntArray.ToArray())}"); 16 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.ULongPtr)} = {Blob.Value.ULongPtr.Value}"); 17 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.StringArray)} = {StringArrayToString(ref Blob.Value.StringArray)}"); 18 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.UInt)} = {Blob.Value.UInt}"); 19 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.DoublePtr)} = {Blob.Value.DoublePtr.Value}"); 20 | Debug.Log($"{nameof(SimpleData)}.{nameof(SimpleData.TestEnum)} = {Blob.Value.TestEnum}"); 21 | } 22 | 23 | public static string StringArrayToString(ref BlobArray array) 24 | { 25 | if (array.Length == 0) return ""; 26 | 27 | var msg = ""; 28 | for (var i = 0; i < array.Length - 1; i++) 29 | { 30 | msg += array[i].ToString(); 31 | msg += ","; 32 | } 33 | msg += array[array.Length - 1].ToString(); 34 | return msg; 35 | } 36 | } 37 | 38 | public struct SimpleData 39 | { 40 | public int Int; 41 | public BlobString String; 42 | public float Float; 43 | public BlobArray IntArray; 44 | public long Long; 45 | public BlobPtr ULongPtr; 46 | public BlobArray StringArray; 47 | public uint UInt; 48 | public BlobPtr DoublePtr; 49 | public Test TestEnum; 50 | } 51 | 52 | public enum Test 53 | { 54 | Foo, Bar 55 | } -------------------------------------------------------------------------------- /Assets/TestBlobBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 680ec47a4b3017740b5a978da3d61a55 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TestComplexBlobBuilder.cs: -------------------------------------------------------------------------------- 1 | using Blob; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | 7 | public class TestComplexBlobBuilder : MonoBehaviour 8 | { 9 | public BlobAsset Blob; 10 | 11 | public void Awake() 12 | { 13 | Debug.Log($"ComplexData.A.Int = {Blob.Value.A.Int}"); 14 | Debug.Log($"ComplexData.A.Long = {Blob.Value.A.Long}"); 15 | Debug.Log($"ComplexData.A.String = {Blob.Value.A.String.ToString()}"); 16 | Debug.Log($"ComplexData.A.IntArray = {string.Join(",", Blob.Value.A.IntArray.ToArray())}"); 17 | Debug.Log($"ComplexData.A.LongPtr = {Blob.Value.A.ULongPtr.Value}"); 18 | 19 | Debug.Log($"ComplexData.B.Int = {Blob.Value.B.Int}"); 20 | Debug.Log($"ComplexData.B.Int2Array = {string.Join(",", Blob.Value.B.Int2Array.ToArray())}"); 21 | Debug.Log($"ComplexData.B.String = {Blob.Value.B.String.ToString()}"); 22 | Debug.Log($"ComplexData.B.Int3Ptr = {Blob.Value.B.Int3Ptr.Value}"); 23 | 24 | Debug.Log($"ComplexData.C.Float3 = {Blob.Value.C.Float3}"); 25 | Debug.Log($"ComplexData.C.Double2x2 = {Blob.Value.C.Double2x2}"); 26 | Debug.Log($"ComplexData.C.String = {Blob.Value.C.String.ToString()}"); 27 | Debug.Log($"ComplexData.C.IntArray = {string.Join(",", Blob.Value.C.Int3Array.ToArray())}"); 28 | Debug.Log($"ComplexData.C.Float2Ptr = {Blob.Value.C.Float2Ptr.Value}"); 29 | } 30 | } 31 | 32 | public struct SimpleData2 33 | { 34 | public int Int; 35 | public BlobArray Int2Array; 36 | public BlobString String; 37 | public BlobPtr Int3Ptr; 38 | } 39 | 40 | public struct ComplexData 41 | { 42 | public SimpleData A; 43 | public SimpleData2 B; 44 | public MathData C; 45 | } -------------------------------------------------------------------------------- /Assets/TestComplexBlobBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22061a7fcdad40638c0911ce04889502 3 | timeCreated: 1628685464 -------------------------------------------------------------------------------- /Assets/TestCustomBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Blob; 3 | using Unity.Entities; 4 | using UnityEngine; 5 | 6 | public class TestCustomBuilder : MonoBehaviour 7 | { 8 | public BlobAsset Blob; 9 | 10 | private void Awake() 11 | { 12 | Debug.Log($"CustomBuilderData.Guid = {Blob.Value.Guid}"); 13 | Debug.Log($"CustomBuilderData.StringGuid = {Blob.Value.StringGuid.ToString()}"); 14 | Debug.Log($"CustomBuilderData.ObjectName = {Blob.Value.ObjectName.ToString()}"); 15 | Debug.Log($"CustomBuilderData.Objects = {TestBlobBuilder.StringArrayToString(ref Blob.Value.Objects)}"); 16 | } 17 | } 18 | 19 | public struct CustomBuilderData 20 | { 21 | public Guid Guid; 22 | [CustomBuilder(typeof(StringGuid))] public BlobString StringGuid; 23 | [CustomBuilder(typeof(ObjectName))] public BlobString ObjectName; 24 | [CustomBuilder(typeof(ObjectNameArray))] public BlobArray Objects; 25 | } 26 | 27 | [Serializable, DefaultBuilder] 28 | public class GuidBuilder : Builder 29 | { 30 | public string Guid = System.Guid.NewGuid().ToString(); 31 | 32 | public override void Build(BlobBuilder builder, ref Guid data) 33 | { 34 | data = System.Guid.Parse(Guid); 35 | } 36 | } 37 | 38 | [Serializable] 39 | public class StringGuid : Builder 40 | { 41 | public string Guid = System.Guid.NewGuid().ToString(); 42 | 43 | public override void Build(BlobBuilder builder, ref BlobString data) 44 | { 45 | builder.AllocateString(ref data, Guid); 46 | } 47 | } 48 | 49 | [Serializable] 50 | public class GuidViewer : Viewer 51 | { 52 | public string Guid = System.Guid.NewGuid().ToString(); 53 | 54 | public override void View(ref Guid data) 55 | { 56 | Guid = data.ToString(); 57 | } 58 | } 59 | 60 | [Serializable] 61 | public class ObjectName : Builder 62 | { 63 | public GameObject GameObject; 64 | 65 | public override void Build(BlobBuilder builder, ref BlobString data) 66 | { 67 | builder.AllocateString(ref data, GameObject == null ? "" : GameObject.name); 68 | } 69 | } 70 | 71 | [Serializable] 72 | public class ObjectNameArray : Builder> 73 | { 74 | public GameObject[] GameObjects = Array.Empty(); 75 | 76 | public override void Build(BlobBuilder builder, ref BlobArray data) 77 | { 78 | var array = builder.Allocate(ref data, GameObjects.Length); 79 | for (var i = 0; i < GameObjects.Length; i++) builder.AllocateString(ref array[i], GameObjects[i].name); 80 | } 81 | } -------------------------------------------------------------------------------- /Assets/TestCustomBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 072ba1615bdd4d0fae37f41320faa043 3 | timeCreated: 1628688534 -------------------------------------------------------------------------------- /Assets/TestMathBlobBuilder.cs: -------------------------------------------------------------------------------- 1 | using Blob; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | public class TestMathBlobBuilder : MonoBehaviour 7 | { 8 | public BlobAsset Blob; 9 | 10 | public void Awake() 11 | { 12 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.Float3)} = {Blob.Value.Float3}"); 13 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.Bool2)} = {Blob.Value.Bool2}"); 14 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.Double2x2)} = {Blob.Value.Double2x2}"); 15 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.String)} = {Blob.Value.String.ToString()}"); 16 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.Int3Array)} = {string.Join(",", Blob.Value.Int3Array.ToArray())}"); 17 | Debug.Log($"{nameof(MathData)}.{nameof(MathData.Float2Ptr)} = {Blob.Value.Float2Ptr.Value}"); 18 | } 19 | } 20 | 21 | public struct MathData 22 | { 23 | public float3 Float3; 24 | public BlobString String; 25 | public bool2 Bool2; 26 | public BlobArray Int3Array; 27 | public double2x2 Double2x2; 28 | public BlobPtr Float2Ptr; 29 | } -------------------------------------------------------------------------------- /Assets/TestMathBlobBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b87079ae31944ec8c32b5fc1a21860f 3 | timeCreated: 1628679168 -------------------------------------------------------------------------------- /Assets/TestSingleBlobBuilder.cs: -------------------------------------------------------------------------------- 1 | using Blob; 2 | using Unity.Animation; 3 | using Unity.Entities; 4 | using UnityEngine; 5 | using Debug = UnityEngine.Debug; 6 | 7 | public class TestSingleBlobBuilder : MonoBehaviour 8 | { 9 | public BlobAsset Int; 10 | public BlobAsset> StringArray; 11 | public BlobAsset>>> StringArrayArray; 12 | public BlobAsset AnimationCurve; 13 | 14 | public void Awake() 15 | { 16 | Debug.Log($"{nameof(TestSingleBlobBuilder)}.{nameof(Int)} = {Int.Value}"); 17 | Debug.Log($"{nameof(TestSingleBlobBuilder)}.{nameof(StringArray)} = {TestBlobBuilder.StringArrayToString(ref StringArray.Value)}"); 18 | Debug.Log($"{nameof(TestSingleBlobBuilder)}.{nameof(AnimationCurve)}(0.5f) = {AnimationCurveEvaluator.Evaluate(0.5f, AnimationCurve.Reference)}"); 19 | Debug.Log($"{nameof(TestSingleBlobBuilder)}.{nameof(StringArrayArray)} = {StringArrayArrayToString(ref StringArrayArray.Value)}"); 20 | } 21 | 22 | private static string StringArrayArrayToString(ref BlobArray>> array) 23 | { 24 | if (array.Length == 0) return ""; 25 | 26 | var msg = ""; 27 | for (var i = 0; i < array.Length; i++) 28 | { 29 | for (var j = 0; j < array[i].Length; j++) 30 | { 31 | msg += array[i][j].Value.ToString(); 32 | msg += ","; 33 | } 34 | msg += "|"; 35 | } 36 | return msg; 37 | } 38 | } -------------------------------------------------------------------------------- /Assets/TestSingleBlobBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2dc298c008948ad9fe7bd82801ec685 3 | timeCreated: 1629277936 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 quabug 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 | -------------------------------------------------------------------------------- /Packages/blob-editor/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e268fc22f7b048828cc07be60e7d3557 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/Blob.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Blob.Editor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:2128cfde978da5c44bf90b8dda521ff6", 6 | "GUID:734d92eba21c94caba915361bd5ac177", 7 | "GUID:6d84eb5386377416e93c122a00485b68", 8 | "GUID:2bfccbc67fab343fe842fd447669165f" 9 | ], 10 | "includePlatforms": [ 11 | "Editor" 12 | ], 13 | "excludePlatforms": [], 14 | "allowUnsafeCode": true, 15 | "overrideReferences": false, 16 | "precompiledReferences": [], 17 | "autoReferenced": false, 18 | "defineConstraints": [], 19 | "versionDefines": [], 20 | "noEngineReferences": false 21 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/Blob.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d889159d69832d4badabd7539783e68 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b155f9141e6203d47be61bf9920ab524 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/ArrayBuilderDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Blob.Editor 6 | { 7 | public abstract class ArrayBuilderDrawer : PropertyDrawer 8 | { 9 | protected abstract Type FindElementType(SerializedProperty property); 10 | protected abstract string ElementsPropertyName { get; } 11 | 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | return EditorGUI.GetPropertyHeight(FindElementsProperty(property), GUIContent.none, includeChildren: true); 15 | } 16 | 17 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 18 | { 19 | var elementsProperty = FindElementsProperty(property); 20 | var builderFactory = FindElementType(property).GetBuilderFactory(customBuilder: null); 21 | for (var i = 0; i < elementsProperty.arraySize; i++) 22 | { 23 | var elementProperty = elementsProperty.GetArrayElementAtIndex(i); 24 | var element = elementProperty.GetObject(); 25 | if (element == null || element.GetType() != builderFactory.BuilderType) 26 | { 27 | elementProperty.managedReferenceValue = builderFactory.Create(); 28 | property.serializedObject.ApplyModifiedProperties(); 29 | } 30 | } 31 | EditorGUI.PropertyField(position, elementsProperty, label, includeChildren: true); 32 | property.serializedObject.ApplyModifiedProperties(); 33 | } 34 | 35 | private SerializedProperty FindElementsProperty(SerializedProperty property) => property.FindPropertyRelative(ElementsPropertyName); 36 | } 37 | 38 | [CustomPropertyDrawer(typeof(ArrayBuilder<>), useForChildren: true)] 39 | public class GenericArrayBuilderDrawer : ArrayBuilderDrawer 40 | { 41 | protected override Type FindElementType(SerializedProperty property) 42 | { 43 | return property.GetObject().GetType().FindGenericArgumentsOf(typeof(ArrayBuilder<>))[0]; 44 | } 45 | 46 | protected override string ElementsPropertyName => nameof(ArrayBuilder.Value); 47 | } 48 | 49 | [CustomPropertyDrawer(typeof(DynamicArrayBuilder))] 50 | public class DynamicArrayBuilderDrawer : ArrayBuilderDrawer 51 | { 52 | protected override Type FindElementType(SerializedProperty property) 53 | { 54 | return Type.GetType(property.FindPropertyRelative(nameof(DynamicArrayBuilder.ArrayElementType)).stringValue); 55 | } 56 | 57 | protected override string ElementsPropertyName => nameof(DynamicArrayBuilder.Value); 58 | } 59 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/ArrayBuilderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0bae2e2783894d77bc189cb8978e1de1 3 | timeCreated: 1628609407 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobAssetDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace Blob.Editor 5 | { 6 | [CustomPropertyDrawer(typeof(BlobAsset<>))] 7 | public class BlobAssetDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | property = property.FindPropertyRelative(nameof(BlobAsset.Builder)); 12 | return EditorGUI.GetPropertyHeight(property, label, true); 13 | } 14 | 15 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | var valueType = fieldInfo.FieldType.GenericTypeArguments[0]; 18 | var builderFactory = valueType.GetBuilderFactory(customBuilder: null); 19 | property = property.FindPropertyRelative(nameof(BlobAsset.Builder)); 20 | var builder = property.GetObject(); 21 | if (builder == null || builder.GetType() != builderFactory.BuilderType) 22 | { 23 | property.managedReferenceValue = builderFactory.Create(); 24 | property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); 25 | } 26 | 27 | EditorGUI.PropertyField(position, property, new GUIContent($"{label.text} : {valueType.ToReadableName()}"), true); 28 | 29 | property.serializedObject.ApplyModifiedProperties(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobAssetDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29ed3af5ba5d4d3f8ce7fcd9285498aa 3 | timeCreated: 1628755750 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobAssetV1Drawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Blob.Editor 6 | { 7 | [CustomPropertyDrawer(typeof(BlobAssetV1<>)), Obsolete("for backward compatibility of version 1 only")] 8 | public class BlobAssetV1Drawer : PropertyDrawer 9 | { 10 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 11 | { 12 | property = property.FindPropertyRelative(nameof(BlobAsset.Builder)); 13 | return EditorGUI.GetPropertyHeight(property, label, true); 14 | } 15 | 16 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 17 | { 18 | property = property.FindPropertyRelative(nameof(BlobAsset.Builder)); 19 | EditorGUI.PropertyField(position, property, new GUIContent($"{label.text} : {fieldInfo.FieldType.GenericTypeArguments[0].Name}")); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobAssetV1Drawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efbeee0f9d434ac5bc3a2ca871cf296d 3 | timeCreated: 1629281000 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobDataBuilderDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Blob.Editor 7 | { 8 | public abstract class BlobDataBuilderDrawer : PropertyDrawer 9 | { 10 | protected abstract string FieldNamePropertyName { get; } 11 | protected abstract string BuildersPropertyName { get; } 12 | protected abstract Type GetBlobType(SerializedProperty property); 13 | 14 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 15 | { 16 | var height = EditorGUIUtility.singleLineHeight; 17 | if (property.isExpanded) 18 | { 19 | var builders = Builders(property); 20 | for (var i = 0; i < builders.arraySize; i++) 21 | { 22 | var builderProperty = builders.GetArrayElementAtIndex(i); 23 | height += EditorGUI.GetPropertyHeight(builderProperty, includeChildren: true); 24 | } 25 | } 26 | return height; 27 | } 28 | 29 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 30 | { 31 | // var fieldType = fieldInfo?.FieldType; 32 | // if (fieldType == null || !typeof(Builder<>).IsAssignableFrom(fieldType)) 33 | // fieldType = property.GetObject().GetType(); 34 | // var blobType = fieldType.FindGenericArgumentsOf(typeof(Builder<>))[0]; 35 | var blobType = GetBlobType(property); 36 | var blobFields = blobType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 37 | 38 | var buildersProperty = Builders(property); 39 | buildersProperty.arraySize = blobFields.Length; 40 | var builders = (IBuilder[]) buildersProperty.GetObject(); 41 | Array.Resize(ref builders, blobFields.Length); 42 | 43 | var fieldNamesProperty = FieldNames(property); 44 | fieldNamesProperty.arraySize = blobFields.Length; 45 | var fieldNames = (string[]) fieldNamesProperty.GetObject(); 46 | Array.Resize(ref fieldNames, blobFields.Length); 47 | 48 | property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); 49 | 50 | for (var i = 0; i < blobFields.Length; i++) 51 | { 52 | var blobField = blobFields[i]; 53 | var builderFactory = blobField.FindBuilderCreator(); 54 | var builder = builders[i]; 55 | if (builder == null || builder.GetType() != builderFactory.BuilderType || blobField.Name != fieldNames[i]) 56 | { 57 | fieldNamesProperty.GetArrayElementAtIndex(i).stringValue = blobField.Name; 58 | var builderIndex = Array.IndexOf(fieldNames, blobField.Name); 59 | object newBuilder = null; 60 | if (builderIndex >= 0) newBuilder = builders[builderIndex]; 61 | else if (builder != null && builder.GetType() == builderFactory.BuilderType) newBuilder = builder; 62 | else newBuilder = builderFactory.Create(); 63 | buildersProperty.GetArrayElementAtIndex(i).managedReferenceValue = newBuilder; 64 | property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); 65 | } 66 | } 67 | 68 | position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 69 | EditorGUI.PropertyField(position, property, label); 70 | if (property.isExpanded) 71 | { 72 | EditorGUI.indentLevel++; 73 | position = EditorGUI.IndentedRect(position); 74 | var propertyHeight = position.height; 75 | for (var i = 0; i < blobFields.Length; i++) 76 | { 77 | position = new Rect(position.x, position.y + propertyHeight, position.width, position.height); 78 | var builderProperty = buildersProperty.GetArrayElementAtIndex(i); 79 | EditorGUI.PropertyField(position, builderProperty, new GUIContent(blobFields[i].Name), includeChildren: true); 80 | propertyHeight = EditorGUI.GetPropertyHeight(builderProperty, includeChildren: true); 81 | // HACK (bug?): somehow, `ApplyModifiedProperties` must be place inside `for` loop, otherwise some properties will not be changed in some cases. 82 | property.serializedObject.ApplyModifiedProperties(); 83 | } 84 | EditorGUI.indentLevel--; 85 | } 86 | property.serializedObject.ApplyModifiedProperties(); 87 | } 88 | 89 | private SerializedProperty Builders(SerializedProperty property) 90 | { 91 | return property.FindPropertyRelative(BuildersPropertyName); 92 | } 93 | 94 | private SerializedProperty FieldNames(SerializedProperty property) 95 | { 96 | return property.FindPropertyRelative(FieldNamePropertyName); 97 | } 98 | } 99 | 100 | [CustomPropertyDrawer(typeof(BlobDataBuilder<>), useForChildren: true)] 101 | public class GenericBlobDataBuilderDrawer : BlobDataBuilderDrawer 102 | { 103 | protected override string FieldNamePropertyName => nameof(BlobDataBuilder.FieldNames); 104 | protected override string BuildersPropertyName => nameof(BlobDataBuilder.Builders); 105 | protected override Type GetBlobType(SerializedProperty property) 106 | { 107 | var fieldType = fieldInfo?.FieldType; 108 | if (fieldType == null || !typeof(Builder<>).IsAssignableFrom(fieldType)) 109 | fieldType = property.GetObject().GetType(); 110 | return fieldType.FindGenericArgumentsOf(typeof(Builder<>))[0]; 111 | } 112 | } 113 | 114 | [CustomPropertyDrawer(typeof(DynamicBlobDataBuilder))] 115 | public class DynamicBlobDataBuilderDrawer : BlobDataBuilderDrawer 116 | { 117 | protected override string FieldNamePropertyName => nameof(DynamicBlobDataBuilder.FieldNames); 118 | protected override string BuildersPropertyName => nameof(DynamicBlobDataBuilder.Builders); 119 | protected override Type GetBlobType(SerializedProperty property) => 120 | Type.GetType(property.FindPropertyRelative(nameof(DynamicBlobDataBuilder.BlobDataType)).stringValue); 121 | } 122 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/BlobDataBuilderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fb3d15c79074e5e944c90b56e6f8528 3 | timeCreated: 1628587468 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/DynamicBuilderFactoryRegister.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using JetBrains.Annotations; 5 | using UnityEditor; 6 | 7 | namespace Blob.Editor 8 | { 9 | public static class DynamicBuilderFactoryRegister 10 | { 11 | private static IReadOnlyList _factories; 12 | 13 | static DynamicBuilderFactoryRegister() 14 | { 15 | _factories = TypeCache.GetTypesDerivedFrom() 16 | .Where(type => !type.IsAbstract && !type.IsGenericType) 17 | .Select(Activator.CreateInstance).Cast() 18 | .OrderBy(factory => factory.Order) 19 | .ToArray() 20 | ; 21 | } 22 | 23 | [CanBeNull] public static object Create([NotNull] Type dataType) 24 | { 25 | return _factories.FirstOrDefault(f => f.IsValid(dataType))?.Create(dataType); 26 | } 27 | 28 | [CanBeNull] public static IDynamicBuilderFactory FindFactory([NotNull] Type dataType) 29 | { 30 | return _factories.FirstOrDefault(f => f.IsValid(dataType)); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/DynamicBuilderFactoryRegister.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fff3f23154c47f1827f8e464312e67d 3 | timeCreated: 1629821249 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/EnumBuilderDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Blob.Editor 6 | { 7 | public abstract class EnumBuilderDrawer : PropertyDrawer 8 | { 9 | protected abstract object GetValue(SerializedProperty property); 10 | protected abstract void SetValue(SerializedProperty property, object value); 11 | 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | return EditorGUIUtility.singleLineHeight; 15 | } 16 | 17 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 18 | { 19 | var enumType = Type.GetType(property.FindPropertyRelative(nameof(DynamicEnumBuilder.EnumTypeName)).stringValue); 20 | var valueProperty = property.FindPropertyRelative(nameof(DynamicEnumBuilder.Value)); 21 | var value = EditorGUI.EnumPopup(position, label, (Enum)Enum.ToObject(enumType, GetValue(valueProperty))); 22 | SetValue(valueProperty, value); 23 | property.serializedObject.ApplyModifiedProperties(); 24 | } 25 | } 26 | 27 | [CustomPropertyDrawer(typeof(DynamicByteEnumBuilder))] 28 | [CustomPropertyDrawer(typeof(DynamicSByteEnumBuilder))] 29 | [CustomPropertyDrawer(typeof(DynamicShortEnumBuilder))] 30 | [CustomPropertyDrawer(typeof(DynamicUShortEnumBuilder))] 31 | [CustomPropertyDrawer(typeof(DynamicIntEnumBuilder))] 32 | [CustomPropertyDrawer(typeof(DynamicUIntEnumBuilder))] 33 | public class IntEnumBuilderDrawer : EnumBuilderDrawer 34 | { 35 | protected override object GetValue(SerializedProperty property) => property.intValue; 36 | protected override void SetValue(SerializedProperty property, object value) => property.intValue = Convert.ToInt32(value); 37 | } 38 | 39 | [CustomPropertyDrawer(typeof(DynamicLongEnumBuilder))] 40 | [CustomPropertyDrawer(typeof(DynamicULongEnumBuilder))] 41 | public class LongEnumBuilderDrawer : EnumBuilderDrawer 42 | { 43 | protected override object GetValue(SerializedProperty property) => property.longValue; 44 | protected override void SetValue(SerializedProperty property, object value) => property.longValue = Convert.ToInt64(value); 45 | } 46 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/EnumBuilderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53cfe056d95d4ca4949810c93133743b 3 | timeCreated: 1629825962 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/PtrBuilderDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Blob.Editor 6 | { 7 | public abstract class PtrBuilderDrawer : PropertyDrawer 8 | { 9 | protected abstract string PtrBuilderPropertyName { get; } 10 | protected abstract Type BlobType(SerializedProperty property); 11 | 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | var valueProperty = ValueProperty(property); 15 | return EditorGUI.GetPropertyHeight(valueProperty, GUIContent.none, includeChildren: true); 16 | } 17 | 18 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 19 | { 20 | var valueProperty = ValueProperty(property); 21 | var valueType = BlobType(property); 22 | var builderFactory = valueType.GetBuilderFactory(customBuilder: null); 23 | var value = valueProperty.GetObject(); 24 | if (value == null || value.GetType() != builderFactory.BuilderType) valueProperty.managedReferenceValue = builderFactory.Create(); 25 | EditorGUI.PropertyField(position, valueProperty, label, includeChildren: true); 26 | property.serializedObject.ApplyModifiedProperties(); 27 | } 28 | 29 | private SerializedProperty ValueProperty(SerializedProperty property) 30 | { 31 | return property.FindPropertyRelative(PtrBuilderPropertyName); 32 | } 33 | } 34 | 35 | [CustomPropertyDrawer(typeof(PtrBuilder<>), useForChildren: true)] 36 | public class GenericBlobPtrDrawer : PtrBuilderDrawer 37 | { 38 | protected override string PtrBuilderPropertyName => nameof(PtrBuilder.Value); 39 | protected override Type BlobType(SerializedProperty property) => property.GetObject().GetType().FindGenericArgumentsOf(typeof(PtrBuilder<>))[0]; 40 | } 41 | 42 | [CustomPropertyDrawer(typeof(DynamicBlobPtrDrawer))] 43 | public class DynamicBlobPtrDrawer : PtrBuilderDrawer 44 | { 45 | protected override string PtrBuilderPropertyName => nameof(DynamicPtrBuilder.Value); 46 | protected override Type BlobType(SerializedProperty property) => 47 | Type.GetType(property.FindPropertyRelative(nameof(DynamicPtrBuilder.DataType)).stringValue); 48 | } 49 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/BuilderDrawer/PtrBuilderDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6e6f659b78e465c9363e8032a439fef 3 | timeCreated: 1628682246 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Runtime.Serialization; 6 | using System.Text.RegularExpressions; 7 | using JetBrains.Annotations; 8 | using Unity.Entities; 9 | using UnityEditor; 10 | using UnityEngine; 11 | using UnityEngine.Assertions; 12 | 13 | namespace Blob.Editor 14 | { 15 | public ref struct BuilderFactory 16 | { 17 | public Type BuilderType { get; } 18 | private readonly Func _creator; 19 | 20 | public BuilderFactory([NotNull] Type builderType) 21 | { 22 | BuilderType = builderType; 23 | _creator = () => Activator.CreateInstance(builderType); 24 | } 25 | 26 | public BuilderFactory([NotNull] Type builderType, [NotNull] Func creator) 27 | { 28 | BuilderType = builderType; 29 | _creator = creator; 30 | } 31 | 32 | public object Create() => _creator(); 33 | } 34 | 35 | public static class Extensions 36 | { 37 | public static object GetSiblingValue(this SerializedProperty property, string name) 38 | { 39 | var obj = GetDeclaringObject(property); 40 | var type = obj.GetType(); 41 | var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; 42 | var fieldInfo = type.GetField(name, flags); 43 | if (fieldInfo != null) return fieldInfo.GetValue(obj); 44 | var propertyInfo = type.GetProperty(name, flags); 45 | if (propertyInfo != null) return propertyInfo.GetValue(obj); 46 | var methodInfo = type.GetMethod(name, flags); 47 | return methodInfo.Invoke(obj, Array.Empty()); 48 | } 49 | 50 | public static object GetSiblingFieldValue(this SerializedProperty property, string fieldName) 51 | { 52 | var obj = GetDeclaringObject(property); 53 | var fieldInfo = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 54 | return fieldInfo.GetValue(obj); 55 | } 56 | 57 | public static PropertyInfo GetSiblingPropertyInfo(this SerializedProperty property, string propertyName) 58 | { 59 | var obj = GetDeclaringObject(property); 60 | return obj.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 61 | } 62 | 63 | public static MethodInfo GetSiblingMethodInfo(this SerializedProperty property, string methodName) 64 | { 65 | var obj = GetDeclaringObject(property); 66 | return obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 67 | } 68 | 69 | public static object GetDeclaringObject(this SerializedProperty property) 70 | { 71 | return property.GetFieldsByPath().Reverse().Skip(1).First().field; 72 | } 73 | 74 | public static object GetObject(this SerializedProperty property) 75 | { 76 | return property.GetFieldsByPath().Last().field; 77 | } 78 | 79 | private static Regex _arrayData = new Regex(@"^data\[(\d+)\]$"); 80 | 81 | public static IEnumerable<(object field, FieldInfo fi)> GetFieldsByPath(this SerializedProperty property) 82 | { 83 | var obj = (object)property.serializedObject.targetObject; 84 | FieldInfo fi = null; 85 | yield return (obj, fi); 86 | var pathList = property.propertyPath.Split('.'); 87 | for (var i = 0; i < pathList.Length; i++) 88 | { 89 | var fieldName = pathList[i]; 90 | if (fieldName == "Array" && i + 1 < pathList.Length && _arrayData.IsMatch(pathList[i + 1])) 91 | { 92 | i++; 93 | var itemIndex = int.Parse(_arrayData.Match(pathList[i]).Groups[1].Value); 94 | var array = ((Array)obj); 95 | obj = array != null && itemIndex < array.Length ? array.GetValue(itemIndex) : null; 96 | yield return (obj, fi); 97 | } 98 | else 99 | { 100 | var t = Field(obj, obj?.GetType() ?? fi.FieldType, fieldName); 101 | obj = t.field; 102 | fi = t.fi; 103 | yield return t; 104 | } 105 | } 106 | 107 | (object field, FieldInfo fi) Field(object declaringObject, Type declaringType, string fieldName) 108 | { 109 | var fieldInfo = declaringType.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 110 | var fieldValue = declaringObject == null ? null : fieldInfo.GetValue(declaringObject); 111 | return (fieldValue, fieldInfo); 112 | } 113 | } 114 | 115 | internal static (Regex, string) ParseReplaceRegex(this string pattern, string separator = "||") 116 | { 117 | if (string.IsNullOrEmpty(pattern)) return (null, null); 118 | var patterns = pattern.Split(new[] { separator }, StringSplitOptions.None); 119 | if (patterns.Length == 2) return (new Regex(patterns[0]), patterns[1]); 120 | throw new ArgumentException($"invalid number of separator ({separator}) in pattern ({pattern})"); 121 | } 122 | 123 | public static (object field, FieldInfo fieldInfo) GetTargetField(this SerializedProperty property) 124 | { 125 | return property.GetFieldsByPath().ElementAt(1); 126 | } 127 | 128 | public static (object field, FieldInfo fieldInfo) GetPropertyField(this SerializedProperty property) 129 | { 130 | return property.GetFieldsByPath().Last(); 131 | } 132 | 133 | public static FieldInfo GetTargetFieldInfo(this SerializedProperty property) 134 | { 135 | return property.GetFieldsByPath().ElementAt(1).fi; 136 | } 137 | 138 | public static Type GetGenericType(this PropertyDrawer propertyDrawer) 139 | { 140 | return propertyDrawer.fieldInfo.DeclaringType.GetGenericType(); 141 | } 142 | 143 | public static T GetCustomAttribute(this SerializedProperty property) where T : Attribute 144 | { 145 | var (_, fieldInfo) = property.GetPropertyField(); 146 | return fieldInfo.GetCustomAttribute(); 147 | } 148 | 149 | public static FieldInfo GetTargetFieldInfo(this SerializedProperty property, string fieldName) 150 | { 151 | const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; 152 | return property.serializedObject.targetObject.GetType().GetField(fieldName, flags); 153 | } 154 | 155 | public static Type GetGenericType(this Type type) 156 | { 157 | while (type != null) 158 | { 159 | if (type.IsGenericType) return type.GenericTypeArguments.FirstOrDefault(); 160 | type = type.BaseType; 161 | } 162 | 163 | return null; 164 | } 165 | 166 | public static Func PopupFunc(this SerializedProperty property) 167 | { 168 | return (position, label, options) => 169 | { 170 | var optionIndex = Array.IndexOf(options, property.stringValue); 171 | if (optionIndex < 0) optionIndex = 0; 172 | optionIndex = EditorGUI.Popup(position, label, optionIndex, options); 173 | property.stringValue = optionIndex < options.Length ? options[optionIndex] : ""; 174 | return optionIndex; 175 | }; 176 | } 177 | 178 | public static IEnumerable GetVisibleChildren(this SerializedProperty serializedProperty) 179 | { 180 | var iter = serializedProperty.Copy(); 181 | var end = serializedProperty.GetEndProperty(); 182 | iter.NextVisible(true); 183 | while (!SerializedProperty.EqualContents(iter, end)) 184 | { 185 | yield return iter.Copy(); 186 | iter.NextVisible(false); 187 | } 188 | } 189 | 190 | private static Func _getDrawerTypeForPropertyAndType; 191 | 192 | public static Type GetDrawerTypeForPropertyAndType(this SerializedProperty property, Type type) 193 | { 194 | if (_getDrawerTypeForPropertyAndType == null) 195 | { 196 | var internalMethod = typeof(PropertyDrawer).Assembly 197 | .GetType("UnityEditor.ScriptAttributeUtility") 198 | .GetMethod("GetDrawerTypeForPropertyAndType", BindingFlags.Static | BindingFlags.NonPublic) 199 | ; 200 | _getDrawerTypeForPropertyAndType = (Func)internalMethod.CreateDelegate(typeof(Func)); 201 | } 202 | return _getDrawerTypeForPropertyAndType(property, type); 203 | } 204 | 205 | public static Type[] FindGenericArgumentsOf(this Type type, Type baseType) 206 | { 207 | Assert.IsTrue(baseType.IsGenericType); 208 | while (type != null) 209 | { 210 | if (type.IsGenericType && type.GetGenericTypeDefinition() == baseType) 211 | return type.GenericTypeArguments; 212 | type = type.BaseType; 213 | } 214 | 215 | throw new ArgumentException(); 216 | } 217 | 218 | public static SerializedProperty FindProperProperty(this SerializedProperty self) 219 | { 220 | var type = self?.GetObject()?.GetType(); 221 | var customDrawer = type == null ? null : self.GetDrawerTypeForPropertyAndType(type); 222 | if (type != null && customDrawer == null) 223 | { 224 | var children = self.GetVisibleChildren().ToArray(); 225 | if (children.Length == 1) return children[0]; 226 | } 227 | 228 | return self; 229 | } 230 | 231 | public static IEnumerable Yield(this T value) 232 | { 233 | yield return value; 234 | } 235 | 236 | public static BuilderFactory FindBuilderCreator([NotNull] this FieldInfo fieldInfo) 237 | { 238 | var customBuilder = fieldInfo.GetCustomAttribute()?.BuilderType; 239 | return GetBuilderFactory(fieldInfo.FieldType, customBuilder); 240 | } 241 | 242 | public static BuilderFactory GetBuilderFactory([NotNull] this Type valueType, Type customBuilder) 243 | { 244 | var builderType = typeof(Builder<>).MakeGenericType(valueType); 245 | var builders = TypeCache.GetTypesDerivedFrom(builderType); 246 | if (customBuilder == null && builders.Count == 1) return new BuilderFactory(builders[0]); 247 | if (customBuilder != null && builders.Contains(customBuilder)) return new BuilderFactory(customBuilder); 248 | if (customBuilder != null) throw new InvalidCustomBuilderException($"Invalid {customBuilder.Name} of {valueType.Name}, must be one of [{string.Join(",", builders.Select(b => b.Name))}]"); 249 | 250 | try 251 | { 252 | var defaultBuilder = builders.SingleOrDefault(b => b.GetCustomAttribute() != null); 253 | return defaultBuilder == null ? DynamicBuilder() : new BuilderFactory(defaultBuilder); 254 | } 255 | catch (Exception ex) 256 | { 257 | throw new MultipleBuildersException($"There's multiple builders [{string.Join(",", builders.Select(b => b.Name))}] for {valueType.Name}, must mark one of them as `DefaultBuilder` or use `CustomBuilder` on this field", ex); 258 | } 259 | 260 | BuilderFactory DynamicBuilder() 261 | { 262 | var factory = DynamicBuilderFactoryRegister.FindFactory(valueType); 263 | if (factory == null) throw new ArgumentException($"cannot find any builder for {valueType}"); 264 | return new BuilderFactory(factory.BuilderType, () => factory.Create(valueType)); 265 | } 266 | } 267 | } 268 | 269 | [Serializable] 270 | public class InvalidCustomBuilderException : Exception 271 | { 272 | public InvalidCustomBuilderException() {} 273 | public InvalidCustomBuilderException(string message) : base(message) {} 274 | public InvalidCustomBuilderException(string message, Exception inner) : base(message, inner) {} 275 | protected InvalidCustomBuilderException(SerializationInfo info, StreamingContext context) : base(info, context) {} 276 | } 277 | 278 | [Serializable] 279 | public class MultipleBuildersException : Exception 280 | { 281 | public MultipleBuildersException() {} 282 | public MultipleBuildersException(string message) : base(message) {} 283 | public MultipleBuildersException(string message, Exception inner) : base(message, inner) {} 284 | protected MultipleBuildersException(SerializationInfo info, StreamingContext context) : base(info, context) {} 285 | } 286 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80ce86ec046e43e0afce9f99f6cbeafa 3 | timeCreated: 1628590437 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f109cfb92fa42c294518ea2a8f21ab4 3 | timeCreated: 1628656267 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/BaseMultiPropertyDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Blob.Editor 7 | { 8 | public abstract class BaseMultiPropertyDrawer : IMultiPropertyDrawer 9 | { 10 | public MultiPropertyAttribute Decorator { protected get; set; } 11 | public IReadOnlyList SortedDrawers { protected get; set; } 12 | public int AttributeIndex { get; set; } 13 | public FieldInfo FieldInfo { protected get; set; } 14 | 15 | protected IMultiPropertyDrawer NextDrawer => AttributeIndex + 1 < SortedDrawers.Count 16 | ? SortedDrawers[AttributeIndex + 1] 17 | : null 18 | ; 19 | 20 | public virtual void OnGUI(Rect position, SerializedProperty property, GUIContent label) 21 | { 22 | OnGUISelf(position, property, label); 23 | NextDrawer?.OnGUI(position, property, label); 24 | } 25 | 26 | public virtual float GetPropertyHeight(SerializedProperty property, GUIContent label) 27 | { 28 | return NextDrawer?.GetPropertyHeight(property, label) ?? EditorGUI.GetPropertyHeight(property, true); 29 | } 30 | 31 | protected virtual void OnGUISelf(Rect position, SerializedProperty property, GUIContent label) {} 32 | } 33 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/BaseMultiPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 654306f3617b44f2b9a0eb338c706685 3 | timeCreated: 1612007616 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/CustomMultiPropertyDrawerAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using JetBrains.Annotations; 3 | 4 | namespace Blob.Editor 5 | { 6 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] 7 | [BaseTypeRequired(typeof(IMultiPropertyDrawer))] 8 | public class CustomMultiPropertyDrawerAttribute : Attribute 9 | { 10 | internal readonly Type Type; 11 | internal readonly bool UseForChildren; 12 | 13 | public CustomMultiPropertyDrawerAttribute(Type type, bool useForChildren = false) 14 | { 15 | Type = type; 16 | UseForChildren = useForChildren; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/CustomMultiPropertyDrawerAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69e1a0c5bc8340a7a0f11c6ea49fa5d0 3 | timeCreated: 1612013933 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/IMultiPropertyDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Blob.Editor 7 | { 8 | public interface IMultiPropertyDrawer 9 | { 10 | MultiPropertyAttribute Decorator { set; } 11 | IReadOnlyList SortedDrawers { set; } 12 | int AttributeIndex { set; } 13 | FieldInfo FieldInfo { set; } 14 | 15 | void OnGUI(Rect position, SerializedProperty property, GUIContent label); 16 | float GetPropertyHeight(SerializedProperty property, GUIContent label); 17 | } 18 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/IMultiPropertyDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b4cc0b7a5c8432393fca09a9a75a164 3 | timeCreated: 1612002023 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/MultiPropertyDrawerRegister.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Linq; 5 | using System.Reflection; 6 | using JetBrains.Annotations; 7 | using UnityEditor; 8 | using UnityEngine; 9 | 10 | namespace Blob.Editor 11 | { 12 | public static class MultiPropertyDrawerRegister 13 | { 14 | public delegate void DrawFunc(Rect position, UnityEditor.SerializedProperty property, GUIContent label); 15 | public delegate float GetHeightFunc(SerializedProperty property, GUIContent label); 16 | 17 | private class DrawerEntry : IEquatable 18 | { 19 | internal readonly Type Type; 20 | internal readonly CustomMultiPropertyDrawerAttribute Attribute; 21 | 22 | public DrawerEntry(Type type, CustomMultiPropertyDrawerAttribute attribute) 23 | { 24 | Type = type; 25 | Attribute = attribute; 26 | } 27 | 28 | public bool Equals(DrawerEntry other) 29 | { 30 | return Equals(Type, other.Type) && Equals(Attribute, other.Attribute); 31 | } 32 | 33 | public override bool Equals(object obj) 34 | { 35 | return obj is DrawerEntry other && Equals(other); 36 | } 37 | 38 | public override int GetHashCode() 39 | { 40 | unchecked 41 | { 42 | return ((Type != null ? Type.GetHashCode() : 0) * 397) ^ (Attribute != null ? Attribute.GetHashCode() : 0); 43 | } 44 | } 45 | } 46 | 47 | private static readonly IReadOnlyDictionary _drawerRegister; 48 | private static readonly IDictionary> _drawers; 49 | 50 | static MultiPropertyDrawerRegister() 51 | { 52 | _drawers = new Dictionary>(); 53 | _drawerRegister = new ReadOnlyDictionary( 54 | ( 55 | from drawerType in TypeCache.GetTypesWithAttribute() 56 | from attribute in GetCustomPropertyDrawerAttribute(drawerType).Yield() 57 | where attribute != null 58 | select (drawerType, attribute, attributeType: attribute.Type) 59 | ).ToDictionary(t => t.attributeType, t => new DrawerEntry(t.drawerType, t.attribute)) 60 | ); 61 | 62 | CustomMultiPropertyDrawerAttribute GetCustomPropertyDrawerAttribute(Type type) 63 | { 64 | if (type.IsInterface) return null; 65 | if (type.IsAbstract) return null; 66 | if (type.IsGenericType) return null; 67 | if (!typeof(IMultiPropertyDrawer).IsAssignableFrom(type)) return null; 68 | var attribute = type.GetCustomAttribute(); 69 | if (!typeof(MultiPropertyAttribute).IsAssignableFrom(attribute.Type)) 70 | { 71 | Debug.LogError($"{attribute.GetType().FullName}.{nameof(attribute.Type)} must be a type of {nameof(MultiPropertyAttribute)}"); 72 | return null; 73 | } 74 | return attribute; 75 | } 76 | } 77 | 78 | internal static GetHeightFunc GetHeight([NotNull] MultiPropertyUnityDrawer self) 79 | { 80 | return (property, label) => GetOrCreateDrawer(self).FirstOrDefault()?.GetPropertyHeight(property, label) 81 | ?? EditorGUI.GetPropertyHeight(property, true); 82 | } 83 | 84 | internal static DrawFunc DrawMultiProperty([NotNull] MultiPropertyUnityDrawer self) 85 | { 86 | return (position, property, label) => GetOrCreateDrawer(self).FirstOrDefault()?.OnGUI(position, property, label); 87 | } 88 | 89 | private static IReadOnlyList GetOrCreateDrawer([NotNull] MultiPropertyUnityDrawer self) 90 | { 91 | if (_drawers.TryGetValue(self, out var drawerList)) return drawerList; 92 | var attributes = self.fieldInfo 93 | .GetCustomAttributes() 94 | .OrderBy(attribute => attribute.order) 95 | .ToArray() 96 | ; 97 | var drawers = new List(attributes.Length); 98 | for (var i = 0; i < attributes.Length; i++) 99 | { 100 | var type = attributes[i].GetType(); 101 | var drawerEntry = FindEntry(type); 102 | if (drawerEntry.Attribute.Type != type && !drawerEntry.Attribute.UseForChildren) 103 | { 104 | Debug.LogError($"Cannot create drawer of {type.FullName}"); 105 | } 106 | else 107 | { 108 | var drawer = (IMultiPropertyDrawer)Activator.CreateInstance(drawerEntry.Type); 109 | drawer.SortedDrawers = drawers; 110 | drawer.Decorator = attributes[i]; 111 | drawer.AttributeIndex = i; 112 | drawer.FieldInfo = self.fieldInfo; 113 | drawers.Add(drawer); 114 | } 115 | } 116 | _drawers[self] = drawers; 117 | return drawers; 118 | 119 | DrawerEntry FindEntry(Type attributeType) 120 | { 121 | if (attributeType == null) return null; 122 | if (_drawerRegister.TryGetValue(attributeType, out var entry)) return entry; 123 | return FindEntry(attributeType.BaseType); 124 | } 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/MultiPropertyDrawerRegister.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7cec711960db404e9db1ac8663365062 3 | timeCreated: 1612005069 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/MultiPropertyUnityDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace Blob.Editor 5 | { 6 | [CustomPropertyDrawer(typeof(MultiPropertyAttribute), true)] 7 | public class MultiPropertyUnityDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | // [optimize] TODO: only call last `GetHeight` of same `fieldInfo` in one frame 12 | return MultiPropertyDrawerRegister.GetHeight(this)(property, label); 13 | } 14 | 15 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | // [optimize] TODO: only call last `DrawMultiProperty` of same `fieldInfo` in one frame 18 | MultiPropertyDrawerRegister.DrawMultiProperty(this)(position, property, label); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/MultiPropertyUnityDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27d79a8326324e59b8219380df7dd108 3 | timeCreated: 1611216130 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/UnboxSinglePropertyAttributeDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace Blob.Editor 5 | { 6 | [CustomMultiPropertyDrawer(typeof(UnboxSinglePropertyAttribute))] 7 | public class UnboxSinglePropertyAttributeDrawer : BaseMultiPropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | property = property.FindProperProperty(); 12 | return base.GetPropertyHeight(property, label); 13 | } 14 | 15 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | property = property.FindProperProperty(); 18 | base.OnGUI(position, property, label); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/UnboxSinglePropertyAttributeDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c6134ea21be418a870c6660fa87a45c 3 | timeCreated: 1628657980 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/UnityDrawPropertyAttributeDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Blob.Editor 6 | { 7 | [CustomMultiPropertyDrawer(typeof(UnityDrawPropertyAttribute))] 8 | public class UnityDrawPropertyAttributeDrawer : BaseMultiPropertyDrawer 9 | { 10 | private class DefaultDrawer : PropertyDrawer 11 | { 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | return EditorGUI.GetPropertyHeight(property, label, includeChildren: true); 15 | } 16 | 17 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 18 | { 19 | EditorGUI.PropertyField(position, property, label, includeChildren: true); 20 | } 21 | } 22 | 23 | private PropertyDrawer _customDrawer; 24 | 25 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 26 | { 27 | return GetOrCreateCustomDrawer(property).GetPropertyHeight(property, label); 28 | } 29 | 30 | protected override void OnGUISelf(Rect position, UnityEditor.SerializedProperty property, GUIContent label) 31 | { 32 | GetOrCreateCustomDrawer(property).OnGUI(position, property, label); 33 | } 34 | 35 | PropertyDrawer GetOrCreateCustomDrawer(SerializedProperty property) 36 | { 37 | if (_customDrawer != null) return _customDrawer; 38 | 39 | var propertyType = property?.GetObject()?.GetType(); 40 | var customDrawerType = propertyType != null ? property.GetDrawerTypeForPropertyAndType(propertyType) : null; 41 | if (customDrawerType == null) 42 | { 43 | _customDrawer = new DefaultDrawer(); 44 | } 45 | else 46 | { 47 | _customDrawer = (PropertyDrawer) Activator.CreateInstance(customDrawerType); 48 | } 49 | return _customDrawer; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/MultiProperty/UnityDrawPropertyAttributeDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4776d7b52f6a40bf98188f3b8b9d79b9 3 | timeCreated: 1612016946 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9902b3b7cf154c94930f411951a9b376 3 | timeCreated: 1629897352 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/BlobDataViewerDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace Blob.Editor 7 | { 8 | [CustomPropertyDrawer(typeof(DynamicBlobDataViewer))] 9 | public class BlobDataViewerDrawer : PropertyDrawer 10 | { 11 | public Type GetBlobType(SerializedProperty property) 12 | { 13 | return Type.GetType(property.FindPropertyRelative(nameof(DynamicBlobDataViewer.TypeName)).stringValue); 14 | } 15 | 16 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 17 | { 18 | var height = EditorGUIUtility.singleLineHeight; 19 | if (property.isExpanded) 20 | { 21 | var viewers = FieldsViewer(property); 22 | for (var i = 0; i < viewers.arraySize; i++) 23 | { 24 | var viewProperty = viewers.GetArrayElementAtIndex(i); 25 | height += EditorGUI.GetPropertyHeight(viewProperty, includeChildren: true); 26 | } 27 | } 28 | return height; 29 | } 30 | 31 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 32 | { 33 | var blobType = GetBlobType(property); 34 | var blobFields = blobType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 35 | 36 | position = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); 37 | EditorGUI.PropertyField(position, property, label); 38 | 39 | if (property.isExpanded) 40 | { 41 | var viewers = FieldsViewer(property); 42 | EditorGUI.indentLevel++; 43 | position = EditorGUI.IndentedRect(position); 44 | var propertyHeight = position.height; 45 | for (var i = 0; i < blobFields.Length; i++) 46 | { 47 | position = new Rect(position.x, position.y + propertyHeight, position.width, position.height); 48 | var viewProperty = viewers.GetArrayElementAtIndex(i); 49 | EditorGUI.PropertyField(position, viewProperty, new GUIContent(blobFields[i].Name), includeChildren: true); 50 | propertyHeight = EditorGUI.GetPropertyHeight(viewProperty, includeChildren: true); 51 | } 52 | EditorGUI.indentLevel--; 53 | } 54 | } 55 | 56 | private SerializedProperty FieldsViewer(SerializedProperty property) 57 | { 58 | return property.FindPropertyRelative(nameof(DynamicBlobDataViewer.FieldsViewer)); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/BlobDataViewerDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a2e7c5328324733a8538f209f09ac6e 3 | timeCreated: 1629898445 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/BlobViewerDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace Blob.Editor 5 | { 6 | [CustomPropertyDrawer(typeof(BlobViewer))] 7 | public class BlobViewerDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | property = property.FindPropertyRelative(nameof(BlobViewer.Viewer)); 12 | return EditorGUI.GetPropertyHeight(property, label, true); 13 | } 14 | 15 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 16 | { 17 | var typeName = property.FindPropertyRelative(nameof(BlobViewer.TypeName)).stringValue; 18 | var writable = property.FindPropertyRelative(nameof(BlobViewer.Writable)).boolValue; 19 | var enabled = GUI.enabled; 20 | GUI.enabled = writable; 21 | property = property.FindPropertyRelative(nameof(BlobViewer.Viewer)); 22 | EditorGUI.PropertyField(position, property, new GUIContent($"{label.text} : {typeName}"), true); 23 | GUI.enabled = enabled; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/BlobViewerDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e41cc94c3ad54e578a8ab67beca58e45 3 | timeCreated: 1629897387 -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/EnumViewerDrawer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace Blob.Editor 8 | { 9 | [CustomPropertyDrawer(typeof(DynamicEnumViewer))] 10 | public class EnumViewerDrawer : PropertyDrawer 11 | { 12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 13 | { 14 | return EditorGUIUtility.singleLineHeight; 15 | } 16 | 17 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 18 | { 19 | var enumType = Type.GetType(property.FindPropertyRelative(nameof(DynamicEnumViewer.EnumType)).stringValue); 20 | var dataPtr = new IntPtr(property.FindPropertyRelative(nameof(DynamicEnumViewer.Ptr)).longValue); 21 | EditorGUI.EnumPopup(position, label, (Enum)Enum.ToObject(enumType, GetEnum(enumType, dataPtr))); 22 | } 23 | 24 | Enum GetEnum(Type enumType, IntPtr dataPtr) 25 | { 26 | var underlingType = Enum.GetUnderlyingType(enumType); 27 | var value = Marshal.PtrToStructure(dataPtr, underlingType); 28 | return (Enum)Enum.ToObject(enumType, value); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Editor/ViewerDrawer/EnumViewerDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09b5700d264a4c2a806c1442158057e5 3 | timeCreated: 1629898993 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90de4396db5af96488e0234f6ddf767c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 732aac8c13958024dab598ab3a3d9f64 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/MultiPropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using UnityEngine; 4 | 5 | namespace Blob 6 | { 7 | [AttributeUsage(AttributeTargets.Field)] 8 | [Conditional("UNITY_EDITOR")] 9 | public abstract class MultiPropertyAttribute : PropertyAttribute { } 10 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/MultiPropertyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4860a88192b84b36a79c60a1c57d5fda 3 | timeCreated: 1611215663 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/UnboxSinglePropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Blob 2 | { 3 | public class UnboxSinglePropertyAttribute : MultiPropertyAttribute {} 4 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/UnboxSinglePropertyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ade5f4ff2cf4d54bf9f9c48f9432f2e 3 | timeCreated: 1628657997 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/UnityDrawPropertyAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Blob 2 | { 3 | public class UnityDrawPropertyAttribute : MultiPropertyAttribute 4 | { 5 | public UnityDrawPropertyAttribute() => order = int.MaxValue; 6 | } 7 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Attribute/UnityDrawPropertyAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e77d20c44c74084a1009230ba7ddd26 3 | timeCreated: 1612001091 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/BlobEditor.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BlobEditor", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:734d92eba21c94caba915361bd5ac177" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": true, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/BlobEditor.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d84eb5386377416e93c122a00485b68 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8262678920e05540a13d1870cf4bc01 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/AnimationCurveBlobBuilder.cs: -------------------------------------------------------------------------------- 1 | #if ENABLE_UNITY_ANIMATION 2 | 3 | using Unity.Animation; 4 | using Unity.Animation.Hybrid; 5 | using Unity.Entities; 6 | using AnimationCurve = UnityEngine.AnimationCurve; 7 | 8 | namespace Blob 9 | { 10 | public class AnimationCurveBlobBuilder : Builder 11 | { 12 | public AnimationCurve Value; 13 | public override void Build(BlobBuilder builder, ref AnimationCurveBlob data) 14 | { 15 | CurveConversion.FillAnimationCurveBlob(Value, ref builder, ref data); 16 | } 17 | } 18 | } 19 | 20 | #endif -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/AnimationCurveBlobBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b118eef3d6c947d385fce7d90d59069f 3 | timeCreated: 1628857824 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Blob.Editor")] -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a765b761b5b24277bd1c2ffc1e023dac 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/Blob.Builder.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Blob.Builder", 3 | "rootNamespace": "Blob.Builder", 4 | "references": [ 5 | "GUID:734d92eba21c94caba915361bd5ac177", 6 | "GUID:d8b63aba1907145bea998dd612889d6b", 7 | "GUID:39174d49d2befe84d9c54bf8b8d32755", 8 | "GUID:cf3547b97f3ec664f9eca740d393c07c", 9 | "GUID:6d84eb5386377416e93c122a00485b68" 10 | ], 11 | "includePlatforms": [], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": true, 14 | "overrideReferences": false, 15 | "precompiledReferences": [], 16 | "autoReferenced": true, 17 | "defineConstraints": [], 18 | "versionDefines": [ 19 | { 20 | "name": "com.unity.mathematics", 21 | "expression": "1.0.1", 22 | "define": "ENABLE_UNITY_MATHEMATICS" 23 | }, 24 | { 25 | "name": "com.unity.animation", 26 | "expression": "0.7.1-preview.2", 27 | "define": "ENABLE_UNITY_ANIMATION" 28 | } 29 | ], 30 | "noEngineReferences": false 31 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/Blob.Builder.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2128cfde978da5c44bf90b8dda521ff6 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/BlobAsset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using Unity.Entities; 5 | using UnityEngine; 6 | 7 | namespace Blob 8 | { 9 | [Serializable] 10 | public class BlobAsset where T : unmanaged 11 | { 12 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] internal IBuilder Builder; 13 | 14 | BlobAssetReference _blobAssetReference; 15 | 16 | public BlobAssetReference Reference 17 | { 18 | get 19 | { 20 | if (!_blobAssetReference.IsCreated) _blobAssetReference = Create(); 21 | return _blobAssetReference; 22 | } 23 | } 24 | 25 | public ref T Value => ref Reference.Value; 26 | 27 | private unsafe BlobAssetReference Create() 28 | { 29 | using var builder = new BlobBuilder(Allocator.Temp); 30 | ref var root = ref builder.ConstructRoot(); 31 | Builder.Build(builder, new IntPtr(UnsafeUtility.AddressOf(ref root))); 32 | return builder.CreateBlobAssetReference(Allocator.Persistent); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/BlobAsset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 481d7049cf464faabb3079cd680f04db 3 | timeCreated: 1628752168 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/BlobAssetV1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | 5 | namespace Blob 6 | { 7 | [Serializable, Obsolete("for backward compatibility of version 1 only")] 8 | public class BlobAssetV1 where T : unmanaged 9 | { 10 | public BlobDataBuilder Builder; 11 | 12 | BlobAssetReference _blobAssetReference; 13 | 14 | public BlobAssetReference Reference 15 | { 16 | get 17 | { 18 | if (!_blobAssetReference.IsCreated) _blobAssetReference = Create(); 19 | return _blobAssetReference; 20 | } 21 | } 22 | 23 | public ref T Value => ref Reference.Value; 24 | 25 | private BlobAssetReference Create() 26 | { 27 | using var builder = new BlobBuilder(Allocator.Temp); 28 | ref var root = ref builder.ConstructRoot(); 29 | Builder.Build(builder, ref root); 30 | return builder.CreateBlobAssetReference(Allocator.Persistent); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/BlobAssetV1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7192cc789abe47948e51bbc5b2ec512c 3 | timeCreated: 1629280781 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/Builders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using Unity.Entities; 5 | using UnityEngine; 6 | 7 | namespace Blob 8 | { 9 | public interface IBuilder 10 | { 11 | void Build(BlobBuilder builder, IntPtr dataPtr); 12 | } 13 | 14 | public abstract class Builder : IBuilder where T : unmanaged 15 | { 16 | public unsafe void Build(BlobBuilder builder, IntPtr dataPtr) 17 | { 18 | Build(builder, ref UnsafeUtility.AsRef(dataPtr.ToPointer())); 19 | } 20 | 21 | public abstract void Build(BlobBuilder builder, ref T data); 22 | } 23 | 24 | /// 25 | /// Builder of POD. 26 | /// Show the POD as whole in inspector. 27 | /// Not support data with its own builder, e.g. `BlobPtr`, `BlobArray` and `BlobString`. 28 | /// 29 | /// type of POD 30 | [Serializable] 31 | public class PlainDataBuilder : Builder where T : unmanaged 32 | { 33 | public T Value; 34 | 35 | public override void Build(BlobBuilder builder, ref T data) 36 | { 37 | data = Value; 38 | } 39 | } 40 | 41 | /// 42 | /// Builder of structure with `Blob` data inside. 43 | /// Split each data inside structure into its own builder to show and edit. 44 | /// Support data with and , e.g. `BlobPtr`, `BlobArray` and `BlobString` 45 | /// 46 | /// type of blob structure 47 | [Serializable] 48 | public class BlobDataBuilder : Builder where T : unmanaged 49 | { 50 | [HideInInspector] public string[] FieldNames; 51 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder[] Builders; 52 | 53 | public override unsafe void Build(BlobBuilder builder, ref T data) 54 | { 55 | var dataPtr = new IntPtr(UnsafeUtility.AddressOf(ref data)); 56 | var fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 57 | for (var i = 0; i < Builders.Length; i++) 58 | { 59 | var offset = UnsafeUtility.GetFieldOffset(fields[i]); 60 | Builders[i].Build(builder, dataPtr + offset); 61 | } 62 | } 63 | } 64 | 65 | [Serializable] 66 | public class ArrayBuilder : Builder> where T : unmanaged 67 | { 68 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder[] Value; 69 | 70 | public override void Build(BlobBuilder builder, ref BlobArray data) 71 | { 72 | var arrayBuilder = builder.Allocate(ref data, Value.Length); 73 | for (var i = 0; i < Value.Length; i++) ((Builder)Value[i]).Build(builder, ref arrayBuilder[i]); 74 | } 75 | } 76 | 77 | [Serializable, DefaultBuilder] 78 | public class StringBuilder : Builder 79 | { 80 | public string Value; 81 | 82 | public override void Build(BlobBuilder builder, ref BlobString data) 83 | { 84 | builder.AllocateString(ref data, Value); 85 | } 86 | } 87 | 88 | [DefaultBuilder] public class StringArrayBuilder : ArrayBuilder {} 89 | [DefaultBuilder] public class StringPtrBuilder : PtrBuilder {} 90 | 91 | [Serializable] 92 | public class PtrBuilder : Builder> where T : unmanaged 93 | { 94 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder Value; 95 | 96 | public override unsafe void Build(BlobBuilder builder, ref BlobPtr data) 97 | { 98 | ref var value = ref builder.Allocate(ref data); 99 | Value.Build(builder, new IntPtr(UnsafeUtility.AddressOf(ref value))); 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/Builders.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0722af89cc150224090b657b99cf3f2e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/CustomBuilderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Assertions; 3 | 4 | namespace Blob 5 | { 6 | [AttributeUsage(AttributeTargets.Field)] 7 | public class CustomBuilderAttribute : Attribute 8 | { 9 | public Type BuilderType; 10 | public CustomBuilderAttribute(Type builderType) 11 | { 12 | Assert.IsTrue(typeof(IBuilder).IsAssignableFrom(builderType)); 13 | BuilderType = builderType; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/CustomBuilderAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 732ae06651a2d2b4482c48b8e5ca14e8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/DefaultBuilderAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Blob 4 | { 5 | [AttributeUsage(AttributeTargets.Class)] 6 | public class DefaultBuilderAttribute : Attribute {} 7 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/DefaultBuilderAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9033348b004147f3a811195d5af81e7d 3 | timeCreated: 1628688642 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/DynamicBuilders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using Unity.Entities; 5 | using UnityEngine; 6 | 7 | namespace Blob 8 | { 9 | public interface IDynamicBuilderFactory 10 | { 11 | public int Order { get; } 12 | public Type BuilderType { get; } 13 | public bool IsValid(Type dataType); 14 | public object Create(Type dataType); 15 | } 16 | 17 | public abstract class DynamicBuilderFactory : IDynamicBuilderFactory where T : IBuilder 18 | { 19 | public virtual int Order => 0; 20 | public Type BuilderType => typeof(T); 21 | public abstract bool IsValid(Type dataType); 22 | public abstract object Create(Type dataType); 23 | } 24 | 25 | [Serializable] 26 | public class DynamicEnumBuilder : IBuilder where T : unmanaged 27 | { 28 | public string EnumTypeName; 29 | public T Value; 30 | 31 | public unsafe void Build(BlobBuilder builder, IntPtr dataPtr) 32 | { 33 | UnsafeUtility.AsRef(dataPtr.ToPointer()) = Value; 34 | } 35 | 36 | public class Factory : DynamicBuilderFactory where U : DynamicEnumBuilder, new() 37 | { 38 | public override bool IsValid(Type dataType) 39 | { 40 | return dataType.IsEnum && Enum.GetUnderlyingType(dataType) == typeof(T); 41 | } 42 | 43 | public override object Create(Type dataType) 44 | { 45 | return new U { EnumTypeName = dataType.AssemblyQualifiedName }; 46 | } 47 | } 48 | } 49 | 50 | public class DynamicByteEnumBuilder : DynamicEnumBuilder 51 | { 52 | public class Factory : Factory {} 53 | } 54 | 55 | public class DynamicSByteEnumBuilder : DynamicEnumBuilder 56 | { 57 | public class Factory : Factory {} 58 | } 59 | 60 | public class DynamicShortEnumBuilder : DynamicEnumBuilder 61 | { 62 | public class Factory : Factory {} 63 | } 64 | 65 | public class DynamicUShortEnumBuilder : DynamicEnumBuilder 66 | { 67 | public class Factory : Factory {} 68 | } 69 | 70 | public class DynamicIntEnumBuilder : DynamicEnumBuilder 71 | { 72 | public class Factory : Factory {} 73 | } 74 | 75 | public class DynamicUIntEnumBuilder : DynamicEnumBuilder 76 | { 77 | public class Factory : Factory {} 78 | } 79 | 80 | public class DynamicLongEnumBuilder : DynamicEnumBuilder 81 | { 82 | public class Factory : Factory {} 83 | } 84 | 85 | public class DynamicULongEnumBuilder : DynamicEnumBuilder 86 | { 87 | public class Factory : Factory {} 88 | } 89 | 90 | [Serializable] 91 | public class DynamicBlobDataBuilder : IBuilder 92 | { 93 | public string BlobDataType; 94 | public string[] FieldNames; 95 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder[] Builders; 96 | 97 | public void Build(BlobBuilder builder, IntPtr dataPtr) 98 | { 99 | var fields = Type.GetType(BlobDataType).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 100 | for (var i = 0; i < Builders.Length; i++) 101 | { 102 | var offset = UnsafeUtility.GetFieldOffset(fields[i]); 103 | Builders[i].Build(builder, dataPtr + offset); 104 | } 105 | } 106 | 107 | public class Factory : DynamicBuilderFactory 108 | { 109 | public override int Order => 1000; 110 | public override bool IsValid(Type dataType) => !dataType.IsEnum && !dataType.IsPrimitive; 111 | public override object Create(Type dataType) => new DynamicBlobDataBuilder { BlobDataType = dataType.AssemblyQualifiedName }; 112 | } 113 | } 114 | 115 | [Serializable] 116 | public class DynamicArrayBuilder : IBuilder 117 | { 118 | public string ArrayElementType; 119 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder[] Value; 120 | 121 | public void Build(BlobBuilder builder, IntPtr dataPtr) 122 | { 123 | var elementType = Type.GetType(ArrayElementType); 124 | var arrayBuilder = builder.AllocateDynamicArray(elementType, dataPtr, Value.Length); 125 | for (var i = 0; i < Value.Length; i++) Value[i].Build(builder, arrayBuilder[i]); 126 | } 127 | 128 | public class Factory : DynamicBuilderFactory 129 | { 130 | public override int Order => 100; 131 | public override bool IsValid(Type dataType) => dataType.IsGenericType && dataType.GetGenericTypeDefinition() == typeof(BlobArray<>); 132 | public override object Create(Type dataType) => new DynamicArrayBuilder { ArrayElementType = dataType.GenericTypeArguments[0].AssemblyQualifiedName }; 133 | } 134 | } 135 | 136 | [Serializable] 137 | public class DynamicPtrBuilder : IBuilder 138 | { 139 | public string DataType; 140 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IBuilder Value; 141 | 142 | public void Build(BlobBuilder builder, IntPtr dataPtr) 143 | { 144 | var blobPtr = builder.AllocateDynamicPtr(Type.GetType(DataType), dataPtr); 145 | Value.Build(builder, blobPtr); 146 | } 147 | 148 | public class Factory : DynamicBuilderFactory 149 | { 150 | public override int Order => 100; 151 | public override bool IsValid(Type dataType) => dataType.IsGenericType && dataType.GetGenericTypeDefinition() == typeof(BlobPtr<>); 152 | public override object Create(Type dataType) => new DynamicPtrBuilder { DataType = dataType.GenericTypeArguments[0].AssemblyQualifiedName }; 153 | } 154 | } 155 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/DynamicBuilders.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d12d0300db746058e9d3483ad2179fd 3 | timeCreated: 1629819348 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/GenerateBuilders.ttinclude: -------------------------------------------------------------------------------- 1 | <#+ 2 | void GenerateBuilders(Type type) 3 | { 4 | #> 5 | [DefaultBuilder] public class <#= type.Name #>Builder : Blob.PlainDataBuilder<<#= type #>> {} 6 | [DefaultBuilder] public class <#= type.Name #>ArrayBuilder : Blob.ArrayBuilder<<#= type #>> {} 7 | [DefaultBuilder] public class <#= type.Name #>PtrBuilder : Blob.PtrBuilder<<#= type #>> {} 8 | <#+ 9 | } 10 | #> 11 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/GenerateBuilders.ttinclude.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10300682f7d34777b9bcfe9b1f68a0e1 3 | timeCreated: 1628688777 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/MathematicsBuilder.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | #if ENABLE_UNITY_MATHEMATICS 6 | 7 | namespace Blob.Mathematics 8 | { 9 | 10 | [DefaultBuilder] public class bool2Builder : Blob.PlainDataBuilder {} 11 | [DefaultBuilder] public class bool2ArrayBuilder : Blob.ArrayBuilder {} 12 | [DefaultBuilder] public class bool2PtrBuilder : Blob.PtrBuilder {} 13 | [DefaultBuilder] public class bool2x2Builder : Blob.PlainDataBuilder {} 14 | [DefaultBuilder] public class bool2x2ArrayBuilder : Blob.ArrayBuilder {} 15 | [DefaultBuilder] public class bool2x2PtrBuilder : Blob.PtrBuilder {} 16 | [DefaultBuilder] public class bool2x3Builder : Blob.PlainDataBuilder {} 17 | [DefaultBuilder] public class bool2x3ArrayBuilder : Blob.ArrayBuilder {} 18 | [DefaultBuilder] public class bool2x3PtrBuilder : Blob.PtrBuilder {} 19 | [DefaultBuilder] public class bool2x4Builder : Blob.PlainDataBuilder {} 20 | [DefaultBuilder] public class bool2x4ArrayBuilder : Blob.ArrayBuilder {} 21 | [DefaultBuilder] public class bool2x4PtrBuilder : Blob.PtrBuilder {} 22 | [DefaultBuilder] public class bool3Builder : Blob.PlainDataBuilder {} 23 | [DefaultBuilder] public class bool3ArrayBuilder : Blob.ArrayBuilder {} 24 | [DefaultBuilder] public class bool3PtrBuilder : Blob.PtrBuilder {} 25 | [DefaultBuilder] public class bool3x2Builder : Blob.PlainDataBuilder {} 26 | [DefaultBuilder] public class bool3x2ArrayBuilder : Blob.ArrayBuilder {} 27 | [DefaultBuilder] public class bool3x2PtrBuilder : Blob.PtrBuilder {} 28 | [DefaultBuilder] public class bool3x3Builder : Blob.PlainDataBuilder {} 29 | [DefaultBuilder] public class bool3x3ArrayBuilder : Blob.ArrayBuilder {} 30 | [DefaultBuilder] public class bool3x3PtrBuilder : Blob.PtrBuilder {} 31 | [DefaultBuilder] public class bool3x4Builder : Blob.PlainDataBuilder {} 32 | [DefaultBuilder] public class bool3x4ArrayBuilder : Blob.ArrayBuilder {} 33 | [DefaultBuilder] public class bool3x4PtrBuilder : Blob.PtrBuilder {} 34 | [DefaultBuilder] public class bool4Builder : Blob.PlainDataBuilder {} 35 | [DefaultBuilder] public class bool4ArrayBuilder : Blob.ArrayBuilder {} 36 | [DefaultBuilder] public class bool4PtrBuilder : Blob.PtrBuilder {} 37 | [DefaultBuilder] public class bool4x2Builder : Blob.PlainDataBuilder {} 38 | [DefaultBuilder] public class bool4x2ArrayBuilder : Blob.ArrayBuilder {} 39 | [DefaultBuilder] public class bool4x2PtrBuilder : Blob.PtrBuilder {} 40 | [DefaultBuilder] public class bool4x3Builder : Blob.PlainDataBuilder {} 41 | [DefaultBuilder] public class bool4x3ArrayBuilder : Blob.ArrayBuilder {} 42 | [DefaultBuilder] public class bool4x3PtrBuilder : Blob.PtrBuilder {} 43 | [DefaultBuilder] public class bool4x4Builder : Blob.PlainDataBuilder {} 44 | [DefaultBuilder] public class bool4x4ArrayBuilder : Blob.ArrayBuilder {} 45 | [DefaultBuilder] public class bool4x4PtrBuilder : Blob.PtrBuilder {} 46 | [DefaultBuilder] public class double2Builder : Blob.PlainDataBuilder {} 47 | [DefaultBuilder] public class double2ArrayBuilder : Blob.ArrayBuilder {} 48 | [DefaultBuilder] public class double2PtrBuilder : Blob.PtrBuilder {} 49 | [DefaultBuilder] public class double2x2Builder : Blob.PlainDataBuilder {} 50 | [DefaultBuilder] public class double2x2ArrayBuilder : Blob.ArrayBuilder {} 51 | [DefaultBuilder] public class double2x2PtrBuilder : Blob.PtrBuilder {} 52 | [DefaultBuilder] public class double2x3Builder : Blob.PlainDataBuilder {} 53 | [DefaultBuilder] public class double2x3ArrayBuilder : Blob.ArrayBuilder {} 54 | [DefaultBuilder] public class double2x3PtrBuilder : Blob.PtrBuilder {} 55 | [DefaultBuilder] public class double2x4Builder : Blob.PlainDataBuilder {} 56 | [DefaultBuilder] public class double2x4ArrayBuilder : Blob.ArrayBuilder {} 57 | [DefaultBuilder] public class double2x4PtrBuilder : Blob.PtrBuilder {} 58 | [DefaultBuilder] public class double3Builder : Blob.PlainDataBuilder {} 59 | [DefaultBuilder] public class double3ArrayBuilder : Blob.ArrayBuilder {} 60 | [DefaultBuilder] public class double3PtrBuilder : Blob.PtrBuilder {} 61 | [DefaultBuilder] public class double3x2Builder : Blob.PlainDataBuilder {} 62 | [DefaultBuilder] public class double3x2ArrayBuilder : Blob.ArrayBuilder {} 63 | [DefaultBuilder] public class double3x2PtrBuilder : Blob.PtrBuilder {} 64 | [DefaultBuilder] public class double3x3Builder : Blob.PlainDataBuilder {} 65 | [DefaultBuilder] public class double3x3ArrayBuilder : Blob.ArrayBuilder {} 66 | [DefaultBuilder] public class double3x3PtrBuilder : Blob.PtrBuilder {} 67 | [DefaultBuilder] public class double3x4Builder : Blob.PlainDataBuilder {} 68 | [DefaultBuilder] public class double3x4ArrayBuilder : Blob.ArrayBuilder {} 69 | [DefaultBuilder] public class double3x4PtrBuilder : Blob.PtrBuilder {} 70 | [DefaultBuilder] public class double4Builder : Blob.PlainDataBuilder {} 71 | [DefaultBuilder] public class double4ArrayBuilder : Blob.ArrayBuilder {} 72 | [DefaultBuilder] public class double4PtrBuilder : Blob.PtrBuilder {} 73 | [DefaultBuilder] public class double4x2Builder : Blob.PlainDataBuilder {} 74 | [DefaultBuilder] public class double4x2ArrayBuilder : Blob.ArrayBuilder {} 75 | [DefaultBuilder] public class double4x2PtrBuilder : Blob.PtrBuilder {} 76 | [DefaultBuilder] public class double4x3Builder : Blob.PlainDataBuilder {} 77 | [DefaultBuilder] public class double4x3ArrayBuilder : Blob.ArrayBuilder {} 78 | [DefaultBuilder] public class double4x3PtrBuilder : Blob.PtrBuilder {} 79 | [DefaultBuilder] public class double4x4Builder : Blob.PlainDataBuilder {} 80 | [DefaultBuilder] public class double4x4ArrayBuilder : Blob.ArrayBuilder {} 81 | [DefaultBuilder] public class double4x4PtrBuilder : Blob.PtrBuilder {} 82 | [DefaultBuilder] public class float2Builder : Blob.PlainDataBuilder {} 83 | [DefaultBuilder] public class float2ArrayBuilder : Blob.ArrayBuilder {} 84 | [DefaultBuilder] public class float2PtrBuilder : Blob.PtrBuilder {} 85 | [DefaultBuilder] public class float2x2Builder : Blob.PlainDataBuilder {} 86 | [DefaultBuilder] public class float2x2ArrayBuilder : Blob.ArrayBuilder {} 87 | [DefaultBuilder] public class float2x2PtrBuilder : Blob.PtrBuilder {} 88 | [DefaultBuilder] public class float2x3Builder : Blob.PlainDataBuilder {} 89 | [DefaultBuilder] public class float2x3ArrayBuilder : Blob.ArrayBuilder {} 90 | [DefaultBuilder] public class float2x3PtrBuilder : Blob.PtrBuilder {} 91 | [DefaultBuilder] public class float2x4Builder : Blob.PlainDataBuilder {} 92 | [DefaultBuilder] public class float2x4ArrayBuilder : Blob.ArrayBuilder {} 93 | [DefaultBuilder] public class float2x4PtrBuilder : Blob.PtrBuilder {} 94 | [DefaultBuilder] public class float3Builder : Blob.PlainDataBuilder {} 95 | [DefaultBuilder] public class float3ArrayBuilder : Blob.ArrayBuilder {} 96 | [DefaultBuilder] public class float3PtrBuilder : Blob.PtrBuilder {} 97 | [DefaultBuilder] public class float3x2Builder : Blob.PlainDataBuilder {} 98 | [DefaultBuilder] public class float3x2ArrayBuilder : Blob.ArrayBuilder {} 99 | [DefaultBuilder] public class float3x2PtrBuilder : Blob.PtrBuilder {} 100 | [DefaultBuilder] public class float3x3Builder : Blob.PlainDataBuilder {} 101 | [DefaultBuilder] public class float3x3ArrayBuilder : Blob.ArrayBuilder {} 102 | [DefaultBuilder] public class float3x3PtrBuilder : Blob.PtrBuilder {} 103 | [DefaultBuilder] public class float3x4Builder : Blob.PlainDataBuilder {} 104 | [DefaultBuilder] public class float3x4ArrayBuilder : Blob.ArrayBuilder {} 105 | [DefaultBuilder] public class float3x4PtrBuilder : Blob.PtrBuilder {} 106 | [DefaultBuilder] public class float4Builder : Blob.PlainDataBuilder {} 107 | [DefaultBuilder] public class float4ArrayBuilder : Blob.ArrayBuilder {} 108 | [DefaultBuilder] public class float4PtrBuilder : Blob.PtrBuilder {} 109 | [DefaultBuilder] public class float4x2Builder : Blob.PlainDataBuilder {} 110 | [DefaultBuilder] public class float4x2ArrayBuilder : Blob.ArrayBuilder {} 111 | [DefaultBuilder] public class float4x2PtrBuilder : Blob.PtrBuilder {} 112 | [DefaultBuilder] public class float4x3Builder : Blob.PlainDataBuilder {} 113 | [DefaultBuilder] public class float4x3ArrayBuilder : Blob.ArrayBuilder {} 114 | [DefaultBuilder] public class float4x3PtrBuilder : Blob.PtrBuilder {} 115 | [DefaultBuilder] public class float4x4Builder : Blob.PlainDataBuilder {} 116 | [DefaultBuilder] public class float4x4ArrayBuilder : Blob.ArrayBuilder {} 117 | [DefaultBuilder] public class float4x4PtrBuilder : Blob.PtrBuilder {} 118 | [DefaultBuilder] public class halfBuilder : Blob.PlainDataBuilder {} 119 | [DefaultBuilder] public class halfArrayBuilder : Blob.ArrayBuilder {} 120 | [DefaultBuilder] public class halfPtrBuilder : Blob.PtrBuilder {} 121 | [DefaultBuilder] public class half2Builder : Blob.PlainDataBuilder {} 122 | [DefaultBuilder] public class half2ArrayBuilder : Blob.ArrayBuilder {} 123 | [DefaultBuilder] public class half2PtrBuilder : Blob.PtrBuilder {} 124 | [DefaultBuilder] public class half3Builder : Blob.PlainDataBuilder {} 125 | [DefaultBuilder] public class half3ArrayBuilder : Blob.ArrayBuilder {} 126 | [DefaultBuilder] public class half3PtrBuilder : Blob.PtrBuilder {} 127 | [DefaultBuilder] public class half4Builder : Blob.PlainDataBuilder {} 128 | [DefaultBuilder] public class half4ArrayBuilder : Blob.ArrayBuilder {} 129 | [DefaultBuilder] public class half4PtrBuilder : Blob.PtrBuilder {} 130 | [DefaultBuilder] public class int2Builder : Blob.PlainDataBuilder {} 131 | [DefaultBuilder] public class int2ArrayBuilder : Blob.ArrayBuilder {} 132 | [DefaultBuilder] public class int2PtrBuilder : Blob.PtrBuilder {} 133 | [DefaultBuilder] public class int2x2Builder : Blob.PlainDataBuilder {} 134 | [DefaultBuilder] public class int2x2ArrayBuilder : Blob.ArrayBuilder {} 135 | [DefaultBuilder] public class int2x2PtrBuilder : Blob.PtrBuilder {} 136 | [DefaultBuilder] public class int2x3Builder : Blob.PlainDataBuilder {} 137 | [DefaultBuilder] public class int2x3ArrayBuilder : Blob.ArrayBuilder {} 138 | [DefaultBuilder] public class int2x3PtrBuilder : Blob.PtrBuilder {} 139 | [DefaultBuilder] public class int2x4Builder : Blob.PlainDataBuilder {} 140 | [DefaultBuilder] public class int2x4ArrayBuilder : Blob.ArrayBuilder {} 141 | [DefaultBuilder] public class int2x4PtrBuilder : Blob.PtrBuilder {} 142 | [DefaultBuilder] public class int3Builder : Blob.PlainDataBuilder {} 143 | [DefaultBuilder] public class int3ArrayBuilder : Blob.ArrayBuilder {} 144 | [DefaultBuilder] public class int3PtrBuilder : Blob.PtrBuilder {} 145 | [DefaultBuilder] public class int3x2Builder : Blob.PlainDataBuilder {} 146 | [DefaultBuilder] public class int3x2ArrayBuilder : Blob.ArrayBuilder {} 147 | [DefaultBuilder] public class int3x2PtrBuilder : Blob.PtrBuilder {} 148 | [DefaultBuilder] public class int3x3Builder : Blob.PlainDataBuilder {} 149 | [DefaultBuilder] public class int3x3ArrayBuilder : Blob.ArrayBuilder {} 150 | [DefaultBuilder] public class int3x3PtrBuilder : Blob.PtrBuilder {} 151 | [DefaultBuilder] public class int3x4Builder : Blob.PlainDataBuilder {} 152 | [DefaultBuilder] public class int3x4ArrayBuilder : Blob.ArrayBuilder {} 153 | [DefaultBuilder] public class int3x4PtrBuilder : Blob.PtrBuilder {} 154 | [DefaultBuilder] public class int4Builder : Blob.PlainDataBuilder {} 155 | [DefaultBuilder] public class int4ArrayBuilder : Blob.ArrayBuilder {} 156 | [DefaultBuilder] public class int4PtrBuilder : Blob.PtrBuilder {} 157 | [DefaultBuilder] public class int4x2Builder : Blob.PlainDataBuilder {} 158 | [DefaultBuilder] public class int4x2ArrayBuilder : Blob.ArrayBuilder {} 159 | [DefaultBuilder] public class int4x2PtrBuilder : Blob.PtrBuilder {} 160 | [DefaultBuilder] public class int4x3Builder : Blob.PlainDataBuilder {} 161 | [DefaultBuilder] public class int4x3ArrayBuilder : Blob.ArrayBuilder {} 162 | [DefaultBuilder] public class int4x3PtrBuilder : Blob.PtrBuilder {} 163 | [DefaultBuilder] public class int4x4Builder : Blob.PlainDataBuilder {} 164 | [DefaultBuilder] public class int4x4ArrayBuilder : Blob.ArrayBuilder {} 165 | [DefaultBuilder] public class int4x4PtrBuilder : Blob.PtrBuilder {} 166 | [DefaultBuilder] public class quaternionBuilder : Blob.PlainDataBuilder {} 167 | [DefaultBuilder] public class quaternionArrayBuilder : Blob.ArrayBuilder {} 168 | [DefaultBuilder] public class quaternionPtrBuilder : Blob.PtrBuilder {} 169 | [DefaultBuilder] public class RandomBuilder : Blob.PlainDataBuilder {} 170 | [DefaultBuilder] public class RandomArrayBuilder : Blob.ArrayBuilder {} 171 | [DefaultBuilder] public class RandomPtrBuilder : Blob.PtrBuilder {} 172 | [DefaultBuilder] public class RigidTransformBuilder : Blob.PlainDataBuilder {} 173 | [DefaultBuilder] public class RigidTransformArrayBuilder : Blob.ArrayBuilder {} 174 | [DefaultBuilder] public class RigidTransformPtrBuilder : Blob.PtrBuilder {} 175 | [DefaultBuilder] public class uint2Builder : Blob.PlainDataBuilder {} 176 | [DefaultBuilder] public class uint2ArrayBuilder : Blob.ArrayBuilder {} 177 | [DefaultBuilder] public class uint2PtrBuilder : Blob.PtrBuilder {} 178 | [DefaultBuilder] public class uint2x2Builder : Blob.PlainDataBuilder {} 179 | [DefaultBuilder] public class uint2x2ArrayBuilder : Blob.ArrayBuilder {} 180 | [DefaultBuilder] public class uint2x2PtrBuilder : Blob.PtrBuilder {} 181 | [DefaultBuilder] public class uint2x3Builder : Blob.PlainDataBuilder {} 182 | [DefaultBuilder] public class uint2x3ArrayBuilder : Blob.ArrayBuilder {} 183 | [DefaultBuilder] public class uint2x3PtrBuilder : Blob.PtrBuilder {} 184 | [DefaultBuilder] public class uint2x4Builder : Blob.PlainDataBuilder {} 185 | [DefaultBuilder] public class uint2x4ArrayBuilder : Blob.ArrayBuilder {} 186 | [DefaultBuilder] public class uint2x4PtrBuilder : Blob.PtrBuilder {} 187 | [DefaultBuilder] public class uint3Builder : Blob.PlainDataBuilder {} 188 | [DefaultBuilder] public class uint3ArrayBuilder : Blob.ArrayBuilder {} 189 | [DefaultBuilder] public class uint3PtrBuilder : Blob.PtrBuilder {} 190 | [DefaultBuilder] public class uint3x2Builder : Blob.PlainDataBuilder {} 191 | [DefaultBuilder] public class uint3x2ArrayBuilder : Blob.ArrayBuilder {} 192 | [DefaultBuilder] public class uint3x2PtrBuilder : Blob.PtrBuilder {} 193 | [DefaultBuilder] public class uint3x3Builder : Blob.PlainDataBuilder {} 194 | [DefaultBuilder] public class uint3x3ArrayBuilder : Blob.ArrayBuilder {} 195 | [DefaultBuilder] public class uint3x3PtrBuilder : Blob.PtrBuilder {} 196 | [DefaultBuilder] public class uint3x4Builder : Blob.PlainDataBuilder {} 197 | [DefaultBuilder] public class uint3x4ArrayBuilder : Blob.ArrayBuilder {} 198 | [DefaultBuilder] public class uint3x4PtrBuilder : Blob.PtrBuilder {} 199 | [DefaultBuilder] public class uint4Builder : Blob.PlainDataBuilder {} 200 | [DefaultBuilder] public class uint4ArrayBuilder : Blob.ArrayBuilder {} 201 | [DefaultBuilder] public class uint4PtrBuilder : Blob.PtrBuilder {} 202 | [DefaultBuilder] public class uint4x2Builder : Blob.PlainDataBuilder {} 203 | [DefaultBuilder] public class uint4x2ArrayBuilder : Blob.ArrayBuilder {} 204 | [DefaultBuilder] public class uint4x2PtrBuilder : Blob.PtrBuilder {} 205 | [DefaultBuilder] public class uint4x3Builder : Blob.PlainDataBuilder {} 206 | [DefaultBuilder] public class uint4x3ArrayBuilder : Blob.ArrayBuilder {} 207 | [DefaultBuilder] public class uint4x3PtrBuilder : Blob.PtrBuilder {} 208 | [DefaultBuilder] public class uint4x4Builder : Blob.PlainDataBuilder {} 209 | [DefaultBuilder] public class uint4x4ArrayBuilder : Blob.ArrayBuilder {} 210 | [DefaultBuilder] public class uint4x4PtrBuilder : Blob.PtrBuilder {} 211 | 212 | } 213 | 214 | #endif 215 | 216 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/MathematicsBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1c5bc9faa754229a5fd689f5561c4ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/MathematicsBuilder.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ output extension=".cs" #> 3 | 4 | <#@ include file="GenerateBuilders.ttinclude" #> 5 | <#@ include file="../Mathematics.ttinclude" #> 6 | 7 | #if ENABLE_UNITY_MATHEMATICS 8 | 9 | namespace Blob.Mathematics 10 | { 11 | 12 | <# 13 | foreach (var type in Mathematics) GenerateBuilders(type); 14 | #> 15 | 16 | } 17 | 18 | #endif -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/MathematicsBuilder.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e19399e58d74e7290430d1a5295e279 3 | timeCreated: 1628604239 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/PrimitiveBuilder.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | namespace Blob.Primitive 5 | { 6 | 7 | [DefaultBuilder] public class BooleanBuilder : Blob.PlainDataBuilder {} 8 | [DefaultBuilder] public class BooleanArrayBuilder : Blob.ArrayBuilder {} 9 | [DefaultBuilder] public class BooleanPtrBuilder : Blob.PtrBuilder {} 10 | [DefaultBuilder] public class ByteBuilder : Blob.PlainDataBuilder {} 11 | [DefaultBuilder] public class ByteArrayBuilder : Blob.ArrayBuilder {} 12 | [DefaultBuilder] public class BytePtrBuilder : Blob.PtrBuilder {} 13 | [DefaultBuilder] public class CharBuilder : Blob.PlainDataBuilder {} 14 | [DefaultBuilder] public class CharArrayBuilder : Blob.ArrayBuilder {} 15 | [DefaultBuilder] public class CharPtrBuilder : Blob.PtrBuilder {} 16 | [DefaultBuilder] public class DoubleBuilder : Blob.PlainDataBuilder {} 17 | [DefaultBuilder] public class DoubleArrayBuilder : Blob.ArrayBuilder {} 18 | [DefaultBuilder] public class DoublePtrBuilder : Blob.PtrBuilder {} 19 | [DefaultBuilder] public class Int16Builder : Blob.PlainDataBuilder {} 20 | [DefaultBuilder] public class Int16ArrayBuilder : Blob.ArrayBuilder {} 21 | [DefaultBuilder] public class Int16PtrBuilder : Blob.PtrBuilder {} 22 | [DefaultBuilder] public class Int32Builder : Blob.PlainDataBuilder {} 23 | [DefaultBuilder] public class Int32ArrayBuilder : Blob.ArrayBuilder {} 24 | [DefaultBuilder] public class Int32PtrBuilder : Blob.PtrBuilder {} 25 | [DefaultBuilder] public class Int64Builder : Blob.PlainDataBuilder {} 26 | [DefaultBuilder] public class Int64ArrayBuilder : Blob.ArrayBuilder {} 27 | [DefaultBuilder] public class Int64PtrBuilder : Blob.PtrBuilder {} 28 | [DefaultBuilder] public class IntPtrBuilder : Blob.PlainDataBuilder {} 29 | [DefaultBuilder] public class IntPtrArrayBuilder : Blob.ArrayBuilder {} 30 | [DefaultBuilder] public class IntPtrPtrBuilder : Blob.PtrBuilder {} 31 | [DefaultBuilder] public class SByteBuilder : Blob.PlainDataBuilder {} 32 | [DefaultBuilder] public class SByteArrayBuilder : Blob.ArrayBuilder {} 33 | [DefaultBuilder] public class SBytePtrBuilder : Blob.PtrBuilder {} 34 | [DefaultBuilder] public class SingleBuilder : Blob.PlainDataBuilder {} 35 | [DefaultBuilder] public class SingleArrayBuilder : Blob.ArrayBuilder {} 36 | [DefaultBuilder] public class SinglePtrBuilder : Blob.PtrBuilder {} 37 | [DefaultBuilder] public class UInt16Builder : Blob.PlainDataBuilder {} 38 | [DefaultBuilder] public class UInt16ArrayBuilder : Blob.ArrayBuilder {} 39 | [DefaultBuilder] public class UInt16PtrBuilder : Blob.PtrBuilder {} 40 | [DefaultBuilder] public class UInt32Builder : Blob.PlainDataBuilder {} 41 | [DefaultBuilder] public class UInt32ArrayBuilder : Blob.ArrayBuilder {} 42 | [DefaultBuilder] public class UInt32PtrBuilder : Blob.PtrBuilder {} 43 | [DefaultBuilder] public class UInt64Builder : Blob.PlainDataBuilder {} 44 | [DefaultBuilder] public class UInt64ArrayBuilder : Blob.ArrayBuilder {} 45 | [DefaultBuilder] public class UInt64PtrBuilder : Blob.PtrBuilder {} 46 | [DefaultBuilder] public class UIntPtrBuilder : Blob.PlainDataBuilder {} 47 | [DefaultBuilder] public class UIntPtrArrayBuilder : Blob.ArrayBuilder {} 48 | [DefaultBuilder] public class UIntPtrPtrBuilder : Blob.PtrBuilder {} 49 | 50 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/PrimitiveBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 567dd79ba5d340738c20e19fac4b630e 3 | timeCreated: 1628582056 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/PrimitiveBuilder.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ output extension=".cs" #> 3 | 4 | <#@ include file="GenerateBuilders.ttinclude" #> 5 | <#@ include file="../Primitives.ttinclude" #> 6 | 7 | namespace Blob.Primitive 8 | { 9 | 10 | <# 11 | foreach (var type in Primitives) GenerateBuilders(type); 12 | #> 13 | 14 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Builder/PrimitiveBuilder.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21f8e18c3b3f415088814521e8fbd0ec 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/DynamicBlobBuilderArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using Blob; 4 | using Unity.Assertions; 5 | using Unity.Collections.LowLevel.Unsafe; 6 | 7 | namespace Unity.Entities 8 | { 9 | /// 10 | /// Used by the methods to reference the arrays within a blob asset. 11 | /// 12 | /// Use this reference to initialize the data of a newly created . 13 | public struct BlobBuilderDynamicArray 14 | { 15 | private IntPtr m_data; 16 | private int m_length; 17 | private Type m_elementType; 18 | 19 | /// 20 | /// For internal, , use only. 21 | /// 22 | public BlobBuilderDynamicArray(IntPtr data, int length, Type elementType) 23 | { 24 | m_data = data; 25 | m_length = length; 26 | m_elementType = elementType; 27 | } 28 | 29 | [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] 30 | private void CheckIndexOutOfRange(int index) 31 | { 32 | if (0 > index || index >= m_length) 33 | throw new IndexOutOfRangeException($"Index {index} is out of range of '{m_length}' Length."); 34 | } 35 | 36 | /// 37 | /// Array index accessor for the elements in the array. 38 | /// 39 | /// The sequential index of an array item. 40 | /// Thrown when index is less than zero or greater than the length of the array (minus one). 41 | public IntPtr this[int index] 42 | { 43 | get 44 | { 45 | CheckIndexOutOfRange(index); 46 | return Utility.ArrayElementAsPtr(m_data, index, UnsafeUtility.SizeOf(m_elementType)); 47 | } 48 | } 49 | 50 | public unsafe void SetElementAt(int index, in T value) where T : unmanaged 51 | { 52 | Assert.AreEqual(m_elementType, typeof(T)); 53 | UnsafeUtility.AsRef(this[index].ToPointer()) = value; 54 | } 55 | 56 | /// 57 | /// Reports the number of elements in the array. 58 | /// 59 | public int Length => m_length; 60 | 61 | /// 62 | /// Provides a pointer to the data stored in the array. 63 | /// 64 | /// You can only call this function in an [unsafe context]. 65 | /// [unsafe context]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/unsafe-code 66 | /// 67 | /// A pointer to the first element in the array. 68 | public IntPtr GetUnsafePtr() => m_data; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/DynamicBlobBuilderArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d775e0a5b6543cfa965ee9a0fa1127b 3 | timeCreated: 1629800012 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Mathematics.ttinclude: -------------------------------------------------------------------------------- 1 | <#@ assembly name="/Applications/Unity/Hub/Editor/2020.3.16f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.CoreModule.dll" #> 2 | <#@ assembly name="$(SolutionDir)/Library/ScriptAssemblies/Unity.Mathematics.dll" #> 3 | <#@ import namespace="Unity.Mathematics" #> 4 | <#@ import namespace="System.Linq" #> 5 | 6 | <#+ 7 | Type[] Mathematics = typeof(math).Assembly.GetTypes().Where(type => type.IsPublic && IsUnmanaged(type)).ToArray(); 8 | 9 | class U where T : unmanaged { } 10 | public static bool IsUnmanaged(Type t) 11 | { 12 | try { typeof(U<>).MakeGenericType(t); return true; } 13 | catch (Exception){ return false; } 14 | } 15 | #> 16 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Mathematics.ttinclude.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91cd44f87175b400e9aef63098037eaf 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Primitives.ttinclude: -------------------------------------------------------------------------------- 1 | <#@ import namespace="System.Linq" #> 2 | 3 | <#+ 4 | Type[] Primitives = typeof(int).Assembly.GetTypes().Where(type => type.IsPrimitive).ToArray(); 5 | #> 6 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Primitives.ttinclude.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41575a89a40834e4286a3cc37c431b0c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Utility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Text.RegularExpressions; 5 | using JetBrains.Annotations; 6 | using Unity.Collections.LowLevel.Unsafe; 7 | using Unity.Entities; 8 | 9 | namespace Blob 10 | { 11 | public static class Utility 12 | { 13 | public static IntPtr ArrayElementAsPtr(IntPtr arrayDataPtr, long index, long size) => new IntPtr(arrayDataPtr.ToInt64() + index * size); 14 | 15 | // TODO: hack into `BlobBuilder` to make some dynamic (non-generic) methods to avoid using reflection. 16 | public static BlobBuilderDynamicArray AllocateDynamicArray(this BlobBuilder builder, Type elementType, IntPtr arrayPtr, int length) 17 | { 18 | var func = typeof(Utility).GetMethod(nameof(AllocateDynamicArray), BindingFlags.Static | BindingFlags.NonPublic); 19 | return (BlobBuilderDynamicArray) func.MakeGenericMethod(elementType).Invoke(null, new object[] {builder, arrayPtr, length}); 20 | } 21 | 22 | private static unsafe BlobBuilderDynamicArray AllocateDynamicArray(BlobBuilder builder, IntPtr arrayPtr, int length) where T : unmanaged 23 | { 24 | ref var data = ref UnsafeUtility.AsRef>(arrayPtr.ToPointer()); 25 | var arrayBuilder = builder.Allocate(ref data, length); 26 | return new BlobBuilderDynamicArray(new IntPtr(arrayBuilder.GetUnsafePtr()), length, typeof(T)); 27 | } 28 | 29 | public static IntPtr AllocateDynamicPtr(this BlobBuilder builder, Type dataType, IntPtr dataPtr) 30 | { 31 | var func = typeof(Utility).GetMethod(nameof(AllocateDynamicPtr), BindingFlags.Static | BindingFlags.NonPublic); 32 | return (IntPtr) func.MakeGenericMethod(dataType).Invoke(null, new object[] {builder, dataPtr}); 33 | } 34 | 35 | private static unsafe IntPtr AllocateDynamicPtr(BlobBuilder builder, IntPtr dataPtr) where T : unmanaged 36 | { 37 | ref var data = ref UnsafeUtility.AsRef>(dataPtr.ToPointer()); 38 | ref var blobPtr = ref builder.Allocate(ref data); 39 | return new IntPtr(UnsafeUtility.AddressOf(ref blobPtr)); 40 | } 41 | 42 | public static string ToReadableFullName([NotNull] this Type type) 43 | { 44 | return type.IsGenericType ? Regex.Replace(type.ToString(), @"(\w+)`\d+\[(.*)\]", "$1<$2>") : type.ToString(); 45 | } 46 | 47 | public static string ToReadableName([NotNull] this Type type) 48 | { 49 | if (!type.IsGenericType) return type.Name; 50 | var name = type.Name.Remove(type.Name.LastIndexOf('`')); 51 | name += "<"; 52 | name += string.Join(",", type.GenericTypeArguments.Select(t => t.ToReadableName())); 53 | name += ">"; 54 | return name; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Utility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0af04a179ef643faa8236ba4096a8ed9 3 | timeCreated: 1629799913 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d382d409db8c44b4ab31f85284b7ba1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Blob.Editor")] -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe325be404d542a08eea83d73f1b90f8 3 | timeCreated: 1629897462 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/Blob.Viewer.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Blob.Viewer", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:6d84eb5386377416e93c122a00485b68", 6 | "GUID:734d92eba21c94caba915361bd5ac177", 7 | "GUID:d8b63aba1907145bea998dd612889d6b" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [ 17 | { 18 | "name": "com.unity.mathematics", 19 | "expression": "1.0.1", 20 | "define": "ENABLE_UNITY_MATHEMATICS" 21 | } 22 | ], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/Blob.Viewer.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bfccbc67fab343fe842fd447669165f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/BlobViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace Blob 6 | { 7 | [Serializable] 8 | public class BlobViewer 9 | { 10 | [SerializeField] public bool Writable = false; 11 | [SerializeField] internal string TypeName = "(Empty)"; 12 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] internal IViewer Viewer; 13 | 14 | public unsafe void View(T* dataPtr) where T : unmanaged => UnsafeView(new IntPtr(dataPtr), typeof(T)); 15 | 16 | public void UnsafeView(IntPtr dataPtr, Type type) 17 | { 18 | #if UNITY_EDITOR 19 | TypeName = type.ToReadableName(); 20 | var viewerType = type.FindViewerType(); 21 | if (Viewer == null || Viewer.GetType() != viewerType) 22 | Viewer = (IViewer) Activator.CreateInstance(viewerType); 23 | Viewer.View(dataPtr, type); 24 | #endif 25 | } 26 | } 27 | 28 | public static class BlobViewerExtension 29 | { 30 | public static unsafe void View(this BlobViewer viewer, BlobAssetReference blobAssetReference) where T : unmanaged 31 | { 32 | fixed (T* ptr = &blobAssetReference.Value) 33 | { 34 | viewer.View(ptr); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/BlobViewer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d0a0f9c6014b84136b7deb063425ed14 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/GenerateViewers.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | namespace Blob 7 | { 8 | 9 | public class BooleanViewer : Blob.PlainDataViewer {} 10 | public class ByteViewer : Blob.PlainDataViewer {} 11 | public class CharViewer : Blob.PlainDataViewer {} 12 | public class DoubleViewer : Blob.PlainDataViewer {} 13 | public class Int16Viewer : Blob.PlainDataViewer {} 14 | public class Int32Viewer : Blob.PlainDataViewer {} 15 | public class Int64Viewer : Blob.PlainDataViewer {} 16 | public class SByteViewer : Blob.PlainDataViewer {} 17 | public class SingleViewer : Blob.PlainDataViewer {} 18 | public class UInt16Viewer : Blob.PlainDataViewer {} 19 | public class UInt32Viewer : Blob.PlainDataViewer {} 20 | public class UInt64Viewer : Blob.PlainDataViewer {} 21 | public class IntPtrViewer : Blob.PlainDataViewer {} 22 | public class UIntPtrViewer : Blob.PlainDataViewer {} 23 | 24 | #if ENABLE_UNITY_MATHEMATICS 25 | public class bool2Viewer : Blob.PlainDataViewer {} 26 | public class bool2x2Viewer : Blob.PlainDataViewer {} 27 | public class bool2x3Viewer : Blob.PlainDataViewer {} 28 | public class bool2x4Viewer : Blob.PlainDataViewer {} 29 | public class bool3Viewer : Blob.PlainDataViewer {} 30 | public class bool3x2Viewer : Blob.PlainDataViewer {} 31 | public class bool3x3Viewer : Blob.PlainDataViewer {} 32 | public class bool3x4Viewer : Blob.PlainDataViewer {} 33 | public class bool4Viewer : Blob.PlainDataViewer {} 34 | public class bool4x2Viewer : Blob.PlainDataViewer {} 35 | public class bool4x3Viewer : Blob.PlainDataViewer {} 36 | public class bool4x4Viewer : Blob.PlainDataViewer {} 37 | public class double2Viewer : Blob.PlainDataViewer {} 38 | public class double2x2Viewer : Blob.PlainDataViewer {} 39 | public class double2x3Viewer : Blob.PlainDataViewer {} 40 | public class double2x4Viewer : Blob.PlainDataViewer {} 41 | public class double3Viewer : Blob.PlainDataViewer {} 42 | public class double3x2Viewer : Blob.PlainDataViewer {} 43 | public class double3x3Viewer : Blob.PlainDataViewer {} 44 | public class double3x4Viewer : Blob.PlainDataViewer {} 45 | public class double4Viewer : Blob.PlainDataViewer {} 46 | public class double4x2Viewer : Blob.PlainDataViewer {} 47 | public class double4x3Viewer : Blob.PlainDataViewer {} 48 | public class double4x4Viewer : Blob.PlainDataViewer {} 49 | public class float2Viewer : Blob.PlainDataViewer {} 50 | public class float2x2Viewer : Blob.PlainDataViewer {} 51 | public class float2x3Viewer : Blob.PlainDataViewer {} 52 | public class float2x4Viewer : Blob.PlainDataViewer {} 53 | public class float3Viewer : Blob.PlainDataViewer {} 54 | public class float3x2Viewer : Blob.PlainDataViewer {} 55 | public class float3x3Viewer : Blob.PlainDataViewer {} 56 | public class float3x4Viewer : Blob.PlainDataViewer {} 57 | public class float4Viewer : Blob.PlainDataViewer {} 58 | public class float4x2Viewer : Blob.PlainDataViewer {} 59 | public class float4x3Viewer : Blob.PlainDataViewer {} 60 | public class float4x4Viewer : Blob.PlainDataViewer {} 61 | public class halfViewer : Blob.PlainDataViewer {} 62 | public class half2Viewer : Blob.PlainDataViewer {} 63 | public class half3Viewer : Blob.PlainDataViewer {} 64 | public class half4Viewer : Blob.PlainDataViewer {} 65 | public class int2Viewer : Blob.PlainDataViewer {} 66 | public class int2x2Viewer : Blob.PlainDataViewer {} 67 | public class int2x3Viewer : Blob.PlainDataViewer {} 68 | public class int2x4Viewer : Blob.PlainDataViewer {} 69 | public class int3Viewer : Blob.PlainDataViewer {} 70 | public class int3x2Viewer : Blob.PlainDataViewer {} 71 | public class int3x3Viewer : Blob.PlainDataViewer {} 72 | public class int3x4Viewer : Blob.PlainDataViewer {} 73 | public class int4Viewer : Blob.PlainDataViewer {} 74 | public class int4x2Viewer : Blob.PlainDataViewer {} 75 | public class int4x3Viewer : Blob.PlainDataViewer {} 76 | public class int4x4Viewer : Blob.PlainDataViewer {} 77 | public class quaternionViewer : Blob.PlainDataViewer {} 78 | public class RandomViewer : Blob.PlainDataViewer {} 79 | public class RigidTransformViewer : Blob.PlainDataViewer {} 80 | public class uint2Viewer : Blob.PlainDataViewer {} 81 | public class uint2x2Viewer : Blob.PlainDataViewer {} 82 | public class uint2x3Viewer : Blob.PlainDataViewer {} 83 | public class uint2x4Viewer : Blob.PlainDataViewer {} 84 | public class uint3Viewer : Blob.PlainDataViewer {} 85 | public class uint3x2Viewer : Blob.PlainDataViewer {} 86 | public class uint3x3Viewer : Blob.PlainDataViewer {} 87 | public class uint3x4Viewer : Blob.PlainDataViewer {} 88 | public class uint4Viewer : Blob.PlainDataViewer {} 89 | public class uint4x2Viewer : Blob.PlainDataViewer {} 90 | public class uint4x3Viewer : Blob.PlainDataViewer {} 91 | public class uint4x4Viewer : Blob.PlainDataViewer {} 92 | #endif 93 | 94 | } 95 | 96 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/GenerateViewers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a903b2049b14ad09674a0a57ced3fe4 3 | timeCreated: 1629896593 -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/GenerateViewers.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ output extension=".cs" #> 3 | 4 | <#@ include file="../Primitives.ttinclude" #> 5 | <#@ include file="../Mathematics.ttinclude" #><#@ assembly name="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #><#@ assembly name="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #> 6 | <#@ import namespace="System.Linq" #> 7 | 8 | namespace Blob 9 | { 10 | 11 | <# 12 | foreach (var type in Primitives) GenerateViewers(type); 13 | #> 14 | 15 | #if ENABLE_UNITY_MATHEMATICS 16 | <# 17 | foreach (var type in Mathematics) GenerateViewers(type); 18 | #> 19 | #endif 20 | 21 | } 22 | 23 | <#+ 24 | void GenerateViewers(Type type) 25 | { 26 | #> 27 | public class <#= type.Name #>Viewer : Blob.PlainDataViewer<<#= type #>> {} 28 | <#+ 29 | } 30 | #> 31 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/GenerateViewers.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17843e3ae38a74c7c9a71d00b63ee19c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/Viewers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using Unity.Assertions; 5 | using Unity.Collections.LowLevel.Unsafe; 6 | using Unity.Entities; 7 | using UnityEditor; 8 | using UnityEngine; 9 | 10 | namespace Blob 11 | { 12 | public interface IViewer 13 | { 14 | void View(IntPtr dataPtr, Type type); 15 | } 16 | 17 | public abstract class Viewer : IViewer where T : unmanaged 18 | { 19 | public unsafe void View(IntPtr dataPtr, Type type) 20 | { 21 | Assert.AreEqual(type, typeof(T)); 22 | View(ref UnsafeUtility.AsRef(dataPtr.ToPointer())); 23 | } 24 | 25 | public abstract void View(ref T data); 26 | } 27 | 28 | [Serializable] 29 | public class PlainDataViewer : Viewer where T : unmanaged 30 | { 31 | public T Value; 32 | public override void View(ref T data) => Value = data; 33 | } 34 | 35 | [Serializable] 36 | public class StringViewer : Viewer 37 | { 38 | public string Value; 39 | public override void View(ref BlobString data) => Value = data.ToString(); 40 | } 41 | 42 | [Serializable] 43 | public class DynamicArrayViewer : IViewer 44 | { 45 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IViewer[] Elements; 46 | 47 | public unsafe void View(IntPtr dataPtr, Type type) 48 | { 49 | Assert.IsTrue(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(BlobArray<>)); 50 | ref var offsetPtr = ref UnsafeUtility.AsRef(dataPtr.ToPointer()); 51 | ref var length = ref UnsafeUtility.AsRef((dataPtr + sizeof(int)).ToPointer()); 52 | var elementType = type.GenericTypeArguments[0]; 53 | Array.Resize(ref Elements, length); 54 | 55 | var viewerType = elementType.FindViewerType(); 56 | var elementSize = UnsafeUtility.SizeOf(elementType); 57 | var arrayPtr = dataPtr + offsetPtr; 58 | 59 | for (var i = 0; i < length; i++) 60 | { 61 | if (Elements[i] == null || Elements[i].GetType() != viewerType) 62 | Elements[i] = (IViewer) Activator.CreateInstance(viewerType); 63 | var elementPtr = arrayPtr + elementSize * i; 64 | Elements[i].View(elementPtr, elementType); 65 | } 66 | } 67 | } 68 | 69 | [Serializable] 70 | public class DynamicBlobDataViewer : IViewer 71 | { 72 | public string TypeName; 73 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IViewer[] FieldsViewer; 74 | 75 | public void View(IntPtr dataPtr, Type type) 76 | { 77 | Assert.IsTrue(!type.IsPrimitive && !type.IsEnum && type.IsValueType); 78 | TypeName = type.AssemblyQualifiedName; 79 | var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 80 | Array.Resize(ref FieldsViewer, fields.Length); 81 | for (var i = 0; i < fields.Length; i++) 82 | { 83 | var field = fields[i]; 84 | var viewerType = field.FieldType.FindViewerType(); 85 | if (FieldsViewer[i] == null || FieldsViewer[i].GetType() != viewerType) 86 | FieldsViewer[i] = (IViewer) Activator.CreateInstance(viewerType); 87 | var fieldOffset = UnsafeUtility.GetFieldOffset(field); 88 | FieldsViewer[i].View(dataPtr + fieldOffset, field.FieldType); 89 | } 90 | } 91 | } 92 | 93 | [Serializable] 94 | public class DynamicPtrViewer : IViewer 95 | { 96 | [SerializeReference, UnboxSingleProperty, UnityDrawProperty] public IViewer Value; 97 | 98 | public unsafe void View(IntPtr dataPtr, Type type) 99 | { 100 | Assert.IsTrue(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(BlobPtr<>)); 101 | var dataType = type.GenericTypeArguments[0]; 102 | var viewerType = dataType.FindViewerType(); 103 | if (Value == null || Value.GetType() != viewerType) Value = (IViewer) Activator.CreateInstance(viewerType); 104 | ref var offsetPtr = ref UnsafeUtility.AsRef(dataPtr.ToPointer()); 105 | Value.View(dataPtr + offsetPtr, dataType); 106 | } 107 | } 108 | 109 | [Serializable] 110 | public class DynamicEnumViewer : IViewer 111 | { 112 | public long Ptr; 113 | public string EnumType; 114 | 115 | public void View(IntPtr dataPtr, Type type) 116 | { 117 | Assert.IsTrue(type.IsEnum); 118 | Ptr = dataPtr.ToInt64(); 119 | EnumType = type.AssemblyQualifiedName; 120 | } 121 | } 122 | 123 | public static class Utility 124 | { 125 | public static Type FindViewerType(this Type dataType) 126 | { 127 | var viewerType = typeof(Viewer<>).MakeGenericType(dataType); 128 | viewerType = TypeCache.GetTypesDerivedFrom(viewerType).SingleOrDefault(); 129 | if (viewerType != null) return viewerType; 130 | if (dataType.IsEnum) return typeof(DynamicEnumViewer); 131 | if (dataType.IsGenericType && dataType.GetGenericTypeDefinition() == typeof(BlobPtr<>)) 132 | return typeof(DynamicPtrViewer); 133 | if (dataType.IsGenericType && dataType.GetGenericTypeDefinition() == typeof(BlobArray<>)) 134 | return typeof(DynamicArrayViewer); 135 | if (!dataType.IsPrimitive) return typeof(DynamicBlobDataViewer); 136 | throw new ArgumentException($"cannot find proper viewer {dataType}"); 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /Packages/blob-editor/Runtime/Viewer/Viewers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e87f1d377b1c42638518a7d325bb31cc 3 | timeCreated: 1629881087 -------------------------------------------------------------------------------- /Packages/blob-editor/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.quabug.blob-editor", 3 | "description": "Inspector-editor of blob asset", 4 | "version": "1.4.1", 5 | "unity": "2020.3", 6 | "displayName": "BlobEditor", 7 | "dependencies": { 8 | "com.unity.entities": "0.14.0-preview.19" 9 | }, 10 | "type": "library" 11 | } 12 | -------------------------------------------------------------------------------- /Packages/blob-editor/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c5bb48690e0a3241b8b9d107f6362df 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.animation": "0.7.1-preview.2", 4 | "com.unity.ide.rider": "2.0.7", 5 | "com.unity.ide.visualstudio": "2.0.14", 6 | "com.unity.ide.vscode": "1.2.4", 7 | "com.unity.test-framework": "1.1.29", 8 | "com.unity.ugui": "1.0.0", 9 | "com.unity.modules.ai": "1.0.0", 10 | "com.unity.modules.androidjni": "1.0.0", 11 | "com.unity.modules.animation": "1.0.0", 12 | "com.unity.modules.assetbundle": "1.0.0", 13 | "com.unity.modules.audio": "1.0.0", 14 | "com.unity.modules.cloth": "1.0.0", 15 | "com.unity.modules.director": "1.0.0", 16 | "com.unity.modules.imageconversion": "1.0.0", 17 | "com.unity.modules.imgui": "1.0.0", 18 | "com.unity.modules.jsonserialize": "1.0.0", 19 | "com.unity.modules.particlesystem": "1.0.0", 20 | "com.unity.modules.physics": "1.0.0", 21 | "com.unity.modules.physics2d": "1.0.0", 22 | "com.unity.modules.screencapture": "1.0.0", 23 | "com.unity.modules.terrain": "1.0.0", 24 | "com.unity.modules.terrainphysics": "1.0.0", 25 | "com.unity.modules.tilemap": "1.0.0", 26 | "com.unity.modules.ui": "1.0.0", 27 | "com.unity.modules.uielements": "1.0.0", 28 | "com.unity.modules.umbra": "1.0.0", 29 | "com.unity.modules.unityanalytics": "1.0.0", 30 | "com.unity.modules.unitywebrequest": "1.0.0", 31 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 32 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 33 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 34 | "com.unity.modules.unitywebrequestwww": "1.0.0", 35 | "com.unity.modules.vehicles": "1.0.0", 36 | "com.unity.modules.video": "1.0.0", 37 | "com.unity.modules.vr": "1.0.0", 38 | "com.unity.modules.wind": "1.0.0", 39 | "com.unity.modules.xr": "1.0.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.quabug.blob-editor": { 4 | "version": "file:blob-editor", 5 | "depth": 0, 6 | "source": "embedded", 7 | "dependencies": { 8 | "com.unity.entities": "0.14.0-preview.19" 9 | } 10 | }, 11 | "com.unity.animation": { 12 | "version": "0.7.1-preview.2", 13 | "depth": 0, 14 | "source": "registry", 15 | "dependencies": { 16 | "com.unity.mathematics": "1.2.1", 17 | "com.unity.entities": "0.14.0-preview.19", 18 | "com.unity.collections": "0.12.0-preview.13", 19 | "com.unity.jobs": "0.5.0-preview.14", 20 | "com.unity.burst": "1.3.2", 21 | "com.unity.test-framework": "1.1.13", 22 | "com.unity.dataflowgraph": "0.17.0-preview.4", 23 | "com.unity.test-framework.performance": "2.0.8-preview", 24 | "com.unity.modules.animation": "1.0.0" 25 | }, 26 | "url": "https://packages.unity.com" 27 | }, 28 | "com.unity.burst": { 29 | "version": "1.3.2", 30 | "depth": 1, 31 | "source": "registry", 32 | "dependencies": { 33 | "com.unity.mathematics": "1.1.0" 34 | }, 35 | "url": "https://packages.unity.com" 36 | }, 37 | "com.unity.collections": { 38 | "version": "0.12.0-preview.13", 39 | "depth": 1, 40 | "source": "registry", 41 | "dependencies": { 42 | "com.unity.test-framework.performance": "2.3.1-preview", 43 | "com.unity.burst": "1.3.2" 44 | }, 45 | "url": "https://packages.unity.com" 46 | }, 47 | "com.unity.dataflowgraph": { 48 | "version": "0.17.0-preview.4", 49 | "depth": 1, 50 | "source": "registry", 51 | "dependencies": { 52 | "com.unity.entities": "0.11.1-preview.4", 53 | "com.unity.jobs": "0.2.10-preview.12", 54 | "com.unity.collections": "0.9.0-preview.6", 55 | "com.unity.mathematics": "1.1.0", 56 | "com.unity.burst": "1.3.0" 57 | }, 58 | "url": "https://packages.unity.com" 59 | }, 60 | "com.unity.entities": { 61 | "version": "0.14.0-preview.19", 62 | "depth": 1, 63 | "source": "registry", 64 | "dependencies": { 65 | "com.unity.burst": "1.3.2", 66 | "com.unity.collections": "0.12.0-preview.13", 67 | "com.unity.properties": "1.3.1-preview", 68 | "com.unity.mathematics": "1.1.0", 69 | "com.unity.test-framework.performance": "2.3.1-preview", 70 | "com.unity.serialization": "1.3.1-preview", 71 | "com.unity.nuget.mono-cecil": "0.1.6-preview.2", 72 | "com.unity.jobs": "0.5.0-preview.14", 73 | "com.unity.scriptablebuildpipeline": "1.9.0", 74 | "com.unity.platforms": "0.7.0-preview.8" 75 | }, 76 | "url": "https://packages.unity.com" 77 | }, 78 | "com.unity.ext.nunit": { 79 | "version": "1.0.6", 80 | "depth": 1, 81 | "source": "registry", 82 | "dependencies": {}, 83 | "url": "https://packages.unity.com" 84 | }, 85 | "com.unity.ide.rider": { 86 | "version": "2.0.7", 87 | "depth": 0, 88 | "source": "registry", 89 | "dependencies": { 90 | "com.unity.test-framework": "1.1.1" 91 | }, 92 | "url": "https://packages.unity.com" 93 | }, 94 | "com.unity.ide.visualstudio": { 95 | "version": "2.0.14", 96 | "depth": 0, 97 | "source": "registry", 98 | "dependencies": { 99 | "com.unity.test-framework": "1.1.9" 100 | }, 101 | "url": "https://packages.unity.com" 102 | }, 103 | "com.unity.ide.vscode": { 104 | "version": "1.2.4", 105 | "depth": 0, 106 | "source": "registry", 107 | "dependencies": {}, 108 | "url": "https://packages.unity.com" 109 | }, 110 | "com.unity.jobs": { 111 | "version": "0.5.0-preview.14", 112 | "depth": 1, 113 | "source": "registry", 114 | "dependencies": { 115 | "com.unity.collections": "0.12.0-preview.13", 116 | "com.unity.mathematics": "1.1.0" 117 | }, 118 | "url": "https://packages.unity.com" 119 | }, 120 | "com.unity.mathematics": { 121 | "version": "1.2.1", 122 | "depth": 1, 123 | "source": "registry", 124 | "dependencies": {}, 125 | "url": "https://packages.unity.com" 126 | }, 127 | "com.unity.nuget.mono-cecil": { 128 | "version": "0.1.6-preview.2", 129 | "depth": 2, 130 | "source": "registry", 131 | "dependencies": { 132 | "nuget.mono-cecil": "0.1.6-preview" 133 | }, 134 | "url": "https://packages.unity.com" 135 | }, 136 | "com.unity.nuget.newtonsoft-json": { 137 | "version": "2.0.0-preview", 138 | "depth": 2, 139 | "source": "registry", 140 | "dependencies": {}, 141 | "url": "https://packages.unity.com" 142 | }, 143 | "com.unity.platforms": { 144 | "version": "0.7.0-preview.8", 145 | "depth": 2, 146 | "source": "registry", 147 | "dependencies": { 148 | "com.unity.properties": "1.3.1-preview", 149 | "com.unity.properties.ui": "1.3.1-preview", 150 | "com.unity.scriptablebuildpipeline": "1.6.4-preview", 151 | "com.unity.searcher": "4.0.9", 152 | "com.unity.serialization": "1.3.1-preview" 153 | }, 154 | "url": "https://packages.unity.com" 155 | }, 156 | "com.unity.properties": { 157 | "version": "1.3.1-preview", 158 | "depth": 2, 159 | "source": "registry", 160 | "dependencies": { 161 | "nuget.mono-cecil": "0.1.5-preview", 162 | "com.unity.test-framework.performance": "2.0.8-preview" 163 | }, 164 | "url": "https://packages.unity.com" 165 | }, 166 | "com.unity.properties.ui": { 167 | "version": "1.3.1-preview", 168 | "depth": 3, 169 | "source": "registry", 170 | "dependencies": { 171 | "com.unity.properties": "1.3.1-preview", 172 | "com.unity.serialization": "1.3.1-preview" 173 | }, 174 | "url": "https://packages.unity.com" 175 | }, 176 | "com.unity.scriptablebuildpipeline": { 177 | "version": "1.9.0", 178 | "depth": 2, 179 | "source": "registry", 180 | "dependencies": {}, 181 | "url": "https://packages.unity.com" 182 | }, 183 | "com.unity.searcher": { 184 | "version": "4.0.9", 185 | "depth": 3, 186 | "source": "registry", 187 | "dependencies": {}, 188 | "url": "https://packages.unity.com" 189 | }, 190 | "com.unity.serialization": { 191 | "version": "1.3.1-preview", 192 | "depth": 2, 193 | "source": "registry", 194 | "dependencies": { 195 | "com.unity.collections": "0.8.0-preview.5", 196 | "com.unity.burst": "1.3.0-preview.12", 197 | "com.unity.jobs": "0.2.9-preview.15", 198 | "com.unity.properties": "1.3.1-preview", 199 | "com.unity.test-framework.performance": "2.0.8-preview" 200 | }, 201 | "url": "https://packages.unity.com" 202 | }, 203 | "com.unity.test-framework": { 204 | "version": "1.1.29", 205 | "depth": 0, 206 | "source": "registry", 207 | "dependencies": { 208 | "com.unity.ext.nunit": "1.0.6", 209 | "com.unity.modules.imgui": "1.0.0", 210 | "com.unity.modules.jsonserialize": "1.0.0" 211 | }, 212 | "url": "https://packages.unity.com" 213 | }, 214 | "com.unity.test-framework.performance": { 215 | "version": "2.3.1-preview", 216 | "depth": 2, 217 | "source": "registry", 218 | "dependencies": { 219 | "com.unity.test-framework": "1.1.0", 220 | "com.unity.nuget.newtonsoft-json": "2.0.0-preview" 221 | }, 222 | "url": "https://packages.unity.com" 223 | }, 224 | "com.unity.ugui": { 225 | "version": "1.0.0", 226 | "depth": 0, 227 | "source": "builtin", 228 | "dependencies": { 229 | "com.unity.modules.ui": "1.0.0", 230 | "com.unity.modules.imgui": "1.0.0" 231 | } 232 | }, 233 | "nuget.mono-cecil": { 234 | "version": "0.1.6-preview", 235 | "depth": 3, 236 | "source": "registry", 237 | "dependencies": {}, 238 | "url": "https://packages.unity.com" 239 | }, 240 | "com.unity.modules.ai": { 241 | "version": "1.0.0", 242 | "depth": 0, 243 | "source": "builtin", 244 | "dependencies": {} 245 | }, 246 | "com.unity.modules.androidjni": { 247 | "version": "1.0.0", 248 | "depth": 0, 249 | "source": "builtin", 250 | "dependencies": {} 251 | }, 252 | "com.unity.modules.animation": { 253 | "version": "1.0.0", 254 | "depth": 0, 255 | "source": "builtin", 256 | "dependencies": {} 257 | }, 258 | "com.unity.modules.assetbundle": { 259 | "version": "1.0.0", 260 | "depth": 0, 261 | "source": "builtin", 262 | "dependencies": {} 263 | }, 264 | "com.unity.modules.audio": { 265 | "version": "1.0.0", 266 | "depth": 0, 267 | "source": "builtin", 268 | "dependencies": {} 269 | }, 270 | "com.unity.modules.cloth": { 271 | "version": "1.0.0", 272 | "depth": 0, 273 | "source": "builtin", 274 | "dependencies": { 275 | "com.unity.modules.physics": "1.0.0" 276 | } 277 | }, 278 | "com.unity.modules.director": { 279 | "version": "1.0.0", 280 | "depth": 0, 281 | "source": "builtin", 282 | "dependencies": { 283 | "com.unity.modules.audio": "1.0.0", 284 | "com.unity.modules.animation": "1.0.0" 285 | } 286 | }, 287 | "com.unity.modules.imageconversion": { 288 | "version": "1.0.0", 289 | "depth": 0, 290 | "source": "builtin", 291 | "dependencies": {} 292 | }, 293 | "com.unity.modules.imgui": { 294 | "version": "1.0.0", 295 | "depth": 0, 296 | "source": "builtin", 297 | "dependencies": {} 298 | }, 299 | "com.unity.modules.jsonserialize": { 300 | "version": "1.0.0", 301 | "depth": 0, 302 | "source": "builtin", 303 | "dependencies": {} 304 | }, 305 | "com.unity.modules.particlesystem": { 306 | "version": "1.0.0", 307 | "depth": 0, 308 | "source": "builtin", 309 | "dependencies": {} 310 | }, 311 | "com.unity.modules.physics": { 312 | "version": "1.0.0", 313 | "depth": 0, 314 | "source": "builtin", 315 | "dependencies": {} 316 | }, 317 | "com.unity.modules.physics2d": { 318 | "version": "1.0.0", 319 | "depth": 0, 320 | "source": "builtin", 321 | "dependencies": {} 322 | }, 323 | "com.unity.modules.screencapture": { 324 | "version": "1.0.0", 325 | "depth": 0, 326 | "source": "builtin", 327 | "dependencies": { 328 | "com.unity.modules.imageconversion": "1.0.0" 329 | } 330 | }, 331 | "com.unity.modules.subsystems": { 332 | "version": "1.0.0", 333 | "depth": 1, 334 | "source": "builtin", 335 | "dependencies": { 336 | "com.unity.modules.jsonserialize": "1.0.0" 337 | } 338 | }, 339 | "com.unity.modules.terrain": { 340 | "version": "1.0.0", 341 | "depth": 0, 342 | "source": "builtin", 343 | "dependencies": {} 344 | }, 345 | "com.unity.modules.terrainphysics": { 346 | "version": "1.0.0", 347 | "depth": 0, 348 | "source": "builtin", 349 | "dependencies": { 350 | "com.unity.modules.physics": "1.0.0", 351 | "com.unity.modules.terrain": "1.0.0" 352 | } 353 | }, 354 | "com.unity.modules.tilemap": { 355 | "version": "1.0.0", 356 | "depth": 0, 357 | "source": "builtin", 358 | "dependencies": { 359 | "com.unity.modules.physics2d": "1.0.0" 360 | } 361 | }, 362 | "com.unity.modules.ui": { 363 | "version": "1.0.0", 364 | "depth": 0, 365 | "source": "builtin", 366 | "dependencies": {} 367 | }, 368 | "com.unity.modules.uielements": { 369 | "version": "1.0.0", 370 | "depth": 0, 371 | "source": "builtin", 372 | "dependencies": { 373 | "com.unity.modules.ui": "1.0.0", 374 | "com.unity.modules.imgui": "1.0.0", 375 | "com.unity.modules.jsonserialize": "1.0.0", 376 | "com.unity.modules.uielementsnative": "1.0.0" 377 | } 378 | }, 379 | "com.unity.modules.uielementsnative": { 380 | "version": "1.0.0", 381 | "depth": 1, 382 | "source": "builtin", 383 | "dependencies": { 384 | "com.unity.modules.ui": "1.0.0", 385 | "com.unity.modules.imgui": "1.0.0", 386 | "com.unity.modules.jsonserialize": "1.0.0" 387 | } 388 | }, 389 | "com.unity.modules.umbra": { 390 | "version": "1.0.0", 391 | "depth": 0, 392 | "source": "builtin", 393 | "dependencies": {} 394 | }, 395 | "com.unity.modules.unityanalytics": { 396 | "version": "1.0.0", 397 | "depth": 0, 398 | "source": "builtin", 399 | "dependencies": { 400 | "com.unity.modules.unitywebrequest": "1.0.0", 401 | "com.unity.modules.jsonserialize": "1.0.0" 402 | } 403 | }, 404 | "com.unity.modules.unitywebrequest": { 405 | "version": "1.0.0", 406 | "depth": 0, 407 | "source": "builtin", 408 | "dependencies": {} 409 | }, 410 | "com.unity.modules.unitywebrequestassetbundle": { 411 | "version": "1.0.0", 412 | "depth": 0, 413 | "source": "builtin", 414 | "dependencies": { 415 | "com.unity.modules.assetbundle": "1.0.0", 416 | "com.unity.modules.unitywebrequest": "1.0.0" 417 | } 418 | }, 419 | "com.unity.modules.unitywebrequestaudio": { 420 | "version": "1.0.0", 421 | "depth": 0, 422 | "source": "builtin", 423 | "dependencies": { 424 | "com.unity.modules.unitywebrequest": "1.0.0", 425 | "com.unity.modules.audio": "1.0.0" 426 | } 427 | }, 428 | "com.unity.modules.unitywebrequesttexture": { 429 | "version": "1.0.0", 430 | "depth": 0, 431 | "source": "builtin", 432 | "dependencies": { 433 | "com.unity.modules.unitywebrequest": "1.0.0", 434 | "com.unity.modules.imageconversion": "1.0.0" 435 | } 436 | }, 437 | "com.unity.modules.unitywebrequestwww": { 438 | "version": "1.0.0", 439 | "depth": 0, 440 | "source": "builtin", 441 | "dependencies": { 442 | "com.unity.modules.unitywebrequest": "1.0.0", 443 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 444 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 445 | "com.unity.modules.audio": "1.0.0", 446 | "com.unity.modules.assetbundle": "1.0.0", 447 | "com.unity.modules.imageconversion": "1.0.0" 448 | } 449 | }, 450 | "com.unity.modules.vehicles": { 451 | "version": "1.0.0", 452 | "depth": 0, 453 | "source": "builtin", 454 | "dependencies": { 455 | "com.unity.modules.physics": "1.0.0" 456 | } 457 | }, 458 | "com.unity.modules.video": { 459 | "version": "1.0.0", 460 | "depth": 0, 461 | "source": "builtin", 462 | "dependencies": { 463 | "com.unity.modules.audio": "1.0.0", 464 | "com.unity.modules.ui": "1.0.0", 465 | "com.unity.modules.unitywebrequest": "1.0.0" 466 | } 467 | }, 468 | "com.unity.modules.vr": { 469 | "version": "1.0.0", 470 | "depth": 0, 471 | "source": "builtin", 472 | "dependencies": { 473 | "com.unity.modules.jsonserialize": "1.0.0", 474 | "com.unity.modules.physics": "1.0.0", 475 | "com.unity.modules.xr": "1.0.0" 476 | } 477 | }, 478 | "com.unity.modules.wind": { 479 | "version": "1.0.0", 480 | "depth": 0, 481 | "source": "builtin", 482 | "dependencies": {} 483 | }, 484 | "com.unity.modules.xr": { 485 | "version": "1.0.0", 486 | "depth": 0, 487 | "source": "builtin", 488 | "dependencies": { 489 | "com.unity.modules.physics": "1.0.0", 490 | "com.unity.modules.jsonserialize": "1.0.0", 491 | "com.unity.modules.subsystems": "1.0.0" 492 | } 493 | } 494 | } 495 | } 496 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneWindows.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 3, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "UsePlatformSDKLinker": false, 9 | "CpuMinTargetX32": 0, 10 | "CpuMaxTargetX32": 0, 11 | "CpuMinTargetX64": 0, 12 | "CpuMaxTargetX64": 0, 13 | "CpuTargetsX32": 6, 14 | "CpuTargetsX64": 72 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 9fc0d4010bbf28b4594072e72b8655ab 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerPaddingPower: 1 14 | m_EtcTextureCompressorBehavior: 1 15 | m_EtcTextureFastCompressor: 1 16 | m_EtcTextureNormalCompressor: 2 17 | m_EtcTextureBestCompressor: 4 18 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref;tt;t4;ttinclude 19 | m_ProjectGenerationRootNamespace: 20 | m_EnableTextureStreamingInEditMode: 1 21 | m_EnableTextureStreamingInPlayMode: 1 22 | m_AsyncShaderCompilation: 1 23 | m_CachingShaderPreprocessor: 1 24 | m_PrefabModeAllowAutoSave: 1 25 | m_EnterPlayModeOptionsEnabled: 0 26 | m_EnterPlayModeOptions: 3 27 | m_GameObjectNamingDigits: 1 28 | m_GameObjectNamingScheme: 0 29 | m_AssetNamingUsesSpace: 1 30 | m_UseLegacyProbeSampleCount: 0 31 | m_SerializeInlineMappingsOnOneLine: 1 32 | m_DisableCookiesInLightmapper: 0 33 | m_AssetPipelineMode: 1 34 | m_CacheServerMode: 0 35 | m_CacheServerEndpoint: 36 | m_CacheServerNamespacePrefix: default 37 | m_CacheServerEnableDownload: 1 38 | m_CacheServerEnableUpload: 1 39 | m_CacheServerEnableAuth: 0 40 | m_CacheServerEnableTls: 0 41 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 1 16 | m_EnablePackageDependencies: 1 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 1 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.30f1 2 | m_EditorVersionWithRevision: 2020.3.30f1 (1fb1bf06830e) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/TimelineSettings.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: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | assetDefaultFramerate: 60 16 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | UnityAdsSettings: 27 | m_Enabled: 0 28 | m_InitializeOnStartup: 1 29 | m_TestMode: 0 30 | m_IosGameId: 31 | m_AndroidGameId: 32 | m_GameIds: {} 33 | m_GameId: 34 | PerformanceReportingSettings: 35 | m_Enabled: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![openupm](https://img.shields.io/npm/v/com.quabug.blob-editor?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.quabug.blob-editor/) 2 | # BlobEditor 3 | ![image](https://user-images.githubusercontent.com/683655/130836799-34c39606-e70f-4ac7-afd5-5ab087e1f797.png) 4 | - [**BlobBuilder**](README.md#blobbuilder): Edit `BlobAsset` in _Inspector_ and then easily create from code. 5 | - [**BlobViewer**](README.md#blobviewer): Display `Blob` data in _Inspector_ at editor-playing-mode. 6 | 7 | 8 | ## Upgrade Note 9 | ⚠️ upgrade from version 1.1 will lose data, you should either recreate data manually or use `BlobAssetV1` 10 | 11 | ## Installation 12 | - (Recommend) [OpenUPM](https://openupm.com/packages/com.quabug.blob-editor/): `openupm add com.quabug.blob-editor` 13 | - or UPM: edit *Packages/manifest.json* 14 | ``` 15 | { 16 | "dependencies": { 17 | "com.quabug.blob-editor": "1.4.0", 18 | ... 19 | }, 20 | "scopedRegistries": [ 21 | { 22 | "name": "package.openupm.com", 23 | "url": "https://package.openupm.com", 24 | "scopes": [ 25 | "com.quabug.blob-editor" 26 | ] 27 | } 28 | ] 29 | } 30 | ``` 31 | 32 | --- 33 | ## **BlobBuilder** 34 | _Edit and build `BlobAsset` from inspector_ 35 | 36 | ### `BlobAsset<>` 37 | 38 | ``` c# 39 | public class SingleBlobComponent : MonoBehaviour 40 | { 41 | public BlobAsset> IntArray; 42 | 43 | private void Awake() 44 | { 45 | // get `BlobAssetReference` from `BlobAsset` 46 | BlobAssetReference> blob = IntArray.Reference; 47 | // or use blob value directly 48 | ref BlobArray _ = ref IntArray.Value; 49 | } 50 | } 51 | ``` 52 | 53 | ``` c# 54 | struct Blob 55 | { 56 | public int Int; 57 | public BlobString String; 58 | } 59 | 60 | public class BlobStructureComponent : MonoBehaviour 61 | { 62 | public BlobAsset BlobValue; 63 | 64 | private void Awake() 65 | { 66 | // get `BlobAssetReference` from `BlobAsset` 67 | BlobAssetReference blob = BlobValue.Reference; 68 | // or use blob value directly 69 | string _ = BlobValue.Value.String.ToString(); 70 | } 71 | } 72 | ``` 73 | 74 | ### Extend builder for new type 75 | 76 | Builders of *primitive* types and *com.unity.mathematics* types are provided by default. 77 | 78 | A specific builder must be provided for any new type. 79 | 80 | Take `Guid` as example: 81 | ``` c# 82 | public struct GuidBlob 83 | { 84 | public Guid Value; 85 | } 86 | 87 | [Serializable] 88 | public class GuidBuilder : Builder 89 | { 90 | public string Guid = System.Guid.NewGuid().ToString(); 91 | 92 | public override void Build(BlobBuilder builder, ref Guid data) 93 | { 94 | data = System.Guid.Parse(Guid); 95 | } 96 | } 97 | ``` 98 | 99 | - `PlainDataBuilder<>`: Builder of POD. Show the POD as whole in inspector. Not support data with its own builder, e.g. `BlobPtr`, `BlobArray` or `BlobString`. 100 | - `BlobDataBuilder<>`: Builder of structure with **Blob-Specific** data inside. Split each data inside structure into its own builder to show and edit. Support data with `DefaultBuilder` or `CustomBuilder`, e.g. `BlobPtr`, `BlobArray` or `BlobString`. 101 | - `ArrayBuilder<>`: Builder for `BlobArray<>`. 102 | - `PtrBuilder<>`: Builder for `BlobPtr<>`. 103 | 104 | ### `DefaultBuilderAttribute` and `CustomBuilderAttribute` 105 | There's may have multiple builders for a single type, one of them must be defined as `DefaultBuilder`, or use `CustomBuilder` to assign a specific builder for a value of blob. 106 | ``` c# 107 | [Serializable, DefaultBuilder] 108 | public class StringBuilder : Builder 109 | { 110 | public string Value = ""; 111 | 112 | public override void Build(BlobBuilder builder, ref BlobString data) 113 | { 114 | builder.AllocateString(ref data, Value); 115 | } 116 | } 117 | 118 | // a builder of `BlobString` which save name of *GameObject* into `BlobString` 119 | [Serializable] 120 | public class ObjectName : Builder 121 | { 122 | public GameObject GameObject; 123 | 124 | public override void Build(BlobBuilder builder, ref BlobString data) 125 | { 126 | builder.AllocateString(ref data, GameObject == null ? "" : GameObject.name); 127 | } 128 | } 129 | 130 | public struct Blob 131 | { 132 | public BlobString String; // will use `StringBuilder` by default 133 | [CustomBuilder(typeof(ObjectName))] public BlobString ObjectName; 134 | } 135 | ``` 136 | 137 | --- 138 | ## **BlobViewer** 139 | _Display `Blob` data in Inspector at editor-playing-mode_ 140 | 141 | ### `BlobViewer<>` 142 | ``` c# 143 | public class BlobViewerComponent : MonoBehaviour 144 | { 145 | public BlobViewer Viewer; 146 | 147 | private void Awake() 148 | { 149 | // set blob into viewer to inspect 150 | BlobAssetReference someBlob = ...; 151 | Viewer.View(someBlob); 152 | } 153 | } 154 | ``` 155 | 156 | ### Extend viewer for new type 157 | ``` c# 158 | [Serializable] 159 | public class GuidViewer : Viewer 160 | { 161 | // declare a serialized field for unity to show in inspector. 162 | public string Guid = System.Guid.NewGuid().ToString(); 163 | 164 | // assign value from blob data to serialized field in `View` method. 165 | public override void View(ref Guid data) 166 | { 167 | Guid = data.ToString(); 168 | } 169 | } 170 | ``` 171 | --------------------------------------------------------------------------------