Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Last active February 12, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/07d94f49836e8325e2d359a9ae0441df to your computer and use it in GitHub Desktop.
Save flushpot1125/07d94f49836e8325e2d359a9ae0441df to your computer and use it in GitHub Desktop.
/*copied from complete version in sample project of "https://developer.microsoft.com/en-us/windows/holographic/holograms_211"*/
private void ExpandModelCommand(PhraseRecognizedEventArgs args)
{
// Swap out the current model for the expanded model.
GameObject currentModel = ExpandModel.Instance.gameObject;
ExpandModel.Instance.ExpandedModel.transform.position = currentModel.transform.position;
ExpandModel.Instance.ExpandedModel.transform.rotation = currentModel.transform.rotation;
ExpandModel.Instance.ExpandedModel.transform.localScale = currentModel.transform.localScale;
currentModel.SetActive(false);
ExpandModel.Instance.ExpandedModel.SetActive(true);
// Play animation. Ensure the Loop Time check box is disabled in the inspector for this animation to play it once.
Animator[] expandedAnimators = ExpandModel.Instance.ExpandedModel.GetComponentsInChildren<Animator>();
// Set local variables for disabling the animation.
if (expandedAnimators.Length > 0)
{
expandAnimationCompletionTime = Time.realtimeSinceStartup + expandedAnimators[0].runtimeAnimatorController.animationClips[0].length * 0.9f;
}
// Set the expand model flag.
isModelExpanding = true;
ExpandModel.Instance.Expand();
}
public void Update()
{
if (isModelExpanding && Time.realtimeSinceStartup >= expandAnimationCompletionTime)
{
isModelExpanding = false;
Animator[] expandedAnimators = ExpandModel.Instance.ExpandedModel.GetComponentsInChildren<Animator>();
foreach (Animator animator in expandedAnimators)
{
animator.enabled = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment