Skip to content

Conversation

@mdeardorff
Copy link

@mdeardorff mdeardorff commented Jan 27, 2026

Description

This PR exposes the KHR_materials_variants extension at the Unity level for runtime-switching of textures. Primitives with the extension enabled will automatically add a CesiumMaterialVariants component which can be toggled between variants with SetVariant(int index) or SetVariant(string name).

Author checklist

  • I have submitted a Contributor License Agreement (only needed once).
  • I have done a full self-review of my code.
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).
  • I have added or updated unit tests to ensure consistent code coverage as necessary.
  • I have updated the documentation as necessary.

Testing plan

  • In Unity, create a CesiumTileset pointed at a tileset with the KHR_materials_variants extension.
  • Create a script that does something like:
[SerializeField]
private Cesium3DTileset tileset;

void Update()
{
    if (Keyboard.current.aKey.wasPressedThisFrame)
    {
        if (tileset != null)
        {
            var childVariants = tileset.GetComponentsInChildren<CesiumMaterialVariants>(true);

            foreach (var v in childVariants)
            {

                bool success = v.SetVariant(v.GetCurrentVariantIndex() == 0 ? -1 : 0);
                Debug.Log($"SetVariant result: {success}, now at: {v.GetCurrentVariantName()}");
            }

        }
    }
}
  • Expect to see tiles toggle between available variants.

@mdeardorff mdeardorff marked this pull request as ready for review January 28, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant