MCQs > IT & Programming > Unity3D > The following code snippets attempt to change an objects color to red during a certain interval of the objects animation. The interval is defined as percentages of the animation duration, enablePercentTime and disablePercentTime (for example, turn the object to red starting 20% of the way through the animation and turn the color back to the original color when the animation is 60% through). Which of the code snippets do this correctly?

Unity3D MCQs

The following code snippets attempt to change an objects color to red during a certain interval of the objects animation. The interval is defined as percentages of the animation duration, enablePercentTime and disablePercentTime (for example, turn the object to red starting 20% of the way through the animation and turn the color back to the original color when the animation is 60% through). Which of the code snippets do this correctly?

Answer

Correct Answer: public List stateName; public float enablePercentTime, disablePercentTime; void Start () {StartCoroutine (StartAnim());} IEnumerator StartAnim(){ GetComponent ().material.color = Color.green; GetComponent ().Play (stateName[0]); float waitTimeFactor = enablePercentTime / 100f; yield return new WaitForSeconds(GetComponent ().GetCurrentAnimatorStateInfo (0).length * waitTimeFactor); GetComponent ().material.color = Color.red; float waitTimeForEnable = disablePercentTime / 100f; waitTimeFactor = waitTimeForEnable - waitTimeFactor; yield return new WaitForSeconds(GetComponent ().GetCurrentAnimatorStateInfo (0).length * waitTimeFactor); GetComponent ().material.color = Color.green; }

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Unity3D Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Unity3D Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it