This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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