CustomRoleController.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class CustomRoleController : MonoBehaviour
  6. {
  7. private Animator ani;
  8. private void Start()
  9. {
  10. ani = GetComponent<Animator>();
  11. var t1 = ani.GetBoneTransform(HumanBodyBones.LeftHand);
  12. var t2 = ani.GetBoneTransform(HumanBodyBones.LeftFoot);
  13. Debug.Log(t1.name + " " + t1.position);
  14. Debug.Log(t2.name + " " + t2.position);
  15. }
  16. public void UpdateBoneScale(EditableBodyPart part,float value)
  17. {
  18. CustomRoleUtility.UpdateBoneScale(ani, part, value);
  19. }
  20. public List<Transform> GetBonesTrans()
  21. {
  22. var bonesTrans = new List<Transform>();
  23. //foreach (var item in Enum.GetValues(typeof(HumanBodyBones)))
  24. //{
  25. // if(item == null)
  26. // {
  27. // continue;
  28. // }
  29. // var trans = ani.GetBoneTransform((HumanBodyBones)item);
  30. // if(trans)
  31. // {
  32. // bonesTrans.Add(trans);
  33. // }
  34. //}
  35. Debug.Log(Enum.GetValues(typeof(HumanBodyBones)).Length);
  36. for (int i = 0; i < Enum.GetValues(typeof(HumanBodyBones)).Length - 1; i++)
  37. {
  38. Debug.Log((HumanBodyBones)i + " " + i);
  39. var trans = ani.GetBoneTransform((HumanBodyBones)i);
  40. if (trans)
  41. {
  42. bonesTrans.Add(trans);
  43. }
  44. }
  45. return bonesTrans;
  46. }
  47. }