├── .gitignore ├── Wiki ├── Images │ ├── uguidots-logo.png │ ├── batched-mesh-authoring.jpg │ ├── uguidots-logo.png.meta │ └── batched-mesh-authoring.jpg.meta ├── Home.md.meta ├── Text.md.meta ├── Button.md.meta ├── Canvas.md.meta ├── Close.md.meta ├── Image.md.meta ├── Material.md.meta ├── Numerics.md.meta ├── Rendering.md.meta ├── Shaders.md.meta ├── Conversions.md.meta ├── Images.meta ├── Material.md ├── Home.md ├── Rendering.md ├── Conversions.md ├── Numerics.md ├── Shaders.md ├── Image.md ├── Text.md ├── Close.md └── Button.md ├── Collections ├── README.md ├── README.md.meta ├── Unsafe.meta ├── UGUIDots.Collections.asmdef.meta ├── Unsafe │ ├── UnsafeArray.cs.meta │ └── UnsafeArray.cs └── UGUIDots.Collections.asmdef ├── CHANGELOG.md.meta ├── LICENSE.md.meta ├── README.md.meta ├── package.json.meta ├── CONTRIBUTING.md.meta ├── Core.meta ├── Wiki.meta ├── Analyzers.meta ├── Common.meta ├── Controls.meta ├── Editor.meta ├── Materials.meta ├── Prefabs.meta ├── Shaders.meta ├── Collections.meta ├── Common.Tests.meta ├── Controls.Tests.meta ├── Core.Tests.meta ├── Core ├── Authoring.meta ├── Systems.meta ├── Components.meta ├── Systems │ ├── Render.meta │ ├── Conversions.meta │ ├── Transforms.meta │ ├── UpdateGroup.cs.meta │ ├── Render │ │ ├── TextUtil.cs.meta │ │ ├── AddMeshSystem.cs.meta │ │ ├── BuildCanvasMeshSystem.cs.meta │ │ ├── UpdateMeshSliceSystem.cs.meta │ │ ├── BatchCanvasVertexSystem.cs.meta │ │ ├── BuildImageVertexDataSystem.cs.meta │ │ ├── BuildTextVertexDataSystem.cs.meta │ │ ├── ButtonColorStateSystem.cs.meta │ │ ├── MaterialPropertySystem.cs.meta │ │ ├── OrthographicRenderSystem.cs.meta │ │ ├── UpdateLocalMeshDataSystem.cs.meta │ │ ├── CanvasMetadataDisposalSystem.cs.meta │ │ ├── ReactiveSubgroupToggleSystem.cs.meta │ │ ├── ResolutionDeltaRebuildSystem.cs.meta │ │ ├── CanvasMetadataDisposalSystem.cs │ │ ├── AddMeshSystem.cs │ │ ├── ReactiveSubgroupToggleSystem.cs │ │ ├── ResolutionDeltaRebuildSystem.cs │ │ ├── OrthographicRenderSystem.cs │ │ ├── MaterialPropertySystem.cs │ │ ├── ButtonColorStateSystem.cs │ │ └── BuildCanvasMeshSystem.cs │ ├── Transforms │ │ ├── AnchorSystem.cs.meta │ │ ├── CanvasScalerSystem.cs.meta │ │ ├── StretchImageSystem.cs.meta │ │ ├── StretchImageSystem.cs │ │ └── CanvasScalerSystem.cs │ ├── Conversions │ │ ├── ImageConversionSystem.cs.meta │ │ ├── TextConversionSystem.cs.meta │ │ ├── ButtonConversionSystem.cs.meta │ │ ├── CanvasConversionSystem.cs.meta │ │ ├── RectTransformConversionSystem.cs.meta │ │ ├── VisualAssetsConversionSystem.cs.meta │ │ ├── ButtonConversionSystem.cs │ │ ├── RectTransformConversionSystem.cs │ │ ├── VisualAssetsConversionSystem.cs │ │ ├── CanvasConversionSystem.cs │ │ └── ImageConversionSystem.cs │ └── UpdateGroup.cs ├── UGUIDots.Core.asmdef.meta ├── Authoring │ ├── Render.meta │ └── Render │ │ ├── MaterialPropertyAuthoringComponent.cs.meta │ │ ├── BatchedMeshAuthoring.cs.meta │ │ ├── RenderCommandAuthoring.cs.meta │ │ ├── MaterialPropertyAuthoringComponent.cs │ │ ├── RenderCommandAuthoring.cs │ │ └── BatchedMeshAuthoring.cs ├── Components │ ├── Render.meta │ ├── Transforms.meta │ ├── Transforms │ │ ├── ResolutionChangeEvt.cs │ │ ├── Stretch.cs.meta │ │ ├── FontExtensions.cs.meta │ │ ├── HierarchyUtils.cs.meta │ │ ├── AnchorComponents.cs.meta │ │ ├── ResolutionChangeEvt.cs.meta │ │ ├── TransformExtensions.cs.meta │ │ ├── Stretch.cs │ │ ├── HierarchyUtils.cs │ │ ├── TransformExtensions.cs │ │ └── FontExtensions.cs │ ├── Dimensions.cs.meta │ ├── ImageComponents.cs.meta │ ├── Render │ │ ├── FillType.cs.meta │ │ ├── MeshTags.cs.meta │ │ ├── BatchedMesh.cs.meta │ │ ├── MeshUtils.cs.meta │ │ ├── RenderCommand.cs.meta │ │ ├── MaterialComponents.cs.meta │ │ ├── MeshComponents.cs.meta │ │ ├── ShaderIDConstants.cs.meta │ │ ├── TextureComponents.cs.meta │ │ ├── OrthographicRenderPass.cs.meta │ │ ├── OrthographicRenderFeature.cs.meta │ │ ├── OrthographicRenderPass.cs │ │ ├── RenderCommand.cs │ │ ├── ShaderIDConstants.cs │ │ ├── MeshTags.cs │ │ ├── OrthographicRenderFeature.cs │ │ ├── FillType.cs │ │ ├── TextureComponents.cs │ │ ├── BatchedMesh.cs │ │ ├── MaterialComponents.cs │ │ ├── MeshComponents.cs │ │ └── MeshUtils.cs │ ├── TextComponents.cs.meta │ ├── ButtonComponents.cs.meta │ ├── CanvasComponents.cs.meta │ ├── CanvasComponents.cs │ ├── ButtonComponents.cs │ ├── ImageComponents.cs │ └── Dimensions.cs └── UGUIDots.Core.asmdef ├── Collections.Tests.meta ├── Common ├── UGUIDots.Common.asmdef.meta ├── NumericUtils.cs.meta ├── UGUIDots.Common.asmdef └── NumericUtils.cs ├── Controls ├── Authoring.meta ├── Components.meta ├── Systems.meta ├── Systems │ ├── Mobile.meta │ ├── Messaging.meta │ ├── Standalone.meta │ ├── Mobile │ │ ├── UGUIDots.Controls.Mobile.asmdef.meta │ │ ├── CopyTouchDataSystem.cs.meta │ │ ├── MobileMouseCollisionSystem.cs.meta │ │ ├── UGUIDots.Controls.Mobile.asmdef │ │ ├── CopyTouchDataSystem.cs │ │ └── MobileMouseCollisionSystem.cs │ ├── Standalone │ │ ├── UGUIDots.Controls.Standalone.asmdef.meta │ │ ├── StandaloneMouseCollisionSystem.cs.meta │ │ ├── UGUIDots.Controls.Standalone.asmdef │ │ └── StandaloneMouseCollisionSystem.cs │ ├── UpdateGroup.cs.meta │ ├── Messaging │ │ ├── ButtonMessageSystem.cs.meta │ │ ├── ToggleVisibilitySystem.cs.meta │ │ └── ButtonMessageSystem.cs │ └── UpdateGroup.cs ├── UGUIDots.Controls.asmdef.meta ├── Components │ ├── InputComponents.cs.meta │ ├── ButtonControlComponents.cs.meta │ ├── InputComponents.cs │ └── ButtonControlComponents.cs ├── Authoring │ ├── ButtonTypeAuthoring.cs.meta │ ├── CloseButtonAuthoring.cs.meta │ ├── MobileInputAuthoring.cs.meta │ ├── StandaloneInputAuthoring.cs.meta │ ├── ButtonTypeAuthoring.cs │ ├── MobileInputAuthoring.cs │ ├── StandaloneInputAuthoring.cs │ └── CloseButtonAuthoring.cs └── UGUIDots.Controls.asmdef ├── Editor ├── UGUIDots.Editor.asmdef.meta ├── BatchedMeshAuthoringEditor.cs.meta ├── UGUIDots.Editor.asmdef └── BatchedMeshAuthoringEditor.cs ├── Controls.Tests ├── Mobile.meta ├── Controls.Tests.asmdef.meta ├── Mobile │ └── MobileMouseCollisionSystemTests.cs.meta └── Controls.Tests.asmdef ├── Analyzers ├── UGUIDots.Analyzers.asmdef.meta ├── BatchAnalysis.cs.meta ├── UGUIDots.Analyzers.asmdef └── BatchAnalysis.cs ├── Core.Tests ├── UGUIDots.Core.Tests.asmdef.meta ├── TestFixture.cs.meta ├── UGUIDots.Core.Tests.asmdef └── TestFixture.cs ├── Collections.Tests ├── Collections.Tests.asmdef.meta ├── UnsafeArrayTests.cs.meta ├── Collections.Tests.asmdef └── UnsafeArrayTests.cs ├── Common.Tests ├── UGUIDots.Common.Tests.asmdef.meta ├── NumericUtilsTests.cs.meta ├── UGUIDots.Common.Tests.asmdef └── NumericUtilsTests.cs ├── Materials ├── DefaultImage.mat.meta └── DefaultImage.mat ├── Prefabs ├── Default URP Pipeline.asset.meta ├── Default URP Pipeline_Renderer.asset.meta ├── Default URP Pipeline.asset └── Default URP Pipeline_Renderer.asset ├── Shaders ├── Common.hlsl.meta ├── DefaultImage.hlsl.meta ├── DefaultImage.shader.meta ├── Common.hlsl ├── DefaultImage.shader └── DefaultImage.hlsl ├── package.json ├── LICENSE.md ├── CONTRIBUTING.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | 3 | *.swp 4 | npm-debug.log* 5 | -------------------------------------------------------------------------------- /Wiki/Images/uguidots-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InitialPrefabs/UGUIDOTS/HEAD/Wiki/Images/uguidots-logo.png -------------------------------------------------------------------------------- /Collections/README.md: -------------------------------------------------------------------------------- 1 | # Collections 2 | 3 | These are temporary until unsafe versions of Unity's collections are released. 4 | -------------------------------------------------------------------------------- /Wiki/Images/batched-mesh-authoring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InitialPrefabs/UGUIDOTS/HEAD/Wiki/Images/batched-mesh-authoring.jpg -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bec19f89efe8e184b83a3ce88784aa58 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00f5754f3cd4ca44baec58a11fee92b8 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4596c6809ecc8403dbdcf032ddc4bd15 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Home.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee0778847f4a9534280d7c8aa332de28 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Text.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9857a4a86f159b84f9df11ddbed58a86 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc352c81dab48214199d257823fa0412 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca9c6fe60485dec45b61739248dae488 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Button.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fe5bb2540928084592a7222f622f0c5 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Canvas.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61f7c03526978b442b4826cc6d1d842d 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Close.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37fe5eba414d041459a911f2f3cc2b3b 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Image.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 956439b977eb838498a51dde09297e9b 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Material.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e62326c3048d4762a935fbc27c7203c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Numerics.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7b390f89d3fe49408e2654a54e20d80 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Rendering.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 552cafa5daaa83349bc75d6eb2c42d22 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Wiki/Shaders.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4381f0d7a78db943a79d67551024afe 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Collections/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b165b3cc1fec7d947885f1b7291517a6 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4b2d7b6aff344ae3b4cb48a7d8942fd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Wiki.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2caee72700ab2e043bf1ad0ad5458cfc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Wiki/Conversions.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45583dca43ca84b30af57a7af1b52b46 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Analyzers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56e46e0e7c212364a9c72857f3bfab49 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7ec6c30b0738ff24a8ec80133eeaf38f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32de127d516374823bde9a903080bc1d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae272fbe400c7bd4ebe191ff56204814 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a65da27f55cd9d1499a5262e337cef67 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f079aed65589b4471b99f79370c02a46 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6c5fb94fdff6a94db272b6a667b4a9a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Collections.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c214a7ec5a8450a4b926b637be1765c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Common.Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8f4cd575e4d23c4fab8d5127f00824e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls.Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfa33aa02bc5d1441b625e72644fc9e6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core.Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0378ec8517b0ae4c988d335671d277f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Authoring.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8db56fe76b1b4946ab45dc710742e4a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec75909294af14f049d09770b3011bf4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Wiki/Images.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4417e0b52578d544f9cf2b16724a4be8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Collections.Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12ae6f3b783187548b40850a4caa41a2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Collections/Unsafe.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 159f78ec061ac7e4f8ec55c422a7f751 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Common/UGUIDots.Common.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f36bc0aeb435984fb19ecbd27b87a1f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Controls/Authoring.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68da5ee940d24430d9c89936ccc93285 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 50412d00c0a564a6597876c7af6f61e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d572b866882447f3800697638c616a6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d45c44d395f334a7690a8fa164dda3c6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Systems/Render.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0745358fd7d3694c8870de8a4cea1fa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/UGUIDots.Core.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d33a885a34af140b7ac6735751616c27 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/UGUIDots.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 673c3c0420fa36c4e8921de259f682ca 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Controls.Tests/Mobile.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d0f6cc0964168345ac01b82b94ff385 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7de151911151a3f45bcd28cf0090f724 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/UGUIDots.Controls.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15b5cedb175ab42a5ab92bf9bb11f169 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Core/Authoring/Render.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f672da18c0e9994ca5944c38e9a0586 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Components/Render.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b74c31b153e6a594a99757f10133583a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Systems/Conversions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61a9ac5a1beb349219e5fc700d3b6435 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core/Systems/Transforms.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a0930398648c4a389eb1471c3b0c755 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Analyzers/UGUIDots.Analyzers.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fef50387be9e4be4ca3d64c31f370667 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Collections/UGUIDots.Collections.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3430abf52b53b5c4ba9083ed24e0e54b 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Controls.Tests/Controls.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a602d8ecd3ea1f44bab47f1ef4cb137 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Controls/Systems/Messaging.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3ef353f143679e49a697b8eaa5a1b0e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/Systems/Standalone.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfd3b8404e18d2645abd437d38b4ac84 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Core.Tests/UGUIDots.Core.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a414421923919a8459d702da73d824bf 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Core/Components/Transforms.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f2e7e7a949a74c8a86629d48fe168a4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Collections.Tests/Collections.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93be2bf7cc6e1aa4390168bb641f6105 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Common.Tests/UGUIDots.Common.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccd3aa813ea9ed740bcb7958994bb185 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Core/Authoring/Render/MaterialPropertyAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbc2e17aca6374f4184161cb81bcc1ff 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Materials/DefaultImage.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 057d22d20c70e4542a369d7c6971610c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Prefabs/Default URP Pipeline.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8346269f1030f1246818f1011b2e3107 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile/UGUIDots.Controls.Mobile.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a93795db662dc6d43872644470467a76 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Controls/Systems/Standalone/UGUIDots.Controls.Standalone.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ccff37a73fd158c4e936a11bd2b570fc 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Prefabs/Default URP Pipeline_Renderer.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e338f2be5c0c93840adc956486c9f34c 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Shaders/Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 439d229e78ec0e743a6b620ecd1262ae 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/DefaultImage.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aedc53cbb43f5924e8eddbeb10b92698 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/DefaultImage.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d2c9acbbe318614684bfdc4c256d8b0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Core/Components/Transforms/ResolutionChangeEvt.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Transforms { 4 | 5 | /// 6 | /// Marks a messaging entity that the resolution has changed. 7 | /// 8 | public struct ResolutionChangeEvt : IComponentData { } 9 | } 10 | -------------------------------------------------------------------------------- /Common/NumericUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88dfb8fe3cd208840ba1a50aee16070f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Analyzers/BatchAnalysis.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acdb4e57e86c8c5479636c4373d70185 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core.Tests/TestFixture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d41509a4e6e04c74d817885dc6c47df6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Dimensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 615e7172a82cb4cd1848f7afe67aea9f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/UpdateGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 982980348bd8c4ae28c428a0d69b3b6a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Wiki/Material.md: -------------------------------------------------------------------------------- 1 | # Material 2 | 3 | Like Textures, Materials are declared their own entities by looping through all converted `Image` and `TextMeshProUGUI` 4 | components via the `VisualAssetDeclarationSystem`. 5 | 6 | All material entities are linked to their associative entities via the `LinkedMaterialEntity` component. 7 | -------------------------------------------------------------------------------- /Collections/Unsafe/UnsafeArray.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc09283f8bfd7db4b8769c0b550bba24 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Common.Tests/NumericUtilsTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b593c06581e9ebb41858774b17d79c83 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Systems/UpdateGroup.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8e5f244ad9df4010963f1e3f02fc9d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/ImageComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b13f5633d48284d2e85fc49901849513 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/FillType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1da0778882a947e4a8dfce3341e76d56 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshTags.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 604e69d5545980d41abb7bd945f816d8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/TextComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d77f65f42a5b1436d96e803277aaa20b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/TextUtil.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd04e7d583bec43069c56471f363835b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Collections.Tests/UnsafeArrayTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ec1b38d8c6fa6548899db3dd44ce229 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Components/InputComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f46b677e7c4fb477f8f589f87bf84d56 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/ButtonComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98c01b3b543394f2292f107a835df7c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/CanvasComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 25dc0e8cde1aa4102b745f78fddfe1fb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/BatchedMesh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be3c33d04882ab6488545e76d06940a3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c29a1f35cb425ae4a915632506d9db00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/RenderCommand.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 457b43c12531c6945b6073084b9af179 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/Stretch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea025401dd5674593954ca7ea199951f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/AddMeshSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a1eaf8e092b8bd429c75e3aa5341f99 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Transforms/AnchorSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d90d191cdab894add8384296c67e27ba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/BatchedMeshAuthoringEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab87b93b3324d6a4b8a65c4d52cca593 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Authoring/ButtonTypeAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bdab13ed5c1b846e78c4f1836ac8f9fa 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Authoring/CloseButtonAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06e80a7623614487a86de6fec44fcf7e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Authoring/MobileInputAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd6972954dd0b4647861d64ce14d1a0c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/MaterialComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b2b94ce6c52743f5887276ed723f8f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2e161c7c7e1f2245bc99a579cdadb4f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/ShaderIDConstants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4113f2669909964aa6bc05ba638cff9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/TextureComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d4351769000ea84994ef6f6d3131466 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/FontExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69be58573281d4d3d8f7bd1ad8f4694c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/HierarchyUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b599037da333084eada76ec477f3224 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/BuildCanvasMeshSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80c2cdc0b9a27403b9e344af219369af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/UpdateMeshSliceSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf0e6bbbd1fcd5842ad6ae37444b52e3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Authoring/StandaloneInputAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e93ed9c4790084f49821cf02d467735b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Components/ButtonControlComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3d0c8af4a276473e8ed15cedd744adf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Systems/Messaging/ButtonMessageSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70491fe314d2d5a4f9ba3f7cfdfffa29 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile/CopyTouchDataSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e96eec2fc381a648aaee28211f0bd69 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Authoring/Render/BatchedMeshAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb66bb67f0b3b5c43b067b6b196daeb0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Authoring/Render/RenderCommandAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcff906e6b00b954795a34475331fca6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/OrthographicRenderPass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14cdeb35bdb34cd4088d3e5df941d6ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/AnchorComponents.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc4bad2ce2c414bab8ce2486cc8d7e54 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/ResolutionChangeEvt.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 813a108767b2fcc4abbf8f937ff09c8b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Transforms/TransformExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bd450f397e214ce4a4f8223b277d100 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/ImageConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5b22d6721f2f42b5a5f765fb625b996 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/TextConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6f7e4e98391d4febabeab1c71b1c049 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/BatchCanvasVertexSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 443e9e78793d2bd459123a7396563b1b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/BuildImageVertexDataSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98b145891f6ed4c479436380b2144d96 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/BuildTextVertexDataSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc39d3a1bc0df4bf39e1c637a4037757 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/ButtonColorStateSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 330e59586d0ff4441a40709133e63146 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/MaterialPropertySystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8b4a9dd32b738a48b4b46234b034ec8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/OrthographicRenderSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c9a0c73ebd064f908da1ad5ed41af94 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/UpdateLocalMeshDataSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1585ed336646da41bdd69304fa84355 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Transforms/CanvasScalerSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 331216980b95d164b979e3ad02e8101e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Transforms/StretchImageSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5227f16f3e95645aea9e7f78ccade821 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Systems/Messaging/ToggleVisibilitySystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5de8699a41b85d04f957bcf436ed6e09 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile/MobileMouseCollisionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a816020e265f4194ab63bf2de0626ec5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Components/Render/OrthographicRenderFeature.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac620f9bc3a53f2478bc078f9d7082bd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/ButtonConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23a4d10fecb17491394e79bee42f57f3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/CanvasConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b832f6ae0d833e4ea74b43179e5657d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/CanvasMetadataDisposalSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1d1e9c885471024f8dd80dbbd9ec9d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/ReactiveSubgroupToggleSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5c1687daab62eb4fa97503c0c3e4ecb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Render/ResolutionDeltaRebuildSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 055d4e59e7dda3e4ea7b327dc17f0f05 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Controls.Tests/Mobile/MobileMouseCollisionSystemTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab0a76005fbcbf046ac66762dcdee8ea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/RectTransformConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2d824b8c9b6d3c45ac7903266422404 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/VisualAssetsConversionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2eac166785e85844bb50c745cf5a39e8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Shaders/Common.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UGUIDOTS_COMMON 2 | #define UGUIDOTS_COMMON 3 | 4 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" 5 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl" 6 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /Controls/Systems/Standalone/StandaloneMouseCollisionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9eb102625658449e491758b3bfdd6ea5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Core/Authoring/Render/MaterialPropertyAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace UGUIDots.Render.Authoring { 5 | 6 | [System.Obsolete] 7 | public class MaterialPropertyAuthoringComponent : MonoBehaviour, IConvertGameObjectToEntity { 8 | 9 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Collections/UGUIDots.Collections.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Collections", 3 | "references": [ 4 | "GUID:e0cd26848372d4e5c891c569017e11f1" 5 | ], 6 | "includePlatforms": [], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": true, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Common/UGUIDots.Common.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Common", 3 | "references": [ 4 | "GUID:e0cd26848372d4e5c891c569017e11f1", 5 | "GUID:d8b63aba1907145bea998dd612889d6b" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": true, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Controls/Authoring/ButtonTypeAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace UGUIDots.Controls.Authoring { 5 | 6 | public class ButtonTypeAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 7 | 8 | public ClickType Type = ClickType.ReleaseUp; 9 | 10 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 11 | dstManager.AddComponentData(entity, new ButtonClickType { Value = Type }); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Editor/UGUIDots.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Editor", 3 | "references": [ 4 | "GUID:fef50387be9e4be4ca3d64c31f370667", 5 | "GUID:d33a885a34af140b7ac6735751616c27" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Analyzers/UGUIDots.Analyzers.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Analyzers", 3 | "references": [ 4 | "GUID:2bafac87e7f4b9b418d9448d219b01ab", 5 | "GUID:6055be8ebefd69e48b49212b09b47b2f" 6 | ], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Core/Components/Render/OrthographicRenderPass.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Rendering; 2 | using UnityEngine.Rendering.Universal; 3 | 4 | namespace UGUIDots.Render { 5 | 6 | public class OrthographicRenderPass : ScriptableRenderPass { 7 | 8 | public CommandBuffer CommandBuffer; 9 | 10 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { 11 | if (CommandBuffer != null) { 12 | context.ExecuteCommandBuffer(CommandBuffer); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.initialprefabs.uguidots", 3 | "author": "Porrith Suong / initialPrefabs", 4 | "displayName": "UGUIDots", 5 | "version": "0.3.6", 6 | "unity": "2020.1", 7 | "description": "Low level library to augment Unity's UI and make it DOTS compliant", 8 | "dependencies" : { 9 | "com.unity.entities" : "0.14.0-preview.18", 10 | "com.unity.ugui" : "1.0.0", 11 | "com.unity.render-pipelines.universal": "9.0.0-preview.35", 12 | "com.unity.textmeshpro": "3.0.1", 13 | "com.unity.burst": "1.3.4" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Controls/Components/InputComponents.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Controls { 6 | 7 | /// 8 | /// Stores the primary mouse key code. 9 | /// 10 | public struct PrimaryMouseKeyCode : IComponentData { 11 | public KeyCode Value; 12 | 13 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 14 | public static PrimaryMouseKeyCode Default() { 15 | return new PrimaryMouseKeyCode { Value = KeyCode.Mouse0 }; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Components/Transforms/Stretch.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Transforms { 4 | 5 | [System.Flags] 6 | public enum StretchedState : byte { 7 | StretchXY = 1 >> 0 8 | 9 | // TODO: Support stretch along left, middle, right 10 | // TODO: Support stretch along top, middle, bottom 11 | } 12 | 13 | 14 | /// 15 | /// Represents that an element is stretched instead of anchored and scaled like the rest of the canvas system. 16 | /// 17 | public struct Stretch : IComponentData { 18 | public StretchedState Value; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Components/Render/RenderCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | 4 | namespace UGUIDots.Render { 5 | 6 | public class RenderCommand : IComponentData, IEquatable { 7 | 8 | public OrthographicRenderFeature RenderFeature; 9 | 10 | public bool Equals(RenderCommand other) { 11 | return other.RenderFeature == RenderFeature; 12 | } 13 | 14 | public override int GetHashCode() { 15 | var hash = 0; 16 | if (ReferenceEquals(RenderFeature, null)) hash ^= RenderFeature.GetHashCode(); 17 | return hash; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Collections.Tests/Collections.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Collections.Tests", 3 | "references": [ 4 | "UGUIDots.Collections", 5 | "UnityEngine.TestRunner", 6 | "UnityEditor.TestRunner" 7 | ], 8 | "includePlatforms": [ 9 | "Editor" 10 | ], 11 | "excludePlatforms": [], 12 | "allowUnsafeCode": false, 13 | "overrideReferences": true, 14 | "precompiledReferences": [ 15 | "nunit.framework.dll" 16 | ], 17 | "autoReferenced": false, 18 | "defineConstraints": [ 19 | "UNITY_INCLUDE_TESTS" 20 | ], 21 | "versionDefines": [], 22 | "noEngineReferences": false 23 | } -------------------------------------------------------------------------------- /Controls/Authoring/MobileInputAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace UGUIDots.Controls { 5 | 6 | public class MobileInputAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 7 | 8 | public int Capacity = 10; 9 | 10 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 11 | var buffer = dstManager.AddBuffer(entity); 12 | buffer.Capacity = Capacity; 13 | for (int i = 0; i < Capacity; i++) { 14 | buffer.Add(TouchElement.Default()); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Components/Render/ShaderIDConstants.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UGUIDots.Render { 4 | 5 | public static class ShaderIDConstants { 6 | public static readonly int MainTex = Shader.PropertyToID("_MainTex"); 7 | public static readonly int ColorMask = Shader.PropertyToID("_ColorMask"); 8 | public static readonly int Color = Shader.PropertyToID("_Color"); 9 | public static readonly int Fill = Shader.PropertyToID("_Fill"); 10 | public static readonly int FillType = Shader.PropertyToID("_FillType"); 11 | public static readonly int Translation = Shader.PropertyToID("_Translation"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Controls/Systems/UpdateGroup.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Controls { 4 | 5 | [UpdateInGroup(typeof(PresentationSystemGroup))] 6 | public class InputGroup : ComponentSystemGroup { } 7 | 8 | [UpdateInGroup(typeof(PresentationSystemGroup))] 9 | public class MessagingUpdateGroup : ComponentSystemGroup { } 10 | 11 | [UpdateInGroup(typeof(PresentationSystemGroup))] 12 | [UpdateAfter(typeof(MessagingUpdateGroup))] 13 | public class MessagingConsumptionGroup : ComponentSystemGroup { } 14 | 15 | [UpdateInGroup(typeof(PresentationSystemGroup))] 16 | [UpdateAfter(typeof(MessagingConsumptionGroup))] 17 | public class MessagingProductionGroup : ComponentSystemGroup { } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Components/Transforms/HierarchyUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Entities; 3 | using Unity.Transforms; 4 | 5 | namespace UGUIDots.Transforms { 6 | 7 | public static class HierarchyUtils { 8 | 9 | /// 10 | /// Returns the root entity based on the current child entity. 11 | /// 12 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 13 | public static Entity GetRoot(Entity child, ComponentDataFromEntity parents) { 14 | if (!parents.HasComponent(child)) { 15 | return child; 16 | } 17 | 18 | return GetRoot(parents[child].Value, parents); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Wiki/Home.md: -------------------------------------------------------------------------------- 1 | # Home 2 | 3 | Welcome to the UGUIDots Wiki. I'll be filling out more details as I continue working on this library 4 | over time. The purpose of this wiki is the provide a high level overview as well delve into finer 5 | tuned technical details that may be necessary for the developer using this. As such - this wiki should 6 | be kept up to date to help lower the barrier of entry for new developers. :) 7 | 8 | ## Table Of Contents 9 | * [Button](Button.md) 10 | * [Closing](Close.md) 11 | * [Canvas](Canvas.md) 12 | * [Conversions](Conversions.md) 13 | * [Image](Image.md) 14 | * [Materials](Material.md) 15 | * [Numerics](Numerics.md) 16 | * [Rendering](Rendering.md) 17 | * [Shaders](Shaders.md) 18 | * [Text](Text.md) 19 | -------------------------------------------------------------------------------- /Common.Tests/UGUIDots.Common.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Common.Tests", 3 | "references": [ 4 | "GUID:5f36bc0aeb435984fb19ecbd27b87a1f", 5 | "GUID:e0cd26848372d4e5c891c569017e11f1", 6 | "GUID:0acc523941302664db1f4e527237feb3", 7 | "GUID:27619889b8ba8c24980f49ee34dbb44a" 8 | ], 9 | "includePlatforms": [ 10 | "Editor" 11 | ], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": true, 14 | "overrideReferences": true, 15 | "precompiledReferences": [ 16 | "nunit.framework.dll" 17 | ], 18 | "autoReferenced": false, 19 | "defineConstraints": [ 20 | "UNITY_INCLUDE_TESTS" 21 | ], 22 | "versionDefines": [], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /Core.Tests/UGUIDots.Core.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Core.Tests", 3 | "references": [ 4 | "UGUIDots.Core", 5 | "Unity.Entities", 6 | "Unity.Entities.Hybrid", 7 | "Unity.Collections", 8 | "Unity.Mathematics", 9 | "Unity.Transforms", 10 | "UnityEngine.TestRunner", 11 | "UnityEditor.TestRunner" 12 | ], 13 | "includePlatforms": [], 14 | "excludePlatforms": [], 15 | "allowUnsafeCode": false, 16 | "overrideReferences": true, 17 | "precompiledReferences": [ 18 | "nunit.framework.dll" 19 | ], 20 | "autoReferenced": false, 21 | "defineConstraints": [ 22 | "UNITY_INCLUDE_TESTS" 23 | ], 24 | "versionDefines": [], 25 | "noEngineReferences": false 26 | } -------------------------------------------------------------------------------- /Core/Authoring/Render/RenderCommandAuthoring.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Render.Authoring { 6 | 7 | public class RenderCommandAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 8 | 9 | public OrthographicRenderFeature RenderFeature; 10 | 11 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 12 | if (ReferenceEquals(RenderFeature, null)) { 13 | throw new ArgumentException("The RenderFeature cannot be null!"); 14 | } 15 | 16 | dstManager.AddComponentData(entity, new RenderCommand { RenderFeature = RenderFeature }); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshTags.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Render { 4 | 5 | /// 6 | /// Indicates that UI Element needs to be rebuilt. 7 | /// 8 | public struct BuildUIElementTag : IComponentData { } 9 | 10 | /// 11 | /// Marks that only the color needs to be updated in the mesh 12 | /// 13 | public struct UpdateVertexColorTag : IComponentData { } 14 | 15 | /// 16 | /// Marks that an element is not rendering. 17 | /// 18 | public struct DisableRenderingTag : IComponentData { } 19 | 20 | /// 21 | /// Marks that the element should render. 22 | /// 23 | public struct EnableRenderingTag : IComponentData { } 24 | } 25 | -------------------------------------------------------------------------------- /Controls/UGUIDots.Controls.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Controls", 3 | "references": [ 4 | "GUID:d33a885a34af140b7ac6735751616c27", 5 | "GUID:2665a8d13d1b3f18800f46e256720795", 6 | "GUID:e0cd26848372d4e5c891c569017e11f1", 7 | "GUID:734d92eba21c94caba915361bd5ac177", 8 | "GUID:8819f35a0fc84499b990e90a4ca1911f", 9 | "GUID:d8b63aba1907145bea998dd612889d6b", 10 | "GUID:e04e6c86a9f3947eb95fded39f9e60cc", 11 | "GUID:a5baed0c9693541a5bd947d336ec7659" 12 | ], 13 | "includePlatforms": [], 14 | "excludePlatforms": [], 15 | "allowUnsafeCode": true, 16 | "overrideReferences": false, 17 | "precompiledReferences": [], 18 | "autoReferenced": true, 19 | "defineConstraints": [], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /Core/Systems/Render/CanvasMetadataDisposalSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Render.Systems { 4 | 5 | public class CanvasMetadataDisposalSystem : SystemBase { 6 | 7 | private EntityCommandBufferSystem commandBufferSystem; 8 | 9 | protected override void OnCreate() { 10 | commandBufferSystem = World.GetOrCreateSystem(); 11 | } 12 | 13 | protected override void OnUpdate() { 14 | var cmdBuffer = commandBufferSystem.CreateCommandBuffer(); 15 | 16 | Entities.WithNone().ForEach((Entity entity, ref ChildrenActiveMetadata c0) => { 17 | c0.Dispose(); 18 | 19 | cmdBuffer.RemoveComponent(entity); 20 | }).Run(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Core/Components/Render/OrthographicRenderFeature.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine.Rendering; 2 | using UnityEngine.Rendering.Universal; 3 | 4 | namespace UGUIDots.Render { 5 | 6 | public class OrthographicRenderFeature : ScriptableRendererFeature { 7 | 8 | private OrthographicRenderPass orthographic; 9 | 10 | public RenderPassEvent RenderPassEvent; 11 | 12 | public CommandBuffer CommandBuffer; 13 | 14 | public override void Create() { 15 | orthographic = new OrthographicRenderPass { 16 | CommandBuffer = CommandBuffer, 17 | renderPassEvent = RenderPassEvent 18 | }; 19 | } 20 | 21 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) { 22 | renderer.EnqueuePass(orthographic); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile/UGUIDots.Controls.Mobile.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Controls.Mobile", 3 | "references": [ 4 | "GUID:15b5cedb175ab42a5ab92bf9bb11f169", 5 | "GUID:d33a885a34af140b7ac6735751616c27", 6 | "GUID:734d92eba21c94caba915361bd5ac177", 7 | "GUID:8a2eafa29b15f444eb6d74f94a930e1d", 8 | "GUID:d8b63aba1907145bea998dd612889d6b", 9 | "GUID:e04e6c86a9f3947eb95fded39f9e60cc", 10 | "GUID:a5baed0c9693541a5bd947d336ec7659" 11 | ], 12 | "includePlatforms": [ 13 | "Android", 14 | "Editor", 15 | "iOS" 16 | ], 17 | "excludePlatforms": [], 18 | "allowUnsafeCode": true, 19 | "overrideReferences": false, 20 | "precompiledReferences": [], 21 | "autoReferenced": true, 22 | "defineConstraints": [], 23 | "versionDefines": [], 24 | "noEngineReferences": false 25 | } -------------------------------------------------------------------------------- /Collections.Tests/UnsafeArrayTests.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Collections.Unsafe; 2 | using NUnit.Framework; 3 | using Unity.Collections; 4 | 5 | namespace UGUIDots.Collections.Tests { 6 | 7 | public class UnsafeArrayTests { 8 | 9 | [Test] 10 | public void ValuesAreSet() { 11 | var values = new UnsafeArray(10, Allocator.Temp); 12 | Assert.AreEqual(true, values.IsCreated); 13 | Assert.AreEqual(10, values.Length); 14 | 15 | for (int i = 0; i < values.Length; i++) { 16 | values[i] = 10 - i; 17 | } 18 | 19 | for (int i = 0; i < values.Length; i++) { 20 | Assert.AreEqual(10 - i, values[i]); 21 | } 22 | 23 | values.Dispose(); 24 | 25 | Assert.AreEqual(false, values.IsCreated); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Controls.Tests/Controls.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Controls.Tests", 3 | "references": [ 4 | "UGUIDots.Core", 5 | "Core.Tests", 6 | "UGUIDots.Controls", 7 | "UGUIDots.Controls.Mobile", 8 | "UGUIDots.Controls.Standalone", 9 | "Unity.Entities", 10 | "Unity.Entities.Hybrid", 11 | "Unity.Mathematics", 12 | "Unity.Transforms", 13 | "UnityEngine.TestRunner", 14 | "UnityEditor.TestRunner" 15 | ], 16 | "includePlatforms": [ 17 | "Editor" 18 | ], 19 | "excludePlatforms": [], 20 | "allowUnsafeCode": true, 21 | "overrideReferences": true, 22 | "precompiledReferences": [ 23 | "nunit.framework.dll" 24 | ], 25 | "autoReferenced": false, 26 | "defineConstraints": [ 27 | "UNITY_INCLUDE_TESTS" 28 | ], 29 | "versionDefines": [], 30 | "noEngineReferences": false 31 | } -------------------------------------------------------------------------------- /Controls/Authoring/StandaloneInputAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Transforms; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Controls.Authoring { 6 | 7 | public class StandaloneInputAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 8 | 9 | public KeyCode PrimaryMouseKey = KeyCode.Mouse0; 10 | 11 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 12 | dstManager.AddComponentData(entity, new PrimaryMouseKeyCode { Value = PrimaryMouseKey }); 13 | 14 | dstManager.RemoveComponent(entity); 15 | dstManager.RemoveComponent(entity); 16 | dstManager.RemoveComponent(entity); 17 | dstManager.RemoveComponent(entity); 18 | dstManager.RemoveComponent(entity); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Components/Render/FillType.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Entities; 3 | 4 | namespace UGUIDots.Render { 5 | 6 | /// 7 | /// Fill types only support x/y axis based fills. Radial support will be coming 8 | /// in later. 9 | /// 10 | public enum FillType : int { 11 | RightToLeft = 0, 12 | LeftToRight = 1, 13 | BottomToTop = 2, 14 | TopToBottom = 3, 15 | } 16 | 17 | /// 18 | /// Stores a normalized value between 0 and 1 that shows how much of the image is filled. 19 | /// 20 | public struct FillAmount : IComponentData { 21 | public float Amount; 22 | public FillType Type; 23 | } 24 | 25 | public static class FillExtensions { 26 | 27 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 28 | public static int FillTypeAsInt(ref this FillAmount value) { 29 | return (int)value.Type; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Components/Render/TextureComponents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Render { 6 | 7 | [Serializable] 8 | public class SharedTexture : IComponentData, IEquatable { 9 | 10 | public Texture Value; 11 | 12 | public override bool Equals(object obj) { 13 | return Equals((SharedTexture)obj); 14 | } 15 | 16 | public bool Equals(SharedTexture other) { 17 | return other.Value == Value; 18 | } 19 | 20 | public override int GetHashCode() { 21 | var hash = 0; 22 | if (!ReferenceEquals(null, Value)) hash = Value.GetHashCode() ^ hash; 23 | return hash; 24 | } 25 | } 26 | 27 | /// 28 | /// Stpres the entity that is linked with a Texture. 29 | /// 30 | public struct LinkedTextureEntity : IComponentData { 31 | public Entity Value; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Controls/Systems/Standalone/UGUIDots.Controls.Standalone.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Controls.Standalone", 3 | "references": [ 4 | "GUID:734d92eba21c94caba915361bd5ac177", 5 | "GUID:d33a885a34af140b7ac6735751616c27", 6 | "GUID:15b5cedb175ab42a5ab92bf9bb11f169", 7 | "GUID:e0cd26848372d4e5c891c569017e11f1", 8 | "GUID:d8b63aba1907145bea998dd612889d6b", 9 | "GUID:e04e6c86a9f3947eb95fded39f9e60cc", 10 | "GUID:a5baed0c9693541a5bd947d336ec7659" 11 | ], 12 | "includePlatforms": [ 13 | "Editor", 14 | "LinuxStandalone64", 15 | "macOSStandalone", 16 | "WSA", 17 | "WebGL", 18 | "WindowsStandalone32", 19 | "WindowsStandalone64" 20 | ], 21 | "excludePlatforms": [], 22 | "allowUnsafeCode": false, 23 | "overrideReferences": false, 24 | "precompiledReferences": [], 25 | "autoReferenced": true, 26 | "defineConstraints": [], 27 | "versionDefines": [], 28 | "noEngineReferences": false 29 | } -------------------------------------------------------------------------------- /Core/UGUIDots.Core.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UGUIDots.Core", 3 | "references": [ 4 | "GUID:3430abf52b53b5c4ba9083ed24e0e54b", 5 | "GUID:2665a8d13d1b3f18800f46e256720795", 6 | "GUID:734d92eba21c94caba915361bd5ac177", 7 | "GUID:8819f35a0fc84499b990e90a4ca1911f", 8 | "GUID:e0cd26848372d4e5c891c569017e11f1", 9 | "GUID:8a2eafa29b15f444eb6d74f94a930e1d", 10 | "GUID:d8b63aba1907145bea998dd612889d6b", 11 | "GUID:df380645f10b7bc4b97d4f5eb6303d95", 12 | "GUID:15fc0a57446b3144c949da3e2b9737a9", 13 | "GUID:6055be8ebefd69e48b49212b09b47b2f", 14 | "GUID:a5baed0c9693541a5bd947d336ec7659", 15 | "GUID:2bafac87e7f4b9b418d9448d219b01ab" 16 | ], 17 | "includePlatforms": [], 18 | "excludePlatforms": [], 19 | "allowUnsafeCode": true, 20 | "overrideReferences": false, 21 | "precompiledReferences": [], 22 | "autoReferenced": true, 23 | "defineConstraints": [], 24 | "versionDefines": [], 25 | "noEngineReferences": false 26 | } -------------------------------------------------------------------------------- /Controls/Systems/Mobile/CopyTouchDataSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Controls.Systems { 6 | 7 | /// 8 | /// Copies data from the Input engine into a TouchElement buffer. 9 | /// 10 | [UpdateInGroup(typeof(InputGroup))] 11 | public class CopyTouchDataSystem : SystemBase { 12 | 13 | protected override void OnUpdate() { 14 | Entities.ForEach((DynamicBuffer b0) => { 15 | var touchBuffer = b0.AsNativeArray(); 16 | 17 | var size = math.min(Input.touchCount, touchBuffer.Length); 18 | 19 | for (int i = 0; i < size; i++) { 20 | touchBuffer[i] = Input.GetTouch(i); 21 | } 22 | 23 | for (int i = size; i < touchBuffer.Length; i++) { 24 | touchBuffer[i] = TouchElement.Default(); 25 | } 26 | }).WithoutBurst().Run(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright <2020> 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Wiki/Rendering.md: -------------------------------------------------------------------------------- 1 | # Rendering 2 | 3 | ## Orthographic Render Pass 4 | To support URP, a custom render pass has been built whose sole purpose is to do an orthographic projection. 5 | 6 | The limitation of the render pass is that, if you need faster rendering times, multiple GraphicsCommandBuffers 7 | are needed. Currently there is only _1_ and there is no API that allows multiple instances of a 8 | GraphicsCommandBuffer. 9 | 10 | ## OrthographicMeshRenderSystem 11 | By default - we retrieve the OrthographicRenderFeature via the `RenderCommandProxy`. We iterate through each Canvas, 12 | retrieve the attached mesh and push the mesh to the an InstructionQueue embedded into the `OrthographicRenderPass`. The 13 | `OrthographicRenderPass` ends up flushing the instruction queue and executes the context of the `GraphicsCommandBuffer` 14 | in orthographic view. This happens every render frame. 15 | 16 | ## Limitations 17 | Currently, there is no way to add multiple `GraphicsCommandBuffer` - as adding multiple command buffers would mean 18 | parallel context execution on the render side. 19 | -------------------------------------------------------------------------------- /Core/Systems/Render/AddMeshSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Render.Systems { 6 | 7 | [UpdateInGroup(typeof(InitializationSystemGroup))] 8 | public class AddMeshSystem : SystemBase { 9 | 10 | private EntityQuery canvasQuery; 11 | 12 | protected override void OnCreate() { 13 | canvasQuery = GetEntityQuery(new EntityQueryDesc { 14 | All = new [] { ComponentType.ReadOnly() }, 15 | None = new [] { ComponentType.ReadOnly() } 16 | }); 17 | 18 | RequireForUpdate(canvasQuery); 19 | } 20 | 21 | protected override void OnUpdate() { 22 | using (var entities = canvasQuery.ToEntityArray(Allocator.TempJob)) { 23 | foreach (var entity in entities) { 24 | EntityManager.AddComponentObject(entity, new Mesh()); 25 | EntityManager.RemoveComponent(entity); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Systems/Render/ReactiveSubgroupToggleSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Render.Systems { 4 | 5 | /// 6 | /// Removes the DisabledTag and actually marks the subgroup as disabled. 7 | /// 8 | [UpdateInGroup(typeof(PresentationSystemGroup))] 9 | public class ReactiveSubgroupToggleSystem : SystemBase { 10 | 11 | private EntityQuery disabledUpdatesQuery; 12 | private EntityCommandBufferSystem cmdBufferSystem; 13 | 14 | protected override void OnCreate() { 15 | cmdBufferSystem = World.GetOrCreateSystem(); 16 | } 17 | 18 | protected override void OnUpdate() { 19 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 20 | 21 | Dependency = Entities.WithAll().ForEach((Entity entity, int entityInQueryIndex) => { 22 | cmdBuffer.RemoveComponent(entityInQueryIndex, entity); 23 | }).ScheduleParallel(Dependency); 24 | 25 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Systems/Render/ResolutionDeltaRebuildSystem.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Transforms; 2 | using Unity.Entities; 3 | using Unity.Jobs; 4 | 5 | namespace UGUIDots.Render.Systems { 6 | 7 | [UpdateInGroup(typeof(UITransformUpdateGroup))] 8 | public class ResolutionDeltaRebuildSystem : SystemBase { 9 | 10 | private EntityCommandBufferSystem cmdBufferSystem; 11 | 12 | protected override void OnCreate() { 13 | cmdBufferSystem = World.GetOrCreateSystem(); 14 | RequireSingletonForUpdate(); 15 | } 16 | 17 | protected override void OnUpdate() { 18 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer(); 19 | 20 | Dependency = Entities.WithNone().ForEach((Entity entity, in SpriteData c0) => { 21 | cmdBuffer.AddComponent(entity, new BuildUIElementTag { }); 22 | }).Schedule(Dependency); 23 | 24 | Dependency = Entities.WithNone().ForEach((Entity entity, in DynamicBuffer b0) => { 25 | cmdBuffer.AddComponent(entity, new BuildUIElementTag { }); 26 | }).Schedule(Dependency); 27 | 28 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/ButtonConversionSystem.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Render; 2 | using Unity.Entities; 3 | using UnityEngine.UI; 4 | 5 | namespace UGUIDots.Conversions.Systems { 6 | 7 | [UpdateInGroup(typeof(GameObjectConversionGroup))] 8 | [UpdateAfter(typeof(ImageConversionSystem))] 9 | public class ButtonConversionSystem : GameObjectConversionSystem { 10 | protected override void OnUpdate() { 11 | Entities.ForEach((Button button) => { 12 | var entity = GetPrimaryEntity(button); 13 | 14 | var colorBlock = button.colors; 15 | DstEntityManager.AddComponentData(entity, ClickState.Default()); 16 | DstEntityManager.AddComponentData(entity, ButtonVisual.Default()); 17 | DstEntityManager.AddComponentData(entity, ColorStates.FromColorBlock(colorBlock)); 18 | 19 | if (!button.interactable) { 20 | DstEntityManager.AddComponentData(entity, new NonInteractableButtontag { }); 21 | DstEntityManager.SetComponentData(entity, new AppliedColor { Value = colorBlock.disabledColor }); 22 | } else { 23 | DstEntityManager.AddComponentData(entity, new AppliedColor { Value = colorBlock.normalColor }); 24 | } 25 | }); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Wiki/Conversions.md: -------------------------------------------------------------------------------- 1 | # Conversions 2 | 3 | If you're not familiar with the GameObject Conversion Pipeline in Unity's ECS architecture, it is a way to convert 4 | Unity's GameObjects to their Entities version. 5 | 6 | Typically there are a few ways to author conversions. 7 | 8 | ## IConvertGameObjectToEntity 9 | An interface implemented into a MonoBehaviour. Typically you override the following function: 10 | 11 | ``` 12 | Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { ... } 13 | ``` 14 | 15 | You can add component data and dynamic buffers within the function body. 16 | 17 | ## GameObjectConversionSystem 18 | `GameObjectConversionSystems` are specialized `ComponentSystems` to process converted GameObjects. UGUIDOTs utilizes 19 | `GameObjectConversonSystem` to convert the entire Canvas hierarchy into their entity version with the correct components. 20 | 21 | For more detailed instructons on the _entire_ conversion 5argon's blog about [conversion](https://gametorrahod.com/game-object-conversion-and-subscene/). 22 | 23 | Currently in UGUIDOTS: 24 | 25 | Conversion currently happen on the following UI components: 26 | 27 | * [Image](Image.md) 28 | * [Text (TextMeshPro UI)](Text.md) 29 | * [Button](Button.md) 30 | 31 | You can view each of their following links to view which components are added to the entity. 32 | -------------------------------------------------------------------------------- /Core/Systems/Transforms/StretchImageSystem.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Render; 2 | using Unity.Entities; 3 | using Unity.Jobs; 4 | using Unity.Mathematics; 5 | using Unity.Transforms; 6 | using UnityEngine; 7 | 8 | namespace UGUIDots.Transforms.Systems { 9 | 10 | [UpdateInGroup(typeof(UITransformUpdateGroup))] 11 | [UpdateAfter(typeof(AnchorSystem))] 12 | public class StretchDimensionsSystem : SystemBase { 13 | 14 | private EntityCommandBufferSystem cmdBufferSystem; 15 | 16 | protected override void OnCreate() { 17 | cmdBufferSystem = World.GetOrCreateSystem(); 18 | RequireSingletonForUpdate(); 19 | } 20 | 21 | protected override void OnUpdate() { 22 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 23 | var resolution = new float2(Screen.width, Screen.height); 24 | 25 | Dependency = Entities.ForEach((Entity entity, ref Dimensions c1, in LocalToWorld c0, in Stretch c2) => { 26 | var scale = c0.Scale().xy; 27 | c1 = new Dimensions { Value = (int2)(resolution / scale) }; 28 | cmdBuffer.AddComponent(entity.Index, entity); 29 | }).WithBurst().ScheduleParallel(Dependency); 30 | 31 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Components/Transforms/TransformExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Mathematics; 3 | using Unity.Transforms; 4 | 5 | namespace UGUIDots.Transforms { 6 | 7 | public static class TransformExtensions { 8 | 9 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 10 | public static float3 Scale(this LocalToWorld ltw) { 11 | var m = ltw.Value; 12 | return new float3(m.c0[0], m.c1[1], m.c2[2]) / m.c3[3]; 13 | } 14 | 15 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 16 | public static float AverageScale(this LocalToWorld ltw) { 17 | var scale = ltw.Scale(); 18 | return math.csum(scale) / 3; 19 | } 20 | 21 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 22 | public static float3 Scale(this LocalToParent ltp) { 23 | var m = ltp.Value; 24 | return new float3(m.c0[0], m.c1[1], m.c2[2]) / m.c3[3]; 25 | } 26 | 27 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 28 | public static float AverageScale(this LocalToParent ltp) { 29 | var scale = ltp.Scale(); 30 | return math.csum(scale) / 3; 31 | } 32 | 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public static quaternion LocalRotation(this LocalToParent ltp) { 35 | return new quaternion(ltp.Value); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/RectTransformConversionSystem.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Transforms; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Conversions.Systems { 6 | 7 | /// 8 | /// Converts all RectTransforms into its entities counterpart using LocalToWorld as its Matrix4x4 representation 9 | /// in ScreenSpace. 10 | /// 11 | [UpdateInGroup(typeof(GameObjectConversionGroup))] 12 | public class RectTransformConversionSystem : GameObjectConversionSystem { 13 | 14 | protected override void OnUpdate() { 15 | Entities.ForEach((RectTransform transform) => { 16 | var entity = GetPrimaryEntity(transform); 17 | 18 | var rectSize = transform.Int2Size(); 19 | DstEntityManager.AddComponentData(entity, new Dimensions { Value = rectSize }); 20 | 21 | // Add anchoring if the min max anchors are equal (e.g. one of the presets) 22 | if (transform.anchorMin == transform.anchorMax) { 23 | 24 | // Adding the anchors - which is taking the anchored position 25 | DstEntityManager.AddComponentData(entity, new Anchor { 26 | Distance = transform.anchoredPosition, 27 | State = transform.ToAnchor() 28 | }); 29 | } else { 30 | DstEntityManager.AddComponentData(entity, new Stretch { 31 | Value = StretchedState.StretchXY 32 | }); 33 | } 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Since UGUIDots is intended to be an open source repository, contributions are welcomed. 4 | 5 | ## Getting started 6 | 7 | * Make sure to have a Github account 8 | 9 | ## Reporting Bugs 10 | * Open up a pull request with details on how to reproduce the bug 11 | * Images and gifs are welcomed in reporting bugs as it provides visual context on how the bug is reproduced 12 | 13 | ## Contributing Code 14 | * Fork the repo 15 | * Use the master branch if there a pending bug that needs to be fixed 16 | * Checkout the develop branch if you want to add additional features 17 | * This branch represents the latest work that is currently in staging and somewhat stable 18 | * Push to your forked repository and submit a pull request from your fork to the primary repository 19 | * Submit the Pull Request to the `master` branch for bugs and bump up the patch version in the package.json 20 | * Include a summary of the changes in the `CHANGELOG.md` file 21 | * Submit the Pull Request to the `develop` branch` if you have a feature that you want to include and stage. 22 | * Ensure your git commits are easy to follow and read 23 | * Follow the general C# MSDN Conventions when contributing code 24 | 25 | ## Pull Request Process 26 | * Include a summary of the general changes to your pull request 27 | * Include your preferred display name/handle (this will be included in the Credits section of the README). 28 | 29 | Eventually, the pull request will be accepted and merged in. 30 | 31 | ## Feedback 32 | 33 | * Feel free to open up any issue in the issue tracker if you have comments on the process and how it can be improved. 34 | -------------------------------------------------------------------------------- /Core/Components/CanvasComponents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Burst; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using Unity.Entities; 5 | using Unity.Jobs; 6 | using Unity.Mathematics; 7 | 8 | namespace UGUIDots { 9 | 10 | /// 11 | /// Stores data about each child's active state in an unsafe hash map. 12 | /// 13 | public struct ChildrenActiveMetadata : ISystemStateComponentData, IDisposable { 14 | public UnsafeHashMap Value; 15 | 16 | public void Dispose() { 17 | Value.Dispose(); 18 | } 19 | 20 | [BurstDiscard] 21 | public void Dispose(JobHandle jobDeps) { 22 | Value.Dispose(jobDeps); 23 | } 24 | } 25 | 26 | /// 27 | /// If the canvas is set to the ScaleWithScreenSize, then this component should be attached to the Canvas component. 28 | /// 29 | public struct ReferenceResolution : IComponentData { 30 | public float2 Value; 31 | } 32 | 33 | /// 34 | /// The weight of whether the scaled canvas should try to match the width of the current window or its height. 35 | /// 36 | public struct WidthHeightRatio : IComponentData { 37 | public float Value; 38 | } 39 | 40 | /// 41 | /// Marks the Canvas root entity to rebuild its current mesh based on the vertex/index buffer. 42 | /// 43 | public struct BuildCanvasTag : IComponentData { } 44 | 45 | /// 46 | /// Marks the vertex/index buffers need to be copied into the mesh. 47 | /// 48 | public struct BatchCanvasTag : IComponentData { } 49 | } 50 | -------------------------------------------------------------------------------- /Common/NumericUtils.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Mathematics; 3 | 4 | namespace UGUIDots.Common { 5 | 6 | public unsafe static class NumericUtils { 7 | 8 | /// 9 | /// Fills a character array pointer with the unicode equivalent of each digit. 10 | /// 11 | /// The character buffer to store into 12 | /// The size of the buffer 13 | /// The total number of counted digits 14 | public static void ToCharArray(this int value, char* ptr, in int length, out int count) { 15 | var offset = value < 0 ? 0 : -1; 16 | 17 | value = math.abs(value); 18 | var stack = new NativeList(Allocator.Temp); 19 | do { 20 | var mod = value % 10; 21 | value /= 10; 22 | 23 | // Convert to the unicode numerical equivalent, the last digit should go into the last value 24 | stack.Add((char)(mod + 48)); 25 | } while (value != 0); 26 | 27 | for (int i = 0; i < stack.Length; i++) { 28 | var flipped = stack.Length + offset - i; 29 | 30 | if (flipped < length) { 31 | ptr[flipped] = stack[i]; 32 | } 33 | } 34 | 35 | count = stack.Length; 36 | 37 | if (offset >= 0) { 38 | ptr[0] = '-'; 39 | count++; 40 | } 41 | 42 | stack.Dispose(); 43 | } 44 | 45 | // TODO: Figure out how to count the number of digits in a floating point #. 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Components/Render/BatchedMesh.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | 4 | namespace UGUIDots.Render { 5 | 6 | /// 7 | /// Used to describe the submesh's index buffer and vertex buffer params. 8 | /// 9 | public struct SubmeshSliceElement : IBufferElementData { 10 | public int2 VertexSpan; 11 | public int2 IndexSpan; 12 | } 13 | 14 | /// 15 | /// Stores the key and material keys required to render. A value of -1 indicates that the material or texture is 16 | /// not used explicitly. 17 | /// 18 | public struct SubmeshKeyElement : IBufferElementData { 19 | public Entity TextureEntity; 20 | public Entity MaterialEntity; 21 | } 22 | 23 | /// 24 | /// Stores which slice of the vertices and indices that the particular element owns. 25 | /// 26 | public struct MeshDataSpan : IComponentData { 27 | public int2 VertexSpan; 28 | public int2 IndexSpan; 29 | } 30 | 31 | /// 32 | /// Stores entities that need to be rendered as a buffer element. 33 | /// 34 | public struct RenderElement : IBufferElementData { 35 | public Entity Value; 36 | } 37 | 38 | /// 39 | /// Stores the start index of the first entity in the batch, and the number of elements in the batch. 40 | /// 41 | public struct BatchedSpanElement : IBufferElementData { 42 | public int2 Value; 43 | 44 | public static implicit operator BatchedSpanElement(int2 value) => new BatchedSpanElement { Value = value }; 45 | public static implicit operator int2(BatchedSpanElement value) => value.Value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Systems/Render/OrthographicRenderSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Jobs; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | namespace UGUIDots.Render.Systems { 7 | 8 | [UpdateInGroup(typeof(MeshRenderGroup))] 9 | public class OrthographicRenderSystem : SystemBase { 10 | 11 | private CommandBuffer cmd; 12 | 13 | protected override void OnDestroy() { 14 | CommandBufferPool.Release(cmd); 15 | } 16 | 17 | protected override void OnStartRunning() { 18 | Entities.ForEach((RenderCommand c0) => { 19 | cmd = CommandBufferPool.Get(c0.RenderFeature.name); 20 | c0.RenderFeature.CommandBuffer = cmd; 21 | }).WithoutBurst().Run(); 22 | } 23 | 24 | protected unsafe override void OnUpdate() { 25 | cmd.Clear(); 26 | cmd.SetViewProjectionMatrices( 27 | Matrix4x4.Ortho(0, Screen.width, 0, Screen.height, -100f, 100f), 28 | Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one)); 29 | 30 | Entities.ForEach((Mesh mesh, MaterialPropertyBatch batch, DynamicBuffer keys) => { 31 | var submeshKeys = keys.AsNativeArray(); 32 | for (int i = 0; i < mesh.subMeshCount && mesh.subMeshCount == submeshKeys.Length; i++) { 33 | var materialKey = submeshKeys[i].MaterialEntity; 34 | var prop = batch.Value[i]; 35 | var mat = EntityManager.GetComponentData(materialKey).Value; 36 | 37 | cmd.DrawMesh(mesh, Matrix4x4.identity, mat, i, -1, prop); 38 | } 39 | }).WithoutBurst().Run(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Materials/DefaultImage.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: DefaultImage 11 | m_Shader: {fileID: 4800000, guid: 2d2c9acbbe318614684bfdc4c256d8b0, type: 3} 12 | m_ShaderKeywords: _CLIPPING _FILL _TOGGLE_FILL 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _MainTex: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | m_Floats: 27 | - _Clipping: 1 28 | - _ColorMask: 15 29 | - _Cutoff: 0.2 30 | - _DstBlend: 10 31 | - _Fill: 1 32 | - _FillType: 1 33 | - _SrcBlend: 5 34 | - _Stencil: 0 35 | - _StencilComp: 0 36 | - _StencilOp: 0 37 | - _StencilReadMask: 255 38 | - _StencilWriteMask: 255 39 | - _ToggleFill: 1 40 | - _ZWrite: 0 41 | m_Colors: 42 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 43 | - _Translation: {r: 0, g: 0, b: 0, a: 1} 44 | - _UVBound: {r: 0, g: 0, b: 1, a: 1} 45 | m_BuildTextureStacks: [] 46 | --- !u!114 &3428952135668497213 47 | MonoBehaviour: 48 | m_ObjectHideFlags: 11 49 | m_CorrespondingSourceObject: {fileID: 0} 50 | m_PrefabInstance: {fileID: 0} 51 | m_PrefabAsset: {fileID: 0} 52 | m_GameObject: {fileID: 0} 53 | m_Enabled: 1 54 | m_EditorHideFlags: 0 55 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 56 | m_Name: 57 | m_EditorClassIdentifier: 58 | version: 2 59 | -------------------------------------------------------------------------------- /Core/Systems/Render/MaterialPropertySystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Render.Systems { 4 | 5 | [UpdateInGroup(typeof(ResetMaterialGroup))] 6 | public class ResetMaterialPropertySystem : SystemBase { 7 | protected override void OnUpdate() { 8 | Entities.ForEach((MaterialPropertyBatch c0) => { 9 | for (int i = 0; i < c0.Value.Length; i++) { 10 | c0.Value[i].Clear(); 11 | } 12 | }).WithoutBurst().Run(); 13 | } 14 | } 15 | 16 | [UpdateInGroup(typeof(UpdateMaterialGroup))] 17 | public class UpdateTextureMaterialPropertySystem : SystemBase { 18 | protected override void OnUpdate() { 19 | 20 | var linkedTextures = GetComponentDataFromEntity(true); 21 | 22 | Entities.ForEach((MaterialPropertyBatch c0, DynamicBuffer b0, 23 | DynamicBuffer b1) => { 24 | 25 | var spans = b1.AsNativeArray(); 26 | var renderEntities = b0.AsNativeArray(); 27 | 28 | for (int i = 0; i < spans.Length; i++) { 29 | var entityIndex = spans[i].Value.x; 30 | var renderEntity = renderEntities[entityIndex].Value; 31 | 32 | if (linkedTextures.HasComponent(renderEntity)) { 33 | var textureEntity = linkedTextures[renderEntity].Value; 34 | var texture = EntityManager.GetComponentData(textureEntity); 35 | 36 | c0.Value[i].SetTexture(ShaderIDConstants.MainTex, texture.Value); 37 | } 38 | } 39 | }).WithoutBurst().Run(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Prefabs/Default URP Pipeline.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 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: bf2edee5c58d82540a51f03df9d42094, type: 3} 13 | m_Name: Default URP Pipeline 14 | m_EditorClassIdentifier: 15 | k_AssetVersion: 5 16 | k_AssetPreviousVersion: 5 17 | m_RendererType: 1 18 | m_RendererData: {fileID: 0} 19 | m_RendererDataList: 20 | - {fileID: 11400000, guid: e338f2be5c0c93840adc956486c9f34c, type: 2} 21 | m_DefaultRendererIndex: 0 22 | m_RequireDepthTexture: 0 23 | m_RequireOpaqueTexture: 0 24 | m_OpaqueDownsampling: 1 25 | m_SupportsTerrainHoles: 1 26 | m_SupportsHDR: 0 27 | m_MSAA: 1 28 | m_RenderScale: 1 29 | m_MainLightRenderingMode: 1 30 | m_MainLightShadowsSupported: 1 31 | m_MainLightShadowmapResolution: 2048 32 | m_AdditionalLightsRenderingMode: 1 33 | m_AdditionalLightsPerObjectLimit: 4 34 | m_AdditionalLightShadowsSupported: 0 35 | m_AdditionalLightsShadowmapResolution: 512 36 | m_ShadowDistance: 50 37 | m_ShadowCascades: 0 38 | m_Cascade2Split: 0.25 39 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467} 40 | m_ShadowDepthBias: 1 41 | m_ShadowNormalBias: 1 42 | m_SoftShadowsSupported: 0 43 | m_UseSRPBatcher: 1 44 | m_SupportsDynamicBatching: 0 45 | m_MixedLightingSupported: 1 46 | m_DebugLevel: 0 47 | m_UseAdaptivePerformance: 1 48 | m_ColorGradingMode: 0 49 | m_ColorGradingLutSize: 32 50 | m_ShadowType: 1 51 | m_LocalShadowsSupported: 0 52 | m_LocalShadowsAtlasResolution: 256 53 | m_MaxPixelLights: 0 54 | m_ShadowAtlasResolution: 256 55 | m_ShaderVariantLogLevel: 0 56 | -------------------------------------------------------------------------------- /Core/Components/ButtonComponents.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Entities; 3 | 4 | namespace UGUIDots { 5 | 6 | public enum ButtonVisualState : byte { 7 | None = 0, 8 | Hover = 1 << 0, 9 | Pressed = 1 << 1, 10 | } 11 | 12 | /// 13 | /// Stores if the button has a cursor on top of it, or if the cursor has been pressed 14 | /// 15 | public struct ClickState : IComponentData { 16 | public bool Value; 17 | 18 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 19 | public static ClickState Default() => new ClickState { Value = false }; 20 | } 21 | 22 | /// 23 | /// Stores the visual state of the button. 24 | /// 25 | public struct ButtonVisual : IComponentData { 26 | public ButtonVisualState Value; 27 | 28 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 29 | public static ButtonVisual Default() => new ButtonVisual { Value = ButtonVisualState.None }; 30 | } 31 | 32 | /// 33 | /// Marks an entity to have a message archetype. 34 | /// 35 | public struct ButtonMessageRequest : IComponentData { } 36 | 37 | /// 38 | /// Marks that a button is non interactable. 39 | /// 40 | public struct NonInteractableButtontag : IComponentData { } 41 | 42 | /// 43 | /// The button is strictly a close button type. 44 | /// 45 | public struct CloseButtonType : IComponentData { } 46 | 47 | /// 48 | /// The button is strictly a show button type. 49 | /// 50 | public struct ShowButtonType : IComponentData { } 51 | 52 | /// 53 | /// The button is strictly a toggle button type. 54 | /// 55 | public struct ToggleButtonType : IComponentData { } 56 | } 57 | -------------------------------------------------------------------------------- /Core.Tests/TestFixture.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using Unity.Entities; 3 | using Unity.Entities.CodeGeneratedJobForEach; 4 | 5 | namespace UGUIDots { 6 | 7 | public abstract class TestFixture { 8 | 9 | public class EntityForEachSystem : ComponentSystem { 10 | 11 | public new EntityQueryBuilder Entities => base.Entities; 12 | 13 | protected override void OnUpdate() { } 14 | } 15 | 16 | protected EntityForEachSystem System { 17 | get { 18 | return World.DefaultGameObjectInjectionWorld.GetOrCreateSystem(); 19 | } 20 | } 21 | 22 | protected EntityQueryBuilder Entities { 23 | get { 24 | return System.Entities; 25 | } 26 | } 27 | 28 | protected World previousWorld; 29 | protected World world; 30 | protected EntityManager manager; 31 | protected EntityManager.EntityManagerDebug managerDebug; 32 | 33 | [SetUp] 34 | public virtual void SetUp() { 35 | previousWorld = World.DefaultGameObjectInjectionWorld; 36 | world = World.DefaultGameObjectInjectionWorld = new World("Test World"); 37 | 38 | manager = world.EntityManager; 39 | managerDebug = new EntityManager.EntityManagerDebug(manager); 40 | } 41 | 42 | [TearDown] 43 | public virtual void TearDown() { 44 | if (manager != default && world.IsCreated) { 45 | while (world.Systems.Count > 0) { 46 | world.DestroySystem(world.Systems[0]); 47 | } 48 | 49 | managerDebug.CheckInternalConsistency(); 50 | 51 | world.Dispose(); 52 | world = null; 53 | 54 | World.DefaultGameObjectInjectionWorld = previousWorld; 55 | previousWorld = null; 56 | manager = default; 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Common.Tests/NumericUtilsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace UGUIDots.Common.Tests { 4 | 5 | public unsafe class NumericUtilTests { 6 | 7 | [Test] 8 | public void CharEqualsPositiveDigit() { 9 | int value = 1234567890; 10 | 11 | char* actual = stackalloc char[10]; 12 | 13 | value.ToCharArray(actual, 10, out int count); 14 | 15 | string expected = value.ToString(); 16 | 17 | for (int i = 0; i < count; i++) { 18 | Assert.AreEqual(expected[i], actual[i], "Mismatched digits"); 19 | } 20 | } 21 | 22 | [Test] 23 | public void CharEqualsPositiveDigitWithExcess() { 24 | int value = 12345; 25 | 26 | char* actual = stackalloc char[15]; 27 | value.ToCharArray(actual, 15, out int count); 28 | string exepected = value.ToString(); 29 | 30 | for (int i = 0; i < count; i++) { 31 | 32 | Assert.AreEqual(exepected[i], actual[i], "Mismatched digits"); 33 | } 34 | } 35 | 36 | [Test] 37 | public void CharEqualsNegativeDigits() { 38 | int value = -12345; 39 | 40 | char* actual = stackalloc char[6]; 41 | value.ToCharArray(actual, 6, out int count); 42 | string expected = value.ToString(); 43 | 44 | for (int i = 0; i < count; i++) { 45 | Assert.AreEqual(expected[i], actual[i], "Mismatch digits"); 46 | } 47 | } 48 | 49 | [Test] 50 | public void CharEqualsNegativeDigitsWIthExcess() { 51 | int value = -1234569; 52 | 53 | char* actual = stackalloc char[15]; 54 | value.ToCharArray(actual, 15, out int count); 55 | string expected = value.ToString(); 56 | 57 | for (int i = 0; i < count; i++) { 58 | Assert.AreEqual(expected[i], actual[i], "Mismatch digits"); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Controls/Authoring/CloseButtonAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace UGUIDots.Controls.Authoring { 5 | 6 | public enum ButtonVisibilityType { 7 | Close, 8 | Show, 9 | Toggle 10 | } 11 | 12 | public class CloseButtonAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 13 | 14 | public ButtonVisibilityType Type = ButtonVisibilityType.Toggle; 15 | public GameObject[] Targets; 16 | 17 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 18 | #if UNITY_EDITOR 19 | if (Targets.Length == 0) { 20 | throw new System.InvalidOperationException("Cannot send a message to a GameObject that is null!"); 21 | } 22 | #endif 23 | 24 | // Create the message which will try to close something 25 | var msg = dstManager.CreateEntity(); 26 | 27 | switch (Type) { 28 | case ButtonVisibilityType.Toggle: 29 | dstManager.AddComponentData(msg, new ToggleButtonType { }); 30 | break; 31 | case ButtonVisibilityType.Show: 32 | dstManager.AddComponentData(msg, new ShowButtonType { }); 33 | break; 34 | case ButtonVisibilityType.Close: 35 | dstManager.AddComponentData(msg, new CloseButtonType { }); 36 | break; 37 | default: 38 | break; 39 | } 40 | 41 | var buffer = dstManager.AddBuffer(msg); 42 | 43 | foreach (var target in Targets) { 44 | buffer.Add(new CloseTarget { Value = conversionSystem.GetPrimaryEntity(target) }); 45 | } 46 | 47 | dstManager.AddComponentData(entity, new ButtonMessageFramePayload { Value = msg }); 48 | 49 | #if UNITY_EDITOR 50 | dstManager.SetName(msg, "Close Target Msg"); 51 | #endif 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Prefabs/Default URP Pipeline_Renderer.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} 13 | m_Name: Default URP Pipeline_Renderer 14 | m_EditorClassIdentifier: 15 | m_RendererFeatures: 16 | - {fileID: 5773635822035489810} 17 | m_RendererFeatureMap: 1254e5aa30132050 18 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} 19 | shaders: 20 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} 21 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} 22 | screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, 23 | type: 3} 24 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} 25 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} 26 | m_OpaqueLayerMask: 27 | serializedVersion: 2 28 | m_Bits: 4294967295 29 | m_TransparentLayerMask: 30 | serializedVersion: 2 31 | m_Bits: 4294967295 32 | m_DefaultStencilState: 33 | overrideStencilState: 0 34 | stencilReference: 0 35 | stencilCompareFunction: 8 36 | passOperation: 0 37 | failOperation: 0 38 | zFailOperation: 0 39 | m_ShadowTransparentReceive: 1 40 | --- !u!114 &5773635822035489810 41 | MonoBehaviour: 42 | m_ObjectHideFlags: 0 43 | m_CorrespondingSourceObject: {fileID: 0} 44 | m_PrefabInstance: {fileID: 0} 45 | m_PrefabAsset: {fileID: 0} 46 | m_GameObject: {fileID: 0} 47 | m_Enabled: 1 48 | m_EditorHideFlags: 0 49 | m_Script: {fileID: 11500000, guid: ac620f9bc3a53f2478bc078f9d7082bd, type: 3} 50 | m_Name: UGUIDOTS 51 | m_EditorClassIdentifier: 52 | m_Active: 1 53 | RenderPassEvent: 600 54 | -------------------------------------------------------------------------------- /Controls/Components/ButtonControlComponents.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | 6 | namespace UGUIDots.Controls { 7 | 8 | /// 9 | /// The entity which is targetted to be disabled. 10 | /// 11 | public struct CloseTarget : IBufferElementData { 12 | public Entity Value; 13 | } 14 | 15 | /// 16 | /// The type of the button behaviour. 17 | /// 18 | public enum ClickType : byte { 19 | PressDown = 1 << 0, 20 | ReleaseUp = 1 << 1, 21 | Held = 1 << 2 22 | } 23 | 24 | /// 25 | /// Registers how a button is clicked 26 | /// 27 | public struct ButtonClickType : IComponentData { 28 | public ClickType Value; 29 | } 30 | 31 | /// 32 | /// Stores the entity that needs to be produced and consumed on the next frame. 33 | /// 34 | public struct ButtonMessageFramePayload : IComponentData { 35 | public Entity Value; 36 | } 37 | 38 | /// 39 | /// Stores the touch state element recorded by Unity. 40 | /// 41 | public struct TouchElement : IBufferElementData { 42 | public TouchPhase Phase; 43 | public float2 Position; 44 | public short TapCount; 45 | 46 | public static implicit operator TouchElement(Touch value) { 47 | return new TouchElement { 48 | Phase = value.phase, 49 | Position = value.position, 50 | TapCount = (short)value.tapCount 51 | }; 52 | } 53 | 54 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 55 | public static TouchElement Default() { 56 | return new TouchElement { 57 | Phase = TouchPhase.Canceled, 58 | Position = new float2(float.PositiveInfinity, float.PositiveInfinity), 59 | TapCount = -1 60 | }; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Controls/Systems/Messaging/ButtonMessageSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots.Controls.Messaging.Systems { 4 | 5 | // TODO: Rename the accompanying file 6 | [UpdateInGroup(typeof(MessagingConsumptionGroup))] 7 | public class ButtonMessageConsumerSystem : SystemBase { 8 | 9 | private EntityCommandBufferSystem cmdBufferSystem; 10 | 11 | protected override void OnCreate() { 12 | cmdBufferSystem = World.GetOrCreateSystem(); 13 | } 14 | 15 | protected override void OnUpdate() { 16 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 17 | 18 | Dependency = Entities.ForEach((Entity entity, in ButtonMessageRequest c0) => { 19 | cmdBuffer.DestroyEntity(entity.Index, entity); 20 | }).WithBurst().Schedule(Dependency); 21 | 22 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 23 | } 24 | } 25 | 26 | [UpdateInGroup(typeof(MessagingProductionGroup))] 27 | public class ButtonMessageProducerSystem : SystemBase { 28 | 29 | private EntityCommandBufferSystem cmdBufferSystem; 30 | 31 | protected override void OnCreate() { 32 | cmdBufferSystem = World.GetOrCreateSystem(); 33 | } 34 | 35 | protected override void OnUpdate() { 36 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 37 | Dependency = Entities.ForEach((Entity entity, in ClickState c0, in ButtonMessageFramePayload c1) => { 38 | if (c0.Value) { 39 | var msgEntity = cmdBuffer.Instantiate(entity.Index, c1.Value); 40 | cmdBuffer.AddComponent(entity.Index, msgEntity); 41 | } 42 | }).ScheduleParallel(Dependency); 43 | 44 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Systems/UpdateGroup.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace UGUIDots { 4 | 5 | /** 6 | * Update material property blocks 7 | * ResetMaterialGroup 8 | * UpdateMaterialGroup 9 | * 10 | * Update all transforms: 11 | * UITransformUpdateGroup 12 | * UITransformConsumerGroup 13 | * UITransformProducerGroup 14 | * 15 | * Update mesh properties 16 | * MeshUpdateGroup 17 | * MeshBuildGroup 18 | * MeshBatchGroup 19 | * MeshRenderGroup 20 | */ 21 | 22 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(UITransformProducerGroup))] 23 | public class MeshUpdateGroup : ComponentSystemGroup { } 24 | 25 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(MeshUpdateGroup))] 26 | public class MeshBuildGroup : ComponentSystemGroup { } 27 | 28 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(MeshBuildGroup))] 29 | public class MeshBatchGroup : ComponentSystemGroup { } 30 | 31 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(MeshBatchGroup))] 32 | public class MeshRenderGroup : ComponentSystemGroup { } 33 | 34 | // Logic based group 35 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(UpdateMaterialGroup))] 36 | public class UITransformUpdateGroup : ComponentSystemGroup { } 37 | 38 | // Consumer based group 39 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(UITransformUpdateGroup))] 40 | public class UITransformConsumerGroup : ComponentSystemGroup { } 41 | 42 | // Producer based group 43 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(UITransformConsumerGroup))] 44 | public class UITransformProducerGroup : ComponentSystemGroup { } 45 | 46 | [UpdateInGroup(typeof(PresentationSystemGroup))] 47 | public class ResetMaterialGroup : ComponentSystemGroup { } 48 | 49 | [UpdateInGroup(typeof(PresentationSystemGroup)), UpdateAfter(typeof(ResetMaterialGroup))] 50 | public class UpdateMaterialGroup : ComponentSystemGroup { } 51 | } 52 | -------------------------------------------------------------------------------- /Wiki/Numerics.md: -------------------------------------------------------------------------------- 1 | # Numerics 2 | 3 | To help make converting numerical numbers into their character array counter part, a new module is introduced called 4 | `NumericUtils`. 5 | 6 | Currently the only support are integers. Floating point will eventually be supported. 7 | 8 | ## How to use 9 | 10 | To convert an integer to its character array counterpart, call the `ToCharArray(...)` extension function on a positive 11 | or negative integer value. 12 | 13 | You can use the `stackalloc` keyword to temporarily create a buffer of characters onto the stack. For those unfamiliar 14 | with using the `stackalloc` keyword and its uses this will be a brief explanation. 15 | 16 | Memory either lives in the stack, which is memory that follows a last in first out policy. This is temporary memory and 17 | is only scoped to its function call, so when a function needs to allocate a new integer it does so on the stack. 18 | While the function call will allocate a block of memory on top of the stack to execute, the moment its execution is 19 | finished, the allocated memory is released until it is used again. 20 | 21 | The heap is memory set aside for dynamic allocation. You can allocate a block of memory at any time and it generally 22 | does not follow the same structure as the stack. Heap memory is usually allocated at the start of the application, 23 | its runtime, and is released when the process exits. 24 | 25 | `stackalloc` allows us to explicitly allocated a pointer on top of the stack and is released when the function leaves 26 | its scope. 27 | 28 | Here is a good [article](https://vcsjones.dev/2020/02/24/stackalloc/) about the dos and don'ts of using `stackalloc`. 29 | 30 | ### Example 31 | ```cs 32 | unsafe { 33 | // For positive values 34 | int value = 12345; 35 | 36 | char* positive = stackalloc char[5]; 37 | value.ToCharArray(positive, 5, out int count); // This will fill the ptr with a max length of 5 38 | 39 | // For negative values 40 | 41 | value = -12345; 42 | char* negative = stackalloc char[6]; // We need 6 characters for the minus - character 43 | value.ToCharArray(negative, 6, out int count); 44 | } 45 | ``` 46 | -------------------------------------------------------------------------------- /Editor/BatchedMeshAuthoringEditor.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Analyzers; 2 | using UGUIDots.Render.Authoring; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using UnityEngine.Assertions; 6 | 7 | namespace UGUIDots.EditorTools { 8 | 9 | [CustomEditor(typeof(BatchedMeshAuthoring))] 10 | public class BatchedMeshAuthoringEditor : Editor { 11 | 12 | private SerializedProperty batchProperty; 13 | private BatchedMeshAuthoring batcher; 14 | 15 | private void OnEnable() { 16 | batchProperty = serializedObject.FindProperty("Batches"); 17 | batcher = target as BatchedMeshAuthoring; 18 | } 19 | 20 | public override void OnInspectorGUI() { 21 | base.OnInspectorGUI(); 22 | 23 | DrawBatchLabel(); 24 | DrawBatchButton(); 25 | } 26 | 27 | private void DrawBatchLabel() { 28 | var batches = batcher.Batches; 29 | EditorGUILayout.LabelField($"There are currently {(batches != null ? batches.Length : 0)} batch(es)."); 30 | } 31 | 32 | private void DrawBatchButton() { 33 | if (GUILayout.Button("Build Batch")) { 34 | serializedObject.Update(); 35 | 36 | var canvas = batcher.GetComponent(); 37 | Assert.IsNull(canvas.transform.parent, "Building a batch must only be done on the root gameObject!"); 38 | var collection = BatchAnalysis.BuildStaticBatch(canvas); 39 | 40 | batchProperty.arraySize = collection.Count; 41 | 42 | for (int i = 0; i < batchProperty.arraySize; i++) { 43 | var internalArray = batchProperty.GetArrayElementAtIndex(i).FindPropertyRelative("Elements"); 44 | internalArray.arraySize = collection[i].Count; 45 | 46 | for (int k = 0; k < collection[i].Count; k++) { 47 | internalArray.GetArrayElementAtIndex(k).objectReferenceValue = collection[i][k]; 48 | } 49 | } 50 | serializedObject.ApplyModifiedProperties(); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/Components/Render/MaterialComponents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Render { 6 | 7 | // TODO: Turn this into a managed component data instead to avoid unnecessary chunk splitting 8 | [Serializable] 9 | public class SharedMaterial : IComponentData, IEquatable { 10 | public Material Value; 11 | 12 | public override bool Equals(object obj) { 13 | return Equals((SharedMaterial)obj); 14 | } 15 | 16 | public override int GetHashCode() { 17 | return !ReferenceEquals(null, Value) ? Value.GetHashCode() : 0; 18 | } 19 | 20 | public bool Equals(SharedMaterial other) { 21 | return other.Value == Value; 22 | } 23 | } 24 | 25 | /// 26 | /// Stores the index of the material property that the rendered element needs to update. 27 | /// 28 | public struct MaterialPropertyIndex : IComponentData { 29 | public ushort Value; 30 | 31 | public static implicit operator ushort(MaterialPropertyIndex value) => value.Value; 32 | public static implicit operator MaterialPropertyIndex(ushort value) => new MaterialPropertyIndex { 33 | Value = value 34 | }; 35 | } 36 | 37 | /// 38 | /// Stores a collection of material property blocks which is batched to a single entity. 39 | /// 40 | public class MaterialPropertyBatch : IComponentData, IEquatable { 41 | public MaterialPropertyBlock[] Value; 42 | 43 | public override bool Equals(object obj) { 44 | return Equals((MaterialPropertyBatch)obj); 45 | } 46 | 47 | public bool Equals(MaterialPropertyBatch other) { 48 | return other.Value == Value; 49 | } 50 | 51 | public override int GetHashCode() { 52 | return Value != null ? Value.GetHashCode() : 0; 53 | } 54 | } 55 | 56 | /// 57 | /// Stores the associative entity that is representative of the material. 58 | /// 59 | public struct LinkedMaterialEntity : IComponentData { 60 | public Entity Value; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/Systems/Render/ButtonColorStateSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Jobs; 3 | using UnityEngine; 4 | 5 | namespace UGUIDots.Render.Systems { 6 | 7 | [UpdateInGroup(typeof(MeshUpdateGroup))] 8 | public class ButtonColorStateSystem : SystemBase { 9 | 10 | private EntityCommandBufferSystem cmdBufferSystem; 11 | 12 | protected override void OnCreate() { 13 | cmdBufferSystem = World.GetOrCreateSystem(); 14 | } 15 | 16 | protected override void OnUpdate() { 17 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 18 | 19 | Dependency = Entities.WithNone(). 20 | ForEach((Entity entity, int entityInQueryIndex, in AppliedColor c0, in ColorStates c1, in ButtonVisual c3) => { 21 | 22 | bool delta = true; 23 | Color32 color = default; 24 | var currentColor = c0.Value.ToNormalizedFloat4(); 25 | 26 | switch (c3.Value) { 27 | case var _ when ButtonVisualState.Hover == c3.Value && 28 | !currentColor.Equals(c1.HighlightedColor.ToNormalizedFloat4()): 29 | color = c1.HighlightedColor; 30 | break; 31 | 32 | case var _ when ButtonVisualState.Pressed == c3.Value && 33 | !currentColor.Equals(c1.PressedColor.ToNormalizedFloat4()): 34 | color = c1.PressedColor; 35 | break; 36 | 37 | case var _ when ButtonVisualState.None == c3.Value && 38 | !currentColor.Equals(c1.DefaultColor.ToNormalizedFloat4()): 39 | color = c1.DefaultColor; 40 | break; 41 | 42 | default: 43 | delta = false; 44 | break; 45 | } 46 | 47 | if (delta) { 48 | cmdBuffer.SetComponent(entityInQueryIndex, entity, new AppliedColor { Value = color }); 49 | cmdBuffer.AddComponent(entityInQueryIndex, entity); 50 | } 51 | }).WithBurst().ScheduleParallel(Dependency); 52 | 53 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Controls/Systems/Standalone/StandaloneMouseCollisionSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Entities; 3 | using Unity.Jobs; 4 | using Unity.Mathematics; 5 | using Unity.Transforms; 6 | using UnityEngine; 7 | 8 | namespace UGUIDots.Controls.Systems { 9 | 10 | [UpdateInGroup(typeof(InputGroup))] 11 | public class StandaloneMouseCollisionSystem : SystemBase { 12 | 13 | private struct MouseInfo { 14 | public float3 Position; 15 | public bool2 Pressed; 16 | } 17 | 18 | protected override void OnCreate() { 19 | RequireSingletonForUpdate(); 20 | } 21 | 22 | protected override void OnUpdate() { 23 | var keycode = GetSingleton().Value; 24 | var mousePos = Input.mousePosition; 25 | var clickDown = Input.GetKeyDown(keycode); 26 | var clickUp = Input.GetKeyUp(keycode); 27 | var clickHeld = Input.GetKey(keycode); 28 | 29 | var mouse = new MouseInfo { 30 | Position = mousePos, 31 | Pressed = new bool2(clickDown, clickUp) 32 | }; 33 | 34 | Entities.WithNone().ForEach((ref ClickState c0, ref ButtonVisual c1, 35 | in Dimensions c2, in LocalToWorld c3, in ButtonClickType c4) => { 36 | 37 | var aabb = new AABB { 38 | Center = c3.Position, 39 | Extents = new float3(c2.Extents(), c3.Position.z) 40 | }; 41 | 42 | if (aabb.Contains(mouse.Position)) { 43 | switch (c4.Value) { 44 | case ClickType.PressDown: 45 | c0.Value = clickDown; 46 | break; 47 | case ClickType.ReleaseUp: 48 | c0.Value = clickUp; 49 | break; 50 | case ClickType.Held: 51 | c0.Value = clickHeld; 52 | break; 53 | default: 54 | break; 55 | } 56 | 57 | c1.Value = clickHeld ? ButtonVisualState.Pressed : ButtonVisualState.Hover; 58 | } else { 59 | c1.Value = ButtonVisualState.None; 60 | } 61 | }).Run(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Shaders/DefaultImage.shader: -------------------------------------------------------------------------------- 1 | Shader "UGUIDOTS/Unlit/DefaultImage" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex("Texture", 2D) = "white" {} 6 | _BaseColor("Color", color) = (1.0, 1.0, 1.0, 1.0) 7 | _Translation("Translation", Vector) = (0.0, 0.0, 0.0) 8 | 9 | [Toggle(_FILL)] _ToggleFill ("Fill?", Float) = 1 10 | _Fill("Fill", Range(0, 1)) = 1 11 | [Enum(UGUIDots.Render.FillType)] _FillType ("Fill Type", Float) = 0 12 | 13 | /* 14 | * Stencil Operation should follow this: https://docs.unity3d.com/ScriptReference/Rendering.StencilOp.html 15 | * Stencil Compare should follow this: https://docs.unity3d.com/ScriptReference/Rendering.CompareFunction.html 16 | */ 17 | [IntRange] _StencilComp ("Stencil Comparison", Range(0, 7)) = 0 18 | [IntRange] _Stencil ("Stencil Ref", Range(0, 255)) = 0 19 | [IntRange] _StencilOp ("Stencil Operation", Range(0, 7)) = 0 20 | [IntRange] _StencilWriteMask ("Stencil Write Mask", Range(0, 255)) = 255 21 | [IntRange] _StencilReadMask ("Stencil Read Mask", Range(0, 255)) = 255 22 | _ColorMask ("Color Mask", Float) = 15 23 | 24 | [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Src Blend", Float) = 1 25 | [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Dst Blend", Float) = 0 26 | [Enum(Off, 0, On, 1)] _ZWrite ("Z Write", Float) = 1 27 | } 28 | 29 | SubShader 30 | { 31 | Tags 32 | { 33 | "Queue"="Transparent" 34 | "IgnoreProjector"="True" 35 | "RenderType"="Transparent" 36 | "PreviewType"="Plane" 37 | "CanUseSpriteAtlas"="True" 38 | } 39 | 40 | Stencil 41 | { 42 | Ref [_Stencil] 43 | Comp [_StencilComp] 44 | Pass [_StencilOp] 45 | ReadMask [_StencilReadMask] 46 | WriteMask [_StencilWriteMask] 47 | } 48 | 49 | Pass 50 | { 51 | Blend [_SrcBlend] [_DstBlend] 52 | ZWrite [_ZWrite] 53 | ZTest [unity_GUIZTestMode] 54 | ColorMask [_ColorMask] 55 | 56 | HLSLPROGRAM 57 | #pragma shader_feature _FILL 58 | #pragma multi_compile_instancing 59 | #pragma vertex UnlitPassVertex 60 | #pragma fragment UnlitPassFragment 61 | #include "DefaultImage.hlsl" 62 | ENDHLSL 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Analyzers/BatchAnalysis.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TMPro; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | using UnityEngine.Assertions; 6 | 7 | namespace UGUIDots.Analyzers { 8 | 9 | public static class BatchAnalysis { 10 | 11 | public static List> BuildStaticBatch(Canvas root) { 12 | Assert.IsNull(root.transform.parent, $"The current Canvas: {root.name} is not a root canvas!"); 13 | var batchMap = new Dictionary>(); 14 | RecurseChildrenBatch(root.transform, batchMap); 15 | 16 | var collection = new List>(); 17 | foreach (var batch in batchMap.Values) { 18 | collection.Add(batch); 19 | } 20 | return collection; 21 | } 22 | 23 | private static void RecurseChildrenBatch(Transform parent, Dictionary> batchMap) { 24 | if (parent.childCount <= 0) { 25 | return; 26 | } 27 | 28 | for (int i = 0; i < parent.childCount; i++) { 29 | var child = parent.GetChild(i); 30 | 31 | if (child.TryGetComponent(out Image img)) { 32 | var texture = img.sprite != null ? img.sprite.texture : (Texture)Texture2D.whiteTexture; 33 | var material = img.material != null ? img.material : Canvas.GetDefaultCanvasMaterial(); 34 | var hash = texture.GetHashCode() ^ material.GetHashCode(); 35 | 36 | if (!batchMap.TryGetValue(hash, out var collection)) { 37 | collection = new List(); 38 | batchMap.Add(hash, collection); 39 | } 40 | collection.Add(child.gameObject); 41 | } 42 | 43 | if (child.TryGetComponent(out TextMeshProUGUI text)) { 44 | var hash = text.materialForRendering != null ? text.materialForRendering.GetHashCode() : 0; 45 | 46 | if (!batchMap.TryGetValue(hash, out var collection)) { 47 | collection = new List(); 48 | batchMap.Add(hash, collection); 49 | } 50 | collection.Add(text.gameObject); 51 | } 52 | 53 | RecurseChildrenBatch(child, batchMap); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Wiki/Images/uguidots-logo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e59a7b80c4f7d004ea361f43a78eb9e4 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | maxTextureSizeSet: 0 59 | compressionQualitySet: 0 60 | textureFormatSet: 0 61 | ignorePngGamma: 0 62 | applyGammaDecoding: 0 63 | platformSettings: 64 | - serializedVersion: 3 65 | buildTarget: DefaultTexturePlatform 66 | maxTextureSize: 2048 67 | resizeAlgorithm: 0 68 | textureFormat: -1 69 | textureCompression: 1 70 | compressionQuality: 50 71 | crunchedCompression: 0 72 | allowsAlphaSplitting: 0 73 | overridden: 0 74 | androidETC2FallbackOverride: 0 75 | forceMaximumCompressionQuality_BC6H_BC7: 0 76 | spriteSheet: 77 | serializedVersion: 2 78 | sprites: [] 79 | outline: [] 80 | physicsShape: [] 81 | bones: [] 82 | spriteID: 83 | internalID: 0 84 | vertices: [] 85 | indices: 86 | edges: [] 87 | weights: [] 88 | secondaryTextures: [] 89 | spritePackingTag: 90 | pSDRemoveMatte: 0 91 | pSDShowRemoveMatteOption: 0 92 | userData: 93 | assetBundleName: 94 | assetBundleVariant: 95 | -------------------------------------------------------------------------------- /Wiki/Images/batched-mesh-authoring.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cc6e295897feb242bc2800ac99f5c5c 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | vTOnly: 0 27 | grayScaleToAlpha: 0 28 | generateCubemap: 6 29 | cubemapConvolution: 0 30 | seamlessCubemap: 0 31 | textureFormat: 1 32 | maxTextureSize: 2048 33 | textureSettings: 34 | serializedVersion: 2 35 | filterMode: -1 36 | aniso: -1 37 | mipBias: -100 38 | wrapU: -1 39 | wrapV: -1 40 | wrapW: -1 41 | nPOTScale: 1 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 0 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spritePixelsToUnits: 100 50 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 51 | spriteGenerateFallbackPhysicsShape: 1 52 | alphaUsage: 1 53 | alphaIsTransparency: 0 54 | spriteTessellationDetail: -1 55 | textureType: 0 56 | textureShape: 1 57 | singleChannelComponent: 0 58 | maxTextureSizeSet: 0 59 | compressionQualitySet: 0 60 | textureFormatSet: 0 61 | ignorePngGamma: 0 62 | applyGammaDecoding: 0 63 | platformSettings: 64 | - serializedVersion: 3 65 | buildTarget: DefaultTexturePlatform 66 | maxTextureSize: 2048 67 | resizeAlgorithm: 0 68 | textureFormat: -1 69 | textureCompression: 1 70 | compressionQuality: 50 71 | crunchedCompression: 0 72 | allowsAlphaSplitting: 0 73 | overridden: 0 74 | androidETC2FallbackOverride: 0 75 | forceMaximumCompressionQuality_BC6H_BC7: 0 76 | spriteSheet: 77 | serializedVersion: 2 78 | sprites: [] 79 | outline: [] 80 | physicsShape: [] 81 | bones: [] 82 | spriteID: 83 | internalID: 0 84 | vertices: [] 85 | indices: 86 | edges: [] 87 | weights: [] 88 | secondaryTextures: [] 89 | spritePackingTag: 90 | pSDRemoveMatte: 0 91 | pSDShowRemoveMatteOption: 0 92 | userData: 93 | assetBundleName: 94 | assetBundleVariant: 95 | -------------------------------------------------------------------------------- /Wiki/Shaders.md: -------------------------------------------------------------------------------- 1 | # Shaders 2 | 3 | UGUIDOTS provides specialized materials and that are compatible to URP to handle _Translation_ and _FillAmount_. 4 | 5 | ## Default UI Material 6 | 7 | The `Default UI Material` works with Universal Render Pipeline, but has limitations in that the transformation matrix 8 | has to be updated in the mesh exclusively. 9 | 10 | If a UI element has to move, instead of exclusively just updating the transformation matrix, we can copy the translation 11 | to the shader instead. 12 | 13 | ## Material Property Index 14 | 15 | All images and text elements have a `MaterialPropertyIndex` component which allows the element to access the index 16 | of the `MaterialPropertyBatch` in the root canvas. 17 | 18 | By accessing the index, you are able to retrieve the associated material property and manipulate any properties. 19 | 20 | ## DefaultImage Material 21 | The `DefaultImage` material is very similar to the DefaultUI material, except that it allows for translation and fill. 22 | 23 | The `UIPingPongSystem` and `HeartFillSystem` in the [UGUIDots.Samples](https://github.com/InitialPrefabs/UGUIDots.Samples) 24 | provides an example of updating the translation and fill property. 25 | 26 | * For translation, simply pass a Vector4 to the Translation property. The translation is added in the Vertex pass in 27 | local space and the matrix is converted in world space when rendering. 28 | * For fill, ensure that the shader supports fill amount and pass a float to the FillAmount property. 29 | 30 | ***All properties that are supported can be found in the `ShaderConstants` static class.*** 31 | 32 | ## Limitations 33 | 34 | ### Canvas Rebuilds 35 | * If you have a continuously moving element in your UI and you schedule a Canvas rebuild - original transformation is not 36 | properly resetted. This creates a very odd offset effect. 37 | 38 | ### Batching 39 | Each material property is associated with a collection of elements. 40 | 41 | Imagine a canvas with 3 batches. There is _only_ 1 material property per batch, as a batch is a collective representation 42 | of the same properties. 43 | 44 | * Canvas 45 | * A -> Material Property A 46 | * B -> Material Property B 47 | * C -> Material Property C 48 | 49 | If you need to update UI Elements individually that are in the same batch, currently, the only recommended way is to 50 | separate the elements from the batch. Currently the `HeartFillSystem` does this if you inspect the # of batches in the 51 | Fill Canvas in the sample. 52 | 53 | > I understand that this is a cumbersome workflow. I will likely introduce a much more comprehensive analysis window in 54 | the future to handle this situation better. 55 | -------------------------------------------------------------------------------- /Shaders/DefaultImage.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef UGUIDOTS_UNLIT_TRANSLATION 2 | #define UGUIDOTS_UNLIT_TRANSLATION 3 | 4 | #include "Common.hlsl" 5 | 6 | TEXTURE2D(_MainTex); 7 | SAMPLER(sampler_MainTex); 8 | 9 | UNITY_INSTANCING_BUFFER_START(UnityPerMaterial) 10 | UNITY_DEFINE_INSTANCED_PROP(float, _Fill) 11 | UNITY_DEFINE_INSTANCED_PROP(float, _FillType) 12 | UNITY_DEFINE_INSTANCED_PROP(float4, _Translation) 13 | UNITY_DEFINE_INSTANCED_PROP(float4, _MainTex_ST) 14 | UNITY_DEFINE_INSTANCED_PROP(float4, _BaseColor) 15 | UNITY_INSTANCING_BUFFER_END(UnityPerMaterial) 16 | 17 | struct Attributes 18 | { 19 | float3 positionOS: POSITION; 20 | float4 color: COLOR; 21 | float2 baseUV: TEXCOORD0; 22 | 23 | UNITY_VERTEX_INPUT_INSTANCE_ID 24 | }; 25 | 26 | struct Varyings 27 | { 28 | float4 positionCS: SV_POSITION; 29 | float4 color: COLOR; 30 | float2 baseUV: VAR_BASE_UV; 31 | 32 | UNITY_VERTEX_INPUT_INSTANCE_ID 33 | }; 34 | 35 | Varyings UnlitPassVertex(Attributes input) 36 | { 37 | Varyings output; 38 | UNITY_SETUP_INSTANCE_ID(input); 39 | UNITY_TRANSFER_INSTANCE_ID(input, output); 40 | float3 positionWS = TransformObjectToWorld(input.positionOS + UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial, _Translation).xyz); 41 | output.positionCS = TransformWorldToHClip(positionWS); 42 | 43 | float4 baseST = UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial, _MainTex_ST); 44 | output.baseUV = input.baseUV * baseST.xy + baseST.zw; 45 | output.color = input.color; 46 | 47 | return output; 48 | } 49 | 50 | float4 UnlitPassFragment(Varyings input) : SV_TARGET 51 | { 52 | UNITY_SETUP_INSTANCE_ID(input); 53 | float4 baseMap = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.baseUV); 54 | float4 baseColor = UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial, _BaseColor); 55 | float4 base = baseMap * input.color; 56 | 57 | #if defined (_FILL) 58 | float fill = 1 - UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial, _Fill); 59 | float type = UNITY_ACCESS_INSTANCED_PROP(UnityPerMaterial, _FillType); 60 | 61 | float increment; 62 | 63 | if (type == 0) 64 | { 65 | increment = step(input.baseUV.x, fill * baseMap.x); 66 | } 67 | 68 | if (type == 1) 69 | { 70 | increment = step(1 - fill * baseMap.x, input.baseUV.x); 71 | } 72 | 73 | if (type == 2) 74 | { 75 | increment = step(input.baseUV.y, fill * baseMap.y); 76 | } 77 | 78 | if (type == 3) 79 | { 80 | increment = step(1 - fill * baseMap.y, input.baseUV.y); 81 | } 82 | 83 | clip(base.a - increment - 0.1); 84 | #endif 85 | 86 | return base; 87 | } 88 | 89 | #endif -------------------------------------------------------------------------------- /Core/Components/Transforms/FontExtensions.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using UnityEngine; 3 | using UnityEngine.TextCore; 4 | 5 | namespace UGUIDots { 6 | 7 | /// 8 | /// Convenient extensions as getters. 9 | /// 10 | public static class FontExtensions { 11 | public static float BearingY(this in CharacterInfo info, in float baseline) { 12 | return info.maxY - baseline; 13 | } 14 | 15 | public static float BearingX(this in CharacterInfo info) { 16 | return info.minX; 17 | } 18 | 19 | public static float Height(this in CharacterInfo info) { 20 | return info.glyphHeight; 21 | } 22 | 23 | public static float Width(this in CharacterInfo info) { 24 | return info.glyphWidth; 25 | } 26 | 27 | public static float2 Min(this in CharacterInfo info) { 28 | return new float2(info.minX, info.minY); 29 | } 30 | 31 | public static float2 Max(this in CharacterInfo info) { 32 | return new float2(info.maxX, info.maxY); 33 | } 34 | 35 | public static int Advance(this in CharacterInfo info) { 36 | return info.advance; 37 | } 38 | 39 | public static FontFaceInfo ToFontFaceInfo(this in FaceInfo info, float2 normalStyle, float2 boldStyle, 40 | int2 atlasSize) { 41 | 42 | return new FontFaceInfo { 43 | AscentLine = info.ascentLine, 44 | BaseLine = info.baseline, 45 | CapLine = info.capLine, 46 | DescentLine = info.descentLine, 47 | FamilyName = info.familyName, 48 | MeanLine = info.meanLine, 49 | PointSize = info.pointSize, 50 | Scale = info.scale, 51 | StrikeThroughThickness = info.strikethroughThickness, 52 | StrikeThroughOffset = info.strikethroughThickness, 53 | SubscriptSize = info.subscriptSize, 54 | SubscriptOffset = info.subscriptOffset, 55 | SuperscriptSize = info.superscriptSize, 56 | SuperscriptOffset = info.superscriptOffset, 57 | TabWidth = info.tabWidth, 58 | UnderlineOffset = info.underlineOffset, 59 | LineHeight = info.lineHeight, 60 | NormalStyle = normalStyle, 61 | BoldStyle = boldStyle, 62 | AtlasSize = atlasSize 63 | }; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/VisualAssetsConversionSystem.cs: -------------------------------------------------------------------------------- 1 | using TMPro; 2 | using UGUIDots.Render; 3 | using Unity.Entities; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | namespace UGUIDots.Conversions.Systems { 8 | 9 | [UpdateInGroup(typeof(GameObjectDeclareReferencedObjectsGroup))] 10 | public class VisualAssetsDeclarationSystem : GameObjectConversionSystem { 11 | protected override void OnUpdate() { 12 | Entities.ForEach((Image img) => { 13 | var mat = img.material != null ? img.material : 14 | Canvas.GetDefaultCanvasMaterial(); 15 | 16 | DeclareReferencedAsset(mat); 17 | 18 | var texture = img.sprite != null ? img.sprite.texture : Texture2D.whiteTexture; 19 | DeclareReferencedAsset(texture); 20 | 21 | }); 22 | 23 | Entities.ForEach((TextMeshProUGUI text) => { 24 | var mat = text.materialForRendering != null ? text.materialForRendering : 25 | Canvas.GetDefaultCanvasMaterial(); 26 | 27 | DeclareReferencedAsset(mat); 28 | }); 29 | } 30 | } 31 | 32 | [UpdateInGroup(typeof(GameObjectConversionGroup))] 33 | public class VisualAssetsConversionSystem : GameObjectConversionSystem { 34 | protected override void OnUpdate() { 35 | Entities.ForEach((Image img) => { 36 | CreateTextureEntity(img); 37 | CreateMaterialEntity(img); 38 | }); 39 | 40 | Entities.ForEach((TextMeshProUGUI text) => { 41 | CreateMaterialEntity(text); 42 | }); 43 | } 44 | 45 | private void CreateTextureEntity(Image img) { 46 | var texture = img.sprite != null ? img.sprite.texture : Texture2D.whiteTexture; 47 | 48 | var linkedTexture = GetPrimaryEntity(texture); 49 | 50 | DstEntityManager.AddComponentData(linkedTexture, new SharedTexture { Value = texture }); 51 | } 52 | 53 | private void CreateMaterialEntity(Image img) { 54 | var mat = img.material != null ? img.material : Canvas.GetDefaultCanvasMaterial(); 55 | var linkedMaterial = GetPrimaryEntity(mat); 56 | 57 | DstEntityManager.AddComponentData(linkedMaterial, new SharedMaterial { Value = mat }); 58 | } 59 | 60 | private void CreateMaterialEntity(TextMeshProUGUI text) { 61 | var mat = text.materialForRendering != null ? text.materialForRendering : 62 | Canvas.GetDefaultCanvasMaterial(); 63 | 64 | var linkedMaterial = GetPrimaryEntity(mat); 65 | DstEntityManager.AddComponentData(linkedMaterial, new SharedMaterial { Value = mat }); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Core/Systems/Render/BuildCanvasMeshSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Jobs; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | namespace UGUIDots.Render.Systems { 7 | 8 | [UpdateInGroup(typeof(MeshBatchGroup)), UpdateAfter(typeof(BatchCanvasVertexSystem))] 9 | public class BuildCanvasMeshSystem : SystemBase { 10 | 11 | private EntityQuery canvasMeshQuery; 12 | private EntityCommandBufferSystem commandBufferSystem; 13 | 14 | protected override void OnCreate() { 15 | canvasMeshQuery = GetEntityQuery(new EntityQueryDesc { 16 | All = new [] { 17 | ComponentType.ReadOnly(), ComponentType.ReadOnly(), 18 | ComponentType.ReadOnly(), ComponentType.ReadOnly() 19 | } 20 | }); 21 | 22 | commandBufferSystem = World.GetOrCreateSystem(); 23 | RequireForUpdate(canvasMeshQuery); 24 | } 25 | 26 | protected override void OnUpdate() { 27 | var cmdBuffer = commandBufferSystem.CreateCommandBuffer(); 28 | 29 | Entities.WithStoreEntityQueryInField(ref canvasMeshQuery).WithoutBurst().ForEach(( 30 | Entity entity, 31 | Mesh mesh, 32 | DynamicBuffer vertices, 33 | DynamicBuffer indices, 34 | DynamicBuffer submeshDesc) => { 35 | 36 | mesh.Clear(); 37 | mesh.SetVertexBufferParams(vertices.Length, MeshVertexDataExtensions.VertexDescriptors); 38 | mesh.SetVertexBufferData(vertices.AsNativeArray(), 0, 0, vertices.Length); 39 | mesh.SetIndexBufferParams(indices.Length, IndexFormat.UInt16); 40 | mesh.SetIndexBufferData(indices.AsNativeArray(), 0, 0, indices.Length); 41 | 42 | mesh.subMeshCount = submeshDesc.Length; 43 | 44 | for (int i = 0; i < submeshDesc.Length; i++) { 45 | var current = submeshDesc[i]; 46 | 47 | mesh.SetSubMesh(i, new SubMeshDescriptor { 48 | bounds = default, 49 | indexStart = current.IndexSpan.x, 50 | indexCount = current.IndexSpan.y, 51 | firstVertex = current.VertexSpan.x, 52 | vertexCount = current.VertexSpan.y, 53 | topology = MeshTopology.Triangles, 54 | }); 55 | } 56 | 57 | mesh.UploadMeshData(false); 58 | cmdBuffer.RemoveComponent(entity); 59 | }).Run(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Controls/Systems/Mobile/MobileMouseCollisionSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | using Unity.Entities; 3 | using Unity.Transforms; 4 | using UnityEngine; 5 | 6 | namespace UGUIDots.Controls.Systems { 7 | 8 | [UpdateInGroup(typeof(InputGroup))] 9 | public unsafe class MobileMouseCollisionSystem : SystemBase { 10 | 11 | protected unsafe override void OnUpdate() { 12 | 13 | var touches = stackalloc TouchElement[1]; 14 | var size = stackalloc int[1]; 15 | 16 | Entities.ForEach((DynamicBuffer b0) => { 17 | touches = (TouchElement*)b0.GetUnsafePtr(); 18 | size[0] = b0.Length; 19 | }).WithNativeDisableUnsafePtrRestriction(touches).WithNativeDisableUnsafePtrRestriction(size).Run(); 20 | 21 | Entities.WithNativeDisableUnsafePtrRestriction(touches).WithNativeDisableUnsafePtrRestriction(size). 22 | WithNone(). 23 | ForEach((ref ClickState c0, ref ButtonVisual c1, in Dimensions c2, in LocalToWorld c3, in ButtonClickType c4) => { 24 | var aabb = new AABB { 25 | Center = c3.Position, 26 | Extents = new float3(c2.Extents(), c3.Position.z) 27 | }; 28 | 29 | for (int i = 0; i < size[0]; i++) { 30 | var touch = touches[i]; 31 | if (aabb.Contains(new float3(touches[i].Position, c3.Position.z))) { 32 | switch (c4.Value) { 33 | case var _ when ClickType.PressDown == c4.Value && touch.Phase == TouchPhase.Began: 34 | c0.Value = true; 35 | break; 36 | case var _ when ClickType.ReleaseUp == c4.Value && touch.Phase == TouchPhase.Ended: 37 | c0.Value = true; 38 | break; 39 | case var _ when ClickType.Held == c4.Value && touch.Phase == TouchPhase.Began || 40 | (touch.Phase & (TouchPhase.Moved | TouchPhase.Stationary)) > 0: 41 | c0.Value = true; 42 | break; 43 | default: 44 | c0.Value = false; 45 | break; 46 | } 47 | 48 | var onTop = touch.Phase == TouchPhase.Began || 49 | (touch.Phase & (TouchPhase.Stationary | TouchPhase.Moved)) > 0; 50 | 51 | c1.Value = onTop ? ButtonVisualState.Pressed : ButtonVisualState.Hover; 52 | break; 53 | } else { 54 | c0.Value = false; 55 | c1.Value = ButtonVisualState.None; 56 | } 57 | } 58 | }).Run(); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Wiki/Image.md: -------------------------------------------------------------------------------- 1 | # Image 2 | 3 | Images designed and developed in Unity's current UI workflow are generally supported. Currently the only image 4 | type supported are Image components that have a fill type of ***Simple***. More will be supported on an on need 5 | basis. 6 | 7 | ## Conversion Pipeline 8 | Images are converted through the `ImageConversionSystem` where the following components are attached to the 9 | entity generated by the conversion system: 10 | 11 | | Component | Description | 12 | |:---------:|:------------| 13 | | LinkedMaterialEntity | The entity which has a Material component object attached and linked to the image entity | 14 | | LinkedTextureEntity | The entity which has a Texture2D component object attached and linked to the image entity | 15 | | AppliedColor | The current color of the Image | 16 | | Dimensions | The size of the image on the canvas - i.e. the rect | 17 | | DefaultSpriteResolution | The original resolution of the sprite (see below for more details) | 18 | | SpriteData | Information of the sprite containing UVs and padding | 19 | | MeshVertexData | Vertex information required by a mesh | 20 | | TriangleIndexElement | Indices needed to generate the mesh | 21 | | MeshDataSpan | Stores the slice of vertex and index spans of the submesh that the image belongs to | 22 | | BuildUIElementTag | Optionally added if you want to update the root mesh's data | 23 | | UpdateVertexColorTag | Optionally added if the color of the mesh needs to change, but the structure remains persistent. | 24 | | MaterialPropertyIndex | The material property that the image will access when rendering. | 25 | 26 | ## Limitations 27 | Currently only ImageTypes that are `Simple` work. Support for `Sliced` sprites are coming. 28 | 29 | ## DefaultSpriteResolution 30 | This stores the original resolution of the sprite. Meaning that if you had a 100x100 sprite, but your 31 | Image component is 200x200, we want to store the default resolution so we can reason about the scale 32 | of the displayed texture (in our case 2x). The scale computed is required to adjust the resultant 33 | calculation for any kind of padding our sprite needs from the `SpriteData`. This ensures that there is 34 | no stretching and the representation in Editor time is equivalent to runtime. 35 | 36 | ### Storing Mesh Data 37 | The `LocalVertexDataElement` and `LocalTriangleIndexElement` buffers contain the core data needed to build a 38 | mesh. Images are effectively quads and the `BuildImageVertexDataSystem` takes care of that for you, 39 | calculating the padding and using the canvas scale to dynamically , to compute the mesh vertices needed to display. 40 | 41 | ## Associating Textures to "Texture" Entities 42 | Textures are stored on their own entities as a `ComponentObject`. These entities are linked to associated Image entities 43 | via the `VisualAssetConversionSystem` and declared in the `VisualAssetDeclarationSystem`. 44 | 45 | An image without a Texture uses the default Texture2D.whiteTexture, which is a single pixel that is white. 46 | -------------------------------------------------------------------------------- /Wiki/Text.md: -------------------------------------------------------------------------------- 1 | # Text 2 | 3 | Currently only TextMeshPro is supported, because they have a generated font atlas and it is easier to figure out 4 | how to scale the text to match its point size. Default UGUI Text components are not supported due to its reliance 5 | of the FontEngine and needing to sample on runtime the actual point sizes. 6 | 7 | ## Conversion Pipeline 8 | TextMeshProUGUIs are converted in several stages - as there are external components needed to render text. 9 | 10 | * FontAssetDelcarationSystem 11 | * FontAssetConversionSystem 12 | * TMPTextConverionSystem 13 | 14 | ## FontAssetDeclarationSystem 15 | The `FontAssetDeclarationSystem` declares that the TMP FontAsset's ScriptableObject 16 | dependency that all `TextMeshProUGUI` components needs to be represented as an entity. 17 | 18 | ## FontAssetConversionSystem 19 | This system, grabs all of the embedded FontAssets from `TextMeshProUGUI` and adds the 20 | following components to the FontAsset entity. 21 | 22 | | Component | Description | 23 | |:---------:|:-----------:| 24 | | FontID | Stores the unique instance ID for font asset - this is used for look up | 25 | | GlyphElement | Stores the character's associated unicode, glyph metrics, raw uvs needed to display the font | 26 | | FontFaceInfo | Stores Unity's FaceInfo data from the FontAsset | 27 | 28 | ## TMPTextConversionSystem 29 | Grabs all `TextMeshProUGUI`s and adds the following components to the linked entity: 30 | 31 | | Component | Description | 32 | |:---------:|:-----------:| 33 | | Dimensions | The rect size for displaying the text | 34 | | TextFontID | The mapping required to link to the FontID | 35 | | TextOptions | The font style, size, and alignment | 36 | | CharElement | Stores all characters of a string | 37 | | LocalVertexDataElement | Vertex information needed to make the mesh | 38 | | LocalTriangleIndexElement | Mesh index information needed to store | 39 | | LinkedMaterialEntity | Stores the entity that has the Material component object and is linked to the text entity. | 40 | | MeshDataSpan | Stores the slice of vertex and index spans of the submesh that the text belongs to | 41 | | AppliedColor | The general color of the text | 42 | | BuildUIElementTag | Optionally added if you want to reconstruct the root mesh | 43 | | MaterialPropertyIndex | Stores the index used to access the Material Property | 44 | 45 | ### Storing Mesh Data 46 | All letters of a mesh are built to the same vertex buffer, this batches all potential meshes such that there is only 1 47 | issued draw calls. Generally, each letter's glyph is retrieved from the FontAsset entity, and the glyph metrics are 48 | applied to build the quad that will display. This takes into account font scaling so that larger point sizes match the 49 | editor time representation. 50 | 51 | For a more detailed outlook of building text individually and rendering, take a look 52 | at the [OpenGL tutorial](https://learnopengl.com/In-Practice/Text-Rendering), which 53 | affects the calculation to explains it quite nicely. 54 | -------------------------------------------------------------------------------- /Wiki/Close.md: -------------------------------------------------------------------------------- 1 | # Close 2 | 3 | In UGUI, you can typically "close" a UI element by disabling a GameObject. Unity rebuilds the canvas and displays the 4 | new rendered elements. 5 | 6 | To achieve this functionality in UGUIDOTS, it is implemented by extending the Button messaging system/event system. 7 | 8 | ## Background Information 9 | All GameObjects have metadata to determine whether or not it's active. This is typically done through the `activeInHierarchy` 10 | flag found in all GameObject. To emulate this behavior in a similar way, each canvas stores the state of its children 11 | with a component called `ChildrenActiveMetadata`. 12 | 13 | This allows us to determine whether an entity was enabled or disabled to begin with and mimic the same behaviour as 14 | ticking the active toggle box in each GameObject. 15 | 16 | For example, imagine a subgroup within the UI with 3 active elements and 1 inactive element. On start, we know that the 17 | subgroup's children will have 3 active elements and 1 inactive element, so the `ChildrenActiveMetadata` component will 18 | store this into its UnsafeHashMap. 19 | 20 | > The `ChildrenActiveMetadata` is populated on conversion via the `CanvasConversionSystem`. 21 | 22 | ## Workflow 23 | You would typically attach `CloseButtonAuthoring` component to the button. This component allows you to store multiple 24 | instances of GameObjects as targets. The `CloseButtonAuthoring` remaps the GameObjects' to their entity version and 25 | stores a `DynamicBuffer` of targetted entities to close, show, or toggle. 26 | 27 | Determining the functionality is driven by the enum specified in the `CloseButtonAuthoring`. For example, a Type of 28 | Toggle will attach the `ToggleButtonType` component to the entity and switch the behavior. 29 | 30 | ## Runtime 31 | When the button is clicked, the `ToggleVisibilitySystem` will loop through all the targets that intend to close/show. 32 | The system goes through each element's child recursively and ensures that all its children are disabled. Only the target 33 | entities active state metadata is flipped. The children's metadata are not flipped so that the last known active states 34 | are consistent and when the subgroup is renabled - the correct elements can be displayed properly. Entities are 35 | "disabled" by attaching the `Disabled` component to the target entites and their children. They are renabled when the 36 | `EnableRenderingTag` is added back to the entity. 37 | 38 | The state of the entity determines how the `UpdateLocalMeshDataSystem` to manipulate the vertices: 39 | 40 | * If the entity is `Disabled` and does not have `EnableRenderingTag`, then the entity is newly disabled and the vertices 41 | are moved out of view. 42 | * If the entity has the `EnableRenderingTag` and the `Disabled` tag is removed, then the entity is renabled and the 43 | vertices are moved into view. 44 | * If the entity has neither, then the entity is currently enabled and rendering. 45 | 46 | See the `CloseButtonSample` for a demo of how this works. 47 | -------------------------------------------------------------------------------- /Core/Components/ImageComponents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | using UnityEngine; 6 | using UnityEngine.Sprites; 7 | using UnityEngine.UI; 8 | 9 | namespace UGUIDots { 10 | 11 | /// 12 | /// Stores the sprite's UVs, padding, and minimum size. 13 | /// 14 | [StructLayout(LayoutKind.Sequential)] 15 | public struct SpriteData : IComponentData { 16 | public float4 InnerUV; 17 | public float4 OuterUV; 18 | public float4 Padding; 19 | public float2 MinSize; 20 | 21 | public static SpriteData FromSprite(Sprite sprite) { 22 | if (sprite) { 23 | return new SpriteData { 24 | InnerUV = DataUtility.GetInnerUV(sprite), 25 | OuterUV = DataUtility.GetOuterUV(sprite), 26 | Padding = DataUtility.GetPadding(sprite), 27 | MinSize = DataUtility.GetMinSize(sprite) 28 | }; 29 | } 30 | return default; 31 | } 32 | } 33 | 34 | // TODO: This is a temporary solution for individual sprite data - may not work with packed atlases... 35 | /// 36 | /// Stores the sprite's texture resolution so that we can use it for scaling 37 | /// 38 | public struct DefaultSpriteResolution : IComponentData { 39 | public int2 Value; 40 | } 41 | 42 | /// 43 | /// Stores the intended color to apply to the entity. 44 | /// 45 | public struct AppliedColor : IComponentData, IEquatable { 46 | public Color32 Value; 47 | 48 | public bool Equals(AppliedColor other) { 49 | return other.Value.Equals(Value); 50 | } 51 | 52 | public override int GetHashCode() { 53 | return Value.GetHashCode(); 54 | } 55 | } 56 | 57 | /// 58 | /// Stores various color states that need to be applied to the image. 59 | /// 60 | public struct ColorStates : IComponentData { 61 | public Color32 DefaultColor, HighlightedColor, PressedColor, DisabledColor; 62 | 63 | public static ColorStates FromColorBlock(ColorBlock block) { 64 | return new ColorStates { 65 | HighlightedColor = block.highlightedColor, 66 | PressedColor = block.pressedColor, 67 | DisabledColor = block.disabledColor, 68 | DefaultColor = block.normalColor 69 | }; 70 | } 71 | } 72 | 73 | public static class ColorExtensions { 74 | public static float4 ToFloat4(this in Color32 color) { 75 | return new float4(color.r, color.g, color.b, color.a); 76 | } 77 | 78 | public static float4 ToNormalizedFloat4(this in Color32 color) { 79 | return new float4(color.r / 255f, color.g / 255f, color.b / 255f, color.a / 255f); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Collections/Unsafe/UnsafeArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using Unity.Collections; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace UGUIDots.Collections.Unsafe { 7 | 8 | // TODO: Allow for enumeration like foreach loops. 9 | public unsafe struct UnsafeArray : IDisposable, IEquatable> where T : unmanaged { 10 | 11 | public int Length { get; private set; } 12 | public bool IsCreated => _Ptr != null; 13 | 14 | [NativeDisableUnsafePtrRestriction] 15 | internal void* _Ptr; 16 | 17 | Allocator allocType; 18 | 19 | public UnsafeArray(int length, Allocator allocator) { 20 | var size = UnsafeUtility.SizeOf() * length; 21 | Length = length; 22 | _Ptr = UnsafeUtility.Malloc(size, UnsafeUtility.SizeOf(), allocator); 23 | allocType = allocator; 24 | } 25 | 26 | public void Dispose() { 27 | if (IsCreated) { 28 | UnsafeUtility.Free(_Ptr, allocType); 29 | _Ptr = null; 30 | Length = 0; 31 | } 32 | } 33 | 34 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 35 | public ref T AsRef(int i) => ref ((T*)_Ptr)[i]; 36 | 37 | public unsafe bool Equals(UnsafeArray other) { 38 | return other.Length == Length && other._Ptr == _Ptr; 39 | } 40 | 41 | public override bool Equals(object other) { 42 | if (other == null) { 43 | return false; 44 | } 45 | return other is UnsafeArray && Equals(other); 46 | } 47 | 48 | public override int GetHashCode() { 49 | return ((int)_Ptr * 397) ^ Length; 50 | } 51 | 52 | public T this[int i] { 53 | get => AsRef(i); 54 | set => AsRef(i) = value; 55 | } 56 | 57 | public static bool operator ==(in UnsafeArray lhs, in UnsafeArray rhs) { 58 | return lhs.Equals(rhs); 59 | } 60 | 61 | public static bool operator !=(UnsafeArray lhs, UnsafeArray rhs) { 62 | return !lhs.Equals(rhs); 63 | } 64 | 65 | public static UnsafeArray FromNativeArray(ref NativeArray source, Allocator allocator) { 66 | var size = source.Length; 67 | var unsafeData = new UnsafeArray(size, allocator); 68 | UnsafeUtility.MemCpy(unsafeData._Ptr, source.GetUnsafePtr(), size * UnsafeUtility.SizeOf()); 69 | return unsafeData; 70 | } 71 | 72 | public static UnsafeArray FromNativeList(ref NativeList source, Allocator allocator) { 73 | var size = source.Length; 74 | var unsafeData = new UnsafeArray(size, allocator); 75 | UnsafeUtility.MemCpy(unsafeData._Ptr, source.GetUnsafePtr(), size * UnsafeUtility.SizeOf()); 76 | return unsafeData; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/Components/Dimensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | using UnityEngine; 6 | 7 | namespace UGUIDots { 8 | 9 | /// 10 | /// Represents the bounding box which may be used to generate the quads for images. For text based entities, 11 | /// this struct would be defined as the "bounding box" of the text for word wrapping/truncation. 12 | /// 13 | public struct Dimensions : IComponentData, IEquatable { 14 | public int2 Value; 15 | 16 | public bool Equals(Dimensions other) { 17 | return other.Value.Equals(Value); 18 | } 19 | 20 | public override int GetHashCode() { 21 | return Value.GetHashCode(); 22 | } 23 | } 24 | 25 | // TODO: Define a much more descriptive functions - since these use "texture" space where 0,0 is the BL corner. 26 | public static class DimensionsExtensions { 27 | 28 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 29 | public static float2 LocalSpaceOrigin(this in Dimensions dim) { 30 | return default; 31 | } 32 | 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public static float2 LocalSpaceUpperLeft(this in Dimensions dim) { 35 | var extents = dim.Extents(); 36 | return dim.LocalSpaceOrigin() + new float2(-extents.x, extents.y); 37 | } 38 | 39 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 40 | public static int Width(this in Dimensions dim) { 41 | return (int)dim.Value.x; 42 | } 43 | 44 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 45 | public static int Height(this in Dimensions dim) { 46 | return (int)dim.Value.y; 47 | } 48 | 49 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 50 | public static int2 Int2Size(this in Dimensions dim) { 51 | return new int2(dim.Width(), dim.Height()); 52 | } 53 | 54 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 55 | public static float2 Extents(this in Dimensions dim) { 56 | return dim.Value / 2; 57 | } 58 | 59 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 60 | public static float2 Size(this RectTransform transform) { 61 | return new float2(transform.rect.width, transform.rect.height); 62 | } 63 | 64 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 65 | public static int2 Int2Size(this RectTransform transform) { 66 | return new int2((int)transform.rect.width, (int)transform.rect.height); 67 | } 68 | 69 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 70 | public static float2 Center(this in Dimensions dim) { 71 | return new float2(dim.Extents()); 72 | } 73 | 74 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 75 | public static int2 Int2Center(this in Dimensions dim) { 76 | return new int2(dim.Extents()); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshComponents.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using UnityEngine.Rendering; 5 | 6 | namespace UGUIDots.Render { 7 | 8 | /// 9 | /// Stores all batched vertices. 10 | /// 11 | [StructLayout(LayoutKind.Sequential)] 12 | public struct RootVertexData : IBufferElementData { 13 | public float3 Position; 14 | public float3 Normal; 15 | public float4 Color; 16 | public float2 UV1; 17 | public float2 UV2; 18 | } 19 | 20 | /// 21 | /// Stores the UI elements vertex element required for each mesh. 22 | /// 23 | [StructLayout(LayoutKind.Sequential)] 24 | public struct LocalVertexData : IBufferElementData { 25 | public float3 Position; 26 | public float3 Normal; 27 | public float4 Color; 28 | public float2 UV1; 29 | public float2 UV2; 30 | 31 | public static implicit operator RootVertexData(LocalVertexData value) { 32 | return new RootVertexData { 33 | Position = value.Position, 34 | Normal = value.Normal, 35 | Color = value.Color, 36 | UV1 = value.UV1, 37 | UV2 = value.UV2 38 | }; 39 | } 40 | } 41 | 42 | /// 43 | /// Stores the root indices needed to generate triangles. 44 | /// 45 | public struct RootTriangleIndexElement : IBufferElementData { 46 | public ushort Value; 47 | 48 | public static implicit operator RootTriangleIndexElement(ushort value) => new RootTriangleIndexElement { Value = value }; 49 | public static implicit operator ushort(RootTriangleIndexElement value) => value.Value; 50 | } 51 | 52 | /// 53 | /// Stores the UI element's local indices to generate a triangle. 54 | /// 55 | public struct LocalTriangleIndexElement : IBufferElementData { 56 | public ushort Value; 57 | 58 | public static implicit operator LocalTriangleIndexElement(ushort value) => 59 | new LocalTriangleIndexElement { Value = value }; 60 | public static implicit operator ushort(LocalTriangleIndexElement value) => value.Value; 61 | } 62 | 63 | /// 64 | /// Marks that an entity needs a Mesh associated with it. 65 | /// 66 | public struct AddMeshTag : IComponentData { } 67 | 68 | public static class MeshVertexDataExtensions { 69 | 70 | /// 71 | /// Descriptor for the mesh generated for text. 72 | /// 73 | public static readonly VertexAttributeDescriptor[] VertexDescriptors = new [] { 74 | new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3), 75 | new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3), 76 | new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.Float32, 4), 77 | new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2), 78 | new VertexAttributeDescriptor(VertexAttribute.TexCoord1, VertexAttributeFormat.Float32, 2) 79 | }; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Core/Authoring/Render/BatchedMeshAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | using Unity.Entities; 4 | using Unity.Mathematics; 5 | using UnityEngine; 6 | using UnityEngine.UI; 7 | 8 | namespace UGUIDots.Render.Authoring { 9 | 10 | public class BatchedMeshAuthoring : MonoBehaviour, IConvertGameObjectToEntity { 11 | 12 | // Used for serialization cases of jagged arrays 13 | [System.Serializable] 14 | public struct BatchedElements { 15 | public GameObject[] Elements; 16 | } 17 | 18 | public BatchedElements[] Batches; 19 | 20 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 21 | var renderEntities = new NativeList(Allocator.Temp); 22 | var batchSpans = new NativeList(Allocator.Temp); 23 | 24 | // Flat map the batch of render elements to a single array. 25 | int startIndex = 0; 26 | for (int i = 0; i < Batches.Length; i++) { 27 | var currentBatch = Batches[i].Elements; 28 | 29 | for (int j = 0; j < currentBatch.Length; j++) { 30 | var uiElement = currentBatch[j]; 31 | var uiEntity = conversionSystem.GetPrimaryEntity(uiElement); 32 | renderEntities.Add(new RenderElement { Value = uiEntity }); 33 | } 34 | 35 | batchSpans.Add(new int2(startIndex, currentBatch.Length)); 36 | startIndex += currentBatch.Length; 37 | } 38 | 39 | // Build the material property batch by only taking the first element of the BatchedElements. 40 | // This is due to the first elementing being representative of the entire batch. 41 | var propertyBatch = new MaterialPropertyBatch { 42 | Value = new MaterialPropertyBlock[Batches.Length] 43 | }; 44 | 45 | for (int i = 0; i < Batches.Length; i++) { 46 | var block = new MaterialPropertyBlock(); 47 | 48 | if (Batches[i].Elements[0].TryGetComponent(out Image image)) { 49 | var texture = image.sprite != null ? image.sprite.texture : Texture2D.whiteTexture; 50 | block.SetTexture(ShaderIDConstants.MainTex, texture); 51 | 52 | for (int k = 0; k < Batches[i].Elements.Length; k++) { 53 | var associativeEntity = conversionSystem.GetPrimaryEntity(Batches[i].Elements[k]); 54 | dstManager.AddComponentData(associativeEntity, new MaterialPropertyIndex { Value = (ushort)i }); 55 | } 56 | } 57 | 58 | propertyBatch.Value[i] = new MaterialPropertyBlock(); 59 | } 60 | 61 | dstManager.AddComponentData(entity, propertyBatch); 62 | 63 | unsafe { 64 | var renderBatches = dstManager.AddBuffer(entity); 65 | var size = UnsafeUtility.SizeOf() * renderEntities.Length; 66 | 67 | renderBatches.ResizeUninitialized(renderEntities.Length); 68 | UnsafeUtility.MemCpy(renderBatches.GetUnsafePtr(), renderEntities.GetUnsafePtr(), size); 69 | 70 | var renderSpans = dstManager.AddBuffer(entity); 71 | size = UnsafeUtility.SizeOf() * batchSpans.Length; 72 | 73 | renderSpans.ResizeUninitialized(batchSpans.Length); 74 | UnsafeUtility.MemCpy(renderSpans.GetUnsafePtr(), batchSpans.GetUnsafePtr(), size); 75 | } 76 | 77 | renderEntities.Dispose(); 78 | batchSpans.Dispose(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Core/Systems/Transforms/CanvasScalerSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | using Unity.Entities; 4 | using Unity.Jobs; 5 | using Unity.Mathematics; 6 | using Unity.Transforms; 7 | using UnityEngine; 8 | 9 | namespace UGUIDots.Transforms.Systems { 10 | 11 | [UpdateInGroup(typeof(UITransformConsumerGroup))] 12 | public class ConsumeChangeEvtSystem : SystemBase { 13 | 14 | private EntityCommandBufferSystem cmdBufferSystem; 15 | 16 | protected override void OnCreate() { 17 | cmdBufferSystem = World.GetOrCreateSystem(); 18 | } 19 | 20 | protected override void OnUpdate() { 21 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer().AsParallelWriter(); 22 | 23 | Dependency = Entities.ForEach((Entity entity, in ResolutionChangeEvt c0) => { 24 | cmdBuffer.DestroyEntity(entity.Index, entity); 25 | }).Schedule(Dependency); 26 | 27 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 28 | } 29 | } 30 | 31 | /// 32 | /// Scales all the canvases if the resolution of the window changes. 33 | /// 34 | [UpdateInGroup(typeof(UITransformProducerGroup))] 35 | public unsafe class CanvasScalerSystem : SystemBase { 36 | 37 | private EntityCommandBufferSystem cmdBufferSystem; 38 | private EntityQuery scaleQuery; 39 | private EntityArchetype evtArchetype; 40 | 41 | private int2* res; 42 | 43 | protected override void OnCreate() { 44 | scaleQuery = GetEntityQuery(new EntityQueryDesc { 45 | All = new [] { 46 | ComponentType.ReadOnly(), 47 | ComponentType.ReadOnly(), 48 | ComponentType.ReadWrite() 49 | } 50 | }); 51 | 52 | evtArchetype = EntityManager.CreateArchetype(typeof(ResolutionChangeEvt)); 53 | 54 | cmdBufferSystem = World.GetOrCreateSystem(); 55 | 56 | res = (int2*)UnsafeUtility.Malloc(UnsafeUtility.SizeOf(), UnsafeUtility.AlignOf(), Allocator.Persistent); 57 | *res = new int2(Screen.width, Screen.height); 58 | } 59 | 60 | protected override void OnDestroy() { 61 | if (res != null) { 62 | UnsafeUtility.Free(res, Allocator.Persistent); 63 | res = null; 64 | } 65 | } 66 | 67 | protected unsafe override void OnUpdate() { 68 | var current = new int2(Screen.width, Screen.height); 69 | 70 | if (res->Equals(current)) { 71 | return; 72 | } 73 | 74 | *res = current; 75 | int2* local = res; 76 | 77 | var cmdBuffer = cmdBufferSystem.CreateCommandBuffer(); 78 | 79 | Dependency = Entities.ForEach((ref LocalToWorld c2, in ReferenceResolution c0, in WidthHeightRatio c1) => { 80 | var logWidth = math.log2(local->x / c0.Value.x); 81 | var logHeight = math.log2(local->y / c0.Value.y); 82 | var avg = math.lerp(logWidth, logHeight, c1.Value); 83 | var scale = math.pow(2, avg); 84 | var center = new float3(local->xy / 2, 0); 85 | 86 | c2 = new LocalToWorld { Value = float4x4.TRS(center, c2.Rotation, new float3(scale)) }; 87 | }).WithNativeDisableUnsafePtrRestriction(local).Schedule(Dependency); 88 | 89 | var archetype = evtArchetype; 90 | 91 | Dependency = Job.WithCode(() => { 92 | cmdBuffer.CreateEntity(archetype); 93 | }).Schedule(Dependency); 94 | 95 | cmdBufferSystem.AddJobHandleForProducer(Dependency); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Wiki/Button.md: -------------------------------------------------------------------------------- 1 | # Button 2 | 3 | Buttons are supported but in a rather verbose way. They are currently experimental and will need work further down the 4 | line to make it easier to support buttons. 5 | 6 | ## Setup 7 | To setup a Button, it is highly recommended to use the TextMeshPro button if you want to have text with your button. To 8 | mark a button, add the following to the GameObject: 9 | 10 | |Component | Description | 11 | |:---------|:------------| 12 | | ButtonTypeAuthoring | Stores the type of click button the button is | 13 | | Button Behavior Script | A custom authored script which will tell what the button will do | 14 | | ButtonFrameMessagePayload | A custom entity to produce when clicked | 15 | 16 | ## Workflow 17 | > Again this is experimental and will likely change over time. 18 | 19 | ### ButtonTypeAuthoring 20 | The `ButtonTypeAuthoring` component defines the kind of button. 21 | 22 | There are currently three kinds of buttons 23 | * ReleaseUp 24 | * PressDown 25 | * Held 26 | 27 | Clicks are registered based on its type. A button type which is `ReleaseUp` will mean that a click is registered when 28 | the mouse is let go. This is similar to current button behaviors found in desktop operating systems (Window, macOS, \*nix). 29 | A button type of `PressDown` means that the moment the mouse is pressed - the button will respond. This is recommended 30 | if you have a something that is very time sensitive and need to have a click registered (e.g. mobile UI that requires 31 | rapid tapping). A button type of `Held` means that as long as the cursor is on top of the button then, a click is 32 | registered. 33 | 34 | ### Button Behavior Script 35 | The Button Behavior Script is your own authored behavior that you attach to the Button GameObject. Because UGUIDots does 36 | not have any kind of its own native event system, it uses a Producer/Consumer model. 37 | 38 | The custom button behavior _must_ define an entity to produce during the click. This produced entity is processed on the 39 | following frame and consumed on the next frame in the `PresentationCommandBufferSystem`. 40 | 41 | For example, this is how the `ButtonSample` in the demo works: 42 | 43 | ``` 44 | // ButtonSample.cs 45 | 46 | public struct SampleID : IComponentData { 47 | public int Value; 48 | } 49 | 50 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { 51 | var msgEntity = dstManager.CreateEntity(); 52 | dstManager.AddComponentData(msgEntity, new SampleID { Value = SOME_VALUE }); 53 | dstManager.AddComponentData(entity, new ButtonMessageFramePayload { Value = msgEntity }); 54 | } 55 | ``` 56 | 57 | The `SampleID` struct is a custom component with some data we want to produce on a click. It can be any integer we define 58 | in the inspector of the script. 59 | 60 | In the `Convert` function, we produce a dummy entity called, `msgEntity`. The `msgEntity` is added with the `SampleID` 61 | component data. 62 | 63 | ***Lastly***, the `msgEntity` is stored in a `ButtonMessageFramePayload` of the Button entity. This allows the `ButtonMessageProducerSystem` 64 | to read the linked entity of the Button and create a copy of it to signal other systems to run their update behavior. 65 | 66 | ### Message Groups 67 | The pipeline of how buttons work is as followed: 68 | 69 | * Click on button 70 | * Produce a messaging entity 71 | * Process messaging entity to do some action (see below) 72 | * Consume messaging entity 73 | 74 | To support this pipeline, there are ComponentSystemGroups provided to implement your system in to process the message. 75 | 76 | ``` 77 | MessagingUpdateGroup <- where systems will update in to process the created messaging entity 78 | MessagingConsumptionGroup <- where the ButtonMessageConsumerSystem will destroy the created messaging entity 79 | MessagingProductionGroup <- where the ButtonMessageProducerSystem will create the message messaging entity 80 | ``` 81 | -------------------------------------------------------------------------------- /Core/Components/Render/MeshUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Unity.Collections; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | namespace UGUIDots.Render { 8 | 9 | public static class MeshUtils { 10 | 11 | public static class Experimental { 12 | 13 | public static readonly VertexAttributeDescriptor[] Layout = new [] { 14 | new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3), 15 | new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float16, 2), 16 | new VertexAttributeDescriptor(VertexAttribute.Tangent, VertexAttributeFormat.UNorm8, 4) 17 | }; 18 | 19 | [StructLayoutAttribute(LayoutKind.Sequential)] 20 | public struct VertexData { 21 | public float3 Position; 22 | public short NormalX, NormalY; 23 | public Color32 Tangent; 24 | } 25 | 26 | public static Mesh CreateQuad(int height, int width) { 27 | var mesh = new Mesh(); 28 | 29 | var vertexData = new NativeArray(4, Allocator.Persistent); 30 | vertexData[0] = new VertexData { 31 | Position = new float3(-width / 2, -height / 2, 0), 32 | NormalX = 0, 33 | NormalY = 1, 34 | Tangent = Color.red 35 | }; 36 | vertexData[1] = new VertexData { 37 | Position = new float3(-width / 2, height / 2, 0), 38 | NormalX = 0, 39 | NormalY = 1, 40 | Tangent = Color.red 41 | }; 42 | vertexData[2] = new VertexData { 43 | Position = new float3(width / 2, height / 2, 0), 44 | NormalX = 0, 45 | NormalY = 1, 46 | Tangent = Color.red 47 | }; 48 | vertexData[3] = new VertexData { 49 | Position = new float3(width / 2, -height / 2, 0), 50 | NormalX = 0, 51 | NormalY = 1, 52 | Tangent = Color.red 53 | }; 54 | 55 | mesh.SetVertexBufferParams(4, Layout); 56 | mesh.SetVertexBufferData(vertexData, 0, 0, vertexData.Length); 57 | 58 | var indexData = new NativeArray(6, Allocator.Persistent); 59 | 60 | indexData[0] = 0; 61 | indexData[1] = 1; 62 | indexData[2] = 2; 63 | indexData[3] = 0; 64 | indexData[4] = 2; 65 | indexData[5] = 3; 66 | 67 | mesh.SetIndexBufferParams(6, IndexFormat.UInt32); 68 | mesh.SetIndexBufferData(indexData, 0, 0, indexData.Length); 69 | 70 | indexData.Dispose(); 71 | vertexData.Dispose(); 72 | return mesh; 73 | } 74 | } 75 | 76 | public static Mesh CreateQuad(int width, int height) { 77 | var mesh = new Mesh(); 78 | var verts = new Vector3[4]; 79 | var norms = new Vector3[4]; 80 | var uvs = new Vector2[4]; 81 | var indices = new int[6]; 82 | 83 | verts[0] = new Vector3(-width / 2, -height / 2); 84 | verts[1] = new Vector3(-width / 2, height / 2, 0); 85 | verts[2] = new Vector3(width / 2, height / 2, 0); 86 | verts[3] = new Vector3(width / 2, -height / 2, 0); 87 | 88 | for (int i = 0; i < 4; i++) { 89 | norms[i] = Vector3.up; 90 | } 91 | 92 | uvs[0] = new Vector2(); 93 | uvs[1] = new Vector2(0, 1); 94 | uvs[2] = new Vector2(1, 1); 95 | uvs[3] = new Vector2(1, 0); 96 | 97 | indices[0] = 0; 98 | indices[1] = 1; 99 | indices[2] = 2; 100 | indices[3] = 0; 101 | indices[4] = 2; 102 | indices[5] = 3; 103 | 104 | mesh.vertices = verts; 105 | mesh.normals = norms; 106 | mesh.triangles = indices; 107 | mesh.uv = uvs; 108 | 109 | mesh.RecalculateBounds(); 110 | return mesh; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/CanvasConversionSystem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UGUIDots.Render; 3 | using Unity.Collections; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | using Unity.Entities; 6 | using Unity.Transforms; 7 | using UnityEngine; 8 | using UnityEngine.UI; 9 | 10 | namespace UGUIDots.Conversions.Systems { 11 | 12 | [UpdateInGroup(typeof(GameObjectConversionGroup))] 13 | [UpdateAfter(typeof(RectTransformConversionSystem))] 14 | [UpdateAfter(typeof(ImageConversionSystem))] 15 | [UpdateAfter(typeof(TMPTextConversionSystem))] 16 | public class CanvasConversionSystem : GameObjectConversionSystem { 17 | 18 | protected override void OnUpdate() { 19 | Entities.ForEach((Canvas canvas) => { 20 | 21 | var parent = canvas.transform.parent; 22 | if (parent != null) { 23 | #if UNITY_EDITOR 24 | UnityEditor.EditorGUIUtility.PingObject(canvas); 25 | #endif 26 | throw new NotSupportedException($"{canvas.name} is child of {parent.name}, this is not supported!"); 27 | } 28 | 29 | var entity = GetPrimaryEntity(canvas); 30 | var canvasScaler = canvas.GetComponent(); 31 | 32 | // Build a metadata of the children which are active 33 | var count = 0; 34 | count = RecurseCountChildren(ref count, canvas.transform); 35 | 36 | var metadata = new UnsafeHashMap(count + 1, Allocator.Persistent); 37 | RecurseAddMetadata(ref metadata, canvas.transform); 38 | 39 | DstEntityManager.AddComponentData(entity, new ChildrenActiveMetadata { 40 | Value = metadata 41 | }); 42 | 43 | // Remove unnecessary information 44 | DstEntityManager.RemoveComponent(entity); 45 | DstEntityManager.RemoveComponent(entity); 46 | DstEntityManager.RemoveComponent(entity); 47 | 48 | // Add the root mesh renderering data to the canvas as the root primary renderer 49 | DstEntityManager.AddBuffer(entity); 50 | DstEntityManager.AddBuffer(entity); 51 | 52 | // Add a mesh to the canvas so treat it as a renderer. 53 | DstEntityManager.AddComponentData(entity, new AddMeshTag { }); 54 | 55 | // Add a collection of the submesh information 56 | DstEntityManager.AddBuffer(entity); 57 | DstEntityManager.AddBuffer(entity); 58 | 59 | switch (canvasScaler.uiScaleMode) { 60 | case CanvasScaler.ScaleMode.ScaleWithScreenSize: 61 | DstEntityManager.AddComponentData(entity, new ReferenceResolution { 62 | Value = canvasScaler.referenceResolution 63 | }); 64 | 65 | // TODO: Should figure out if I want to support shrinking and expanding only... 66 | if (canvasScaler.screenMatchMode == CanvasScaler.ScreenMatchMode.MatchWidthOrHeight) { 67 | DstEntityManager.AddComponentData(entity, new WidthHeightRatio { 68 | Value = canvasScaler.matchWidthOrHeight 69 | }); 70 | } else { 71 | throw new NotSupportedException($"{canvasScaler.screenMatchMode} is not supported yet."); 72 | } 73 | break; 74 | default: 75 | throw new NotSupportedException($"{canvasScaler.uiScaleMode} is not supported yet."); 76 | } 77 | }); 78 | } 79 | 80 | private int RecurseCountChildren(ref int count, Transform current) { 81 | count += current.childCount; 82 | for (int i = 0; i < current.childCount; i++) { 83 | var child = current.GetChild(i); 84 | 85 | if (child.childCount > 0) { 86 | RecurseCountChildren(ref count, child); 87 | } 88 | } 89 | return count; 90 | } 91 | 92 | private void RecurseAddMetadata(ref UnsafeHashMap interactableMetadata, Transform current) { 93 | for (int i = 0; i < current.childCount; i++) { 94 | var child = current.GetChild(i); 95 | var childEntity = this.GetPrimaryEntity(child); 96 | 97 | interactableMetadata.TryAdd(GetPrimaryEntity(child), child.gameObject.activeSelf); 98 | 99 | if (child.childCount > 0) { 100 | RecurseAddMetadata(ref interactableMetadata, child); 101 | } 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UGUIDOTS 2 | 3 |

4 | Logo done by Sabrina Lam 5 |

6 | 7 | UGUIDots is a Data Oriented Tech Stack library aimed to bridge the gap in between 8 | [Unity's WYSIWYG UI](https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/index.html) and 9 | the [Entity Component System](https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/index.html). 10 | This is a **low level library** which augments on top of Unity's UI and does not serve as a 11 | replacement - so the workflow of authoring UI designs in games largely remains the same. 12 | 13 | ## Why do this? 14 | A DOTS compliant UI is still underway (which will be based off of UIElements). Until then, I need a UI solution the 15 | works with the Scriptable Render Pipeline - without building too many custom tooling. Similarly - one that has the 16 | performance capabilities and low overhead for both mobile and desktops. That said supported platforms are primarily for: 17 | 18 | * Android 19 | * iOS (? - currently hard for me to test) 20 | * Linux 64 bit 21 | * macOS 22 | * Windows 64 bit 23 | 24 | ## Beta/Experimental Content 25 | Check out the `develop` branch of the repository for the redesigned system! This is something I've been working on 26 | lately and it redesigns how conversion and transformations are done. I haven't decided to merge this into the `master` 27 | branch as of late because I am trying to update the entire documentation and some features are missing. 28 | 29 | ## Wiki 30 | The [wiki](Wiki/Home.md) is currently being worked on and contains basic information about Image/Text pipelines. 31 | 32 | ## Changelog 33 | General purpose change log can be found [here](CHANGELOG.md). 34 | 35 | ## Contributions 36 | If you would like to help contribute to the development of UGUIDots, please see the contribution guidelines [here](CONTRIBUTING.md). 37 | 38 | ## TODO 39 | 40 | Support for the following will come over time - depends on the needs for my own game. 41 | 42 | * [x] Canvas Scaling 43 | * [x] Anchoring 44 | * [x] Image stretching 45 | * [x] Button actions 46 | * [x] Button states (with color support) 47 | * [x] Hierarchy based disabling 48 | * [x] Text Rendering 49 | * [ ] Input fields 50 | * [ ] Subscene support 51 | * [x] Support manual image / text batching of static UI elements (static analysis) 52 | 53 | ## Installation 54 | 55 | ### OpenUPM 56 | There is currently a known issue with OpenUPM, where Unity internal scopes are added to the registry. After adding the 57 | package via OpenUPM, head over to the manifest file and delete the `com.unity.*` under the `scopes` entry. 58 | 59 | ``` 60 | cd 61 | openupm add com.initialprefabs.uguidots 62 | ``` 63 | 64 | ### Git Submodule 65 | 66 | ``` 67 | git submodule add https://github.com/InitialPrefabs/UGUIDots.git 68 | ``` 69 | 70 | ### Manually 71 | Download the latest [release](https://github.com/InitialPrefabs/UGUIDots/releases) and add it to your project directly. 72 | 73 | 74 | ## QuickStart 75 | 76 | Below are the basic steps to get the package working in game. 77 | 78 | ### Setting up the Render Command 79 | * Set up project to use the Universal Render Pipeline 80 | * Add the RenderCommandAuthoring component with a scriptable render feature to a GameObject. 81 | * Add the `ConvertToEntity` component to the `RenderCommandAuthoring` GameObject 82 | 83 | ### Converting GameObjects to Entities 84 | * Design your UI normally using the WYSWYG editor in Unity 85 | * Add the BatchedMeshAuthoring component to your root canvas 86 | * Build the batch on the BatchedMeshAuthoring component 87 | * Add the `ConvertToEntity` component to convert the GameObject hierarchy to its Entities' format 88 | 89 | ### Setting up input 90 | * Add the `MobileMouseInputAuthoring` component to a GameObject for Mobile support 91 | * Add the `StandaloneInputAuthoring` component to a GameObject for Windows/macOS/\*nix support 92 | * Put the GameObject into a subscene _or_ add the `ConvertToEntity` component to it 93 | 94 | ## Sample Repository 95 | 96 | Please see the Sample repository [here](https://github.com/InitialPrefabs/UGUIDots.Samples). 97 | 98 | ## Dependencies 99 | 100 | * Unity 2020.1.x 101 | 102 | Grab these from Unity's package manager. 103 | 104 | * Burst 1.3.4 105 | * Collections 0.12.0-preview.13 106 | * Entities 0.14.0-preview.18 107 | * Jobs 0.5.0-preview.14 108 | * Mathematics 1.2.1 109 | * TextMeshPro 3.0.1 110 | * UGUI 1.0.0 111 | * Universal RP 9.0.0-preview.35 112 | 113 | ## Limitations 114 | Development is still underway - so not all of the features Unity has by default is supported. Similarly - there are certain 115 | cases that are not accounted for, like sub canvases as I barely use features like that. 116 | 117 | ## Credits 118 | Some thanks to a few folks who've helped me figure out things along the way 119 | 120 | * Sabrina Lam (Logo artwork) 121 | * Valentina S. 122 | * Arthur D. 123 | * Mason R. 124 | -------------------------------------------------------------------------------- /Core/Systems/Conversions/ImageConversionSystem.cs: -------------------------------------------------------------------------------- 1 | using UGUIDots.Render; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | namespace UGUIDots.Conversions.Systems { 8 | 9 | /// 10 | /// Converts images by associating the material to the Image based chunk. 11 | /// 12 | [UpdateInGroup(typeof(GameObjectConversionGroup))] 13 | [UpdateAfter(typeof(VisualAssetsConversionSystem))] 14 | public class ImageConversionSystem : GameObjectConversionSystem { 15 | 16 | protected override void OnUpdate() { 17 | Entities.ForEach((Image image) => { 18 | var texture = image.sprite != null ? image.sprite.texture : Texture2D.whiteTexture; 19 | var material = image.material != null ? image.material : Canvas.GetDefaultCanvasMaterial(); 20 | 21 | var entity = GetPrimaryEntity(image); 22 | var rectSize = image.rectTransform.Int2Size(); 23 | 24 | DstEntityManager.AddComponentData(entity, new LinkedTextureEntity { Value = GetPrimaryEntity(texture) }); 25 | DstEntityManager.AddComponentData(entity, new LinkedMaterialEntity { Value = GetPrimaryEntity(material) }); 26 | DstEntityManager.AddComponentData(entity, new AppliedColor { Value = image.color }); 27 | 28 | var spriteTexture = image.sprite; 29 | var spriteRes = spriteTexture != null ? 30 | new int2(spriteTexture.texture.width, spriteTexture.texture.height) : 31 | rectSize; 32 | 33 | DstEntityManager.AddComponentData(entity, new DefaultSpriteResolution { Value = spriteRes }); 34 | 35 | var spriteData = SpriteData.FromSprite(image.sprite); 36 | DstEntityManager.AddComponentData(entity, spriteData); 37 | 38 | // TODO: Does not handle image slicing 39 | DstEntityManager.AddBuffer(entity).ResizeUninitialized(4); 40 | DstEntityManager.AddBuffer(entity).ResizeUninitialized(6); 41 | 42 | // Mark that the image has to be built. 43 | DstEntityManager.AddComponent(entity); 44 | 45 | var type = image.type; 46 | 47 | switch (type) { 48 | case Image.Type.Simple: 49 | break; 50 | case Image.Type.Filled: 51 | SetFill(image, entity); 52 | break; 53 | default: 54 | throw new System.NotSupportedException($"Only Simple/Filled Image types are supported so far for {image.name}"); 55 | } 56 | 57 | // If the image is inactive, then we want to make sure the image gets offsetted. 58 | if (!image.gameObject.activeInHierarchy || !image.enabled) { 59 | DstEntityManager.AddComponent(entity); 60 | } 61 | }); 62 | } 63 | 64 | private void SetFill(Image image, Entity entity) { 65 | var fillMethod = image.fillMethod; 66 | switch (fillMethod) { 67 | case Image.FillMethod.Vertical: 68 | if (image.fillOrigin == (int)Image.OriginVertical.Bottom) { 69 | DstEntityManager.AddComponentData(entity, new FillAmount { 70 | Amount = image.fillAmount, 71 | Type = FillType.BottomToTop, 72 | }); 73 | } 74 | 75 | if (image.fillOrigin == (int) Image.OriginVertical.Top) { 76 | DstEntityManager.AddComponentData(entity, new FillAmount { 77 | Amount = image.fillAmount, 78 | Type = FillType.TopToBottom, 79 | }); 80 | } 81 | break; 82 | case Image.FillMethod.Horizontal: 83 | if (image.fillOrigin == (int)Image.OriginHorizontal.Left) { 84 | DstEntityManager.AddComponentData(entity, new FillAmount { 85 | Amount = image.fillAmount, 86 | Type = FillType.LeftToRight 87 | }); 88 | } 89 | 90 | if (image.fillOrigin == (int)Image.OriginHorizontal.Right) { 91 | DstEntityManager.AddComponentData(entity, new FillAmount { 92 | Amount = image.fillAmount, 93 | Type = FillType.RightToLeft, 94 | }); 95 | } 96 | break; 97 | default: 98 | throw new System.NotSupportedException("Radial support is not implemented yet."); 99 | } 100 | } 101 | } 102 | } 103 | --------------------------------------------------------------------------------