DynamicBoneDemo1.cs 1.1 KB

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. public class DynamicBoneDemo1 : MonoBehaviour
  4. {
  5. private void Update()
  6. {
  7. this.m_Player.transform.Rotate(new Vector3(0f, Input.GetAxis("Horizontal") * Time.deltaTime * 200f, 0f));
  8. this.m_Player.transform.Translate(base.transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * 4f);
  9. }
  10. private void OnGUI()
  11. {
  12. GUI.Label(new Rect(50f, 50f, 200f, 20f), "Press arrow key to move");
  13. Animation componentInChildren = this.m_Player.GetComponentInChildren<Animation>();
  14. componentInChildren.enabled = GUI.Toggle(new Rect(50f, 70f, 200f, 20f), componentInChildren.enabled, "Play Animation");
  15. DynamicBone[] components = this.m_Player.GetComponents<DynamicBone>();
  16. GUI.Label(new Rect(50f, 100f, 200f, 20f), "Choose dynamic bone:");
  17. Behaviour behaviour = components[0];
  18. bool enabled = GUI.Toggle(new Rect(50f, 120f, 100f, 20f), components[0].enabled, "Breasts");
  19. components[1].enabled = enabled;
  20. behaviour.enabled = enabled;
  21. components[2].enabled = GUI.Toggle(new Rect(50f, 140f, 100f, 20f), components[2].enabled, "Tail");
  22. }
  23. public GameObject m_Player;
  24. }