Skip to content

Unity

DigitalHeaven.Unity is the runtime integration library for Unity-based games and applications. It handles model loading, rig setup, material creation, and rendering pipeline adaptation at runtime.

It depends on DigitalHeaven.Core and ships as pre-compiled DLLs with no external dependencies — drop them into a Unity project or mod loader and they work.

For importing compiled pallets into the Unity Editor as native assets (materials, prefabs, meshes), see Unity Editor.

DigitalHeaven.Unity supports all three Unity rendering pipelines:

PipelineDefault Shader
Built-inStandard
URPUniversal Render Pipeline/Lit
HDRPHDRP/Lit

The active pipeline is auto-detected at runtime via RenderPipelineDetector. Detection checks the project’s GraphicsSettings render pipeline asset first, then falls back to shader probing. You can also override detection manually (e.g. in modding scenarios where reflection-based detection may not work):

DigitalHeaven.Unity.Rendering.RenderPipelineDetector
RenderPipelineDetector.Override(RenderPipeline.URP);

The legacy rendering pipeline, using the Standard shader.

Semantic PropertyShader Property
baseColor_MainTex
normal_BumpMap
metallicRoughness_MetallicGlossMap
occlusion_OcclusionMap
emissive_EmissionMap
tint_Color

The Built-in Standard shader uses a metallic-smoothness workflow. DigitalHeaven’s roughness property is automatically inverted to smoothness (_Glossiness).

The Standard shader’s rendering mode is controlled via the _Mode property, which can be set through platform overrides. This accepts "opaque", "cutout", "fade", or "transparent". Platform overrides are the only way to select "fade" specifically (which fades out specular and reflections along with the surface), since alpha mode auto-inference maps to "transparent" (preserving specular).

Uses the Universal Render Pipeline/Lit shader.

Semantic PropertyShader Property
baseColor_BaseMap
normal_BumpMap
metallicRoughness_MetallicGlossMap
occlusion_OcclusionMap
emissive_EmissionMap
tint_BaseColor

URP Lit uses a metallic-smoothness workflow similar to Built-in but with different property names. Roughness is inverted to _Smoothness.

Uses the HDRP/Lit shader.

Semantic PropertyShader Property
baseColor_BaseColorMap
normal_NormalMap
metallicRoughness_MaskMap
occlusion_OcclusionMap
emissive_EmissiveColorMap
tint_BaseColor

HDRP packs metallic, occlusion, and smoothness into a single _MaskMap texture (R: metallic, G: occlusion, B: detail mask, A: smoothness).

DigitalHeaven materials use semantic properties (baseColor, normal, roughness, etc.) that are automatically mapped to the correct shader properties for the active pipeline. See dh.material for the full material definition reference.

Alpha modes (opaque, mask, blend) are applied automatically, including auto-inference from tint alpha and texture alpha channels. For pipeline-specific customization beyond what semantic properties offer, use platform overrides — files placed in platforms/unity/ that can set raw shader properties, custom shaders, and rendering modes. See Unity Platform Overrides.

The Unity library creates a Unity Avatar and Animator from dh.rig definitions. A valid humanoid avatar requires the following 17 bones to be mapped:

GroupBones
CoreHips, Spine, Chest, Neck, Head
ArmsLeftUpperArm, LeftLowerArm, LeftHand, RightUpperArm, RightLowerArm, RightHand
LegsLeftUpperLeg, LeftLowerLeg, LeftFoot, RightUpperLeg, RightLowerLeg, RightFoot

Optional bones (shoulders, fingers, toes, face, etc.) are used when present. See dh.rig — Standard Bones for the full list of all 56 supported bones.

The library project is at DigitalHeaven.Unity/ in the repository. It targets netstandard2.0, netstandard2.1, net8.0, and net10.0.

A shared build target in Directory.Build.targets automatically copies compiled DLLs to local Unity test projects after building DigitalHeaven.Unity. Each Unity project is mapped to a target framework:

Unity ProjectTarget Framework
Games/DigitalHeaven.Unity-2021.1-Projectnetstandard2.0
Games/DigitalHeaven.Unity-6-Projectnetstandard2.1

DLLs are deployed to Assets/Plugins/DigitalHeaven/ within each project. To disable deployment, set the UnityDeploymentEnabled MSBuild property to false.