/// <summary> /// Applies changes to the USD variant selection made via UsdVariantSet behaviour. Objects will /// be destroyed and imported as a result. /// </summary> private void ApplyVariantSelectionState(Scene scene, UsdVariantSet variants) { var primSource = variants.GetComponent <UsdPrimSource>(); if (!primSource) { Debug.LogError("Null UsdPrimSource while applying variant selection state."); return; } var selections = variants.GetVariantSelections(); var path = primSource.m_usdPrimPath; var prim = scene.GetPrimAtPath(path); var varSets = prim.GetVariantSets(); foreach (var sel in selections) { if (!varSets.HasVariantSet(sel.Key)) { throw new Exception("Unknown varient set: " + sel.Key + " at " + path); } varSets.GetVariantSet(sel.Key).SetVariantSelection(sel.Value); } }
/// <summary> /// Applies changes to the USD variant selection made via UsdVariantSet behaviour. Objects will /// be destroyed and imported as a result. /// </summary> private void ApplyVariantSelectionState(Scene scene, UsdVariantSet variants) { var selections = variants.GetVariantSelections(); var path = variants.GetComponent <UsdPrimSource>().m_usdPrimPath; var prim = scene.GetPrimAtPath(path); var varSets = prim.GetVariantSets(); foreach (var sel in selections) { if (!varSets.HasVariantSet(sel.Key)) { throw new Exception("Unknown varient set: " + sel.Key + " at " + path); } varSets.GetVariantSet(sel.Key).SetVariantSelection(sel.Value); } }