CoreComponentAPI.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace MagicaCloth
  7. {
  8. /// <summary>
  9. /// CoreComponent API
  10. /// </summary>
  11. public abstract partial class CoreComponent : BaseComponent, IShareDataObject, IDataVerify, IEditorMesh, IEditorCloth, IDataHash, IBoneReplace
  12. {
  13. /// <summary>
  14. /// コンポーネントで使用されているすべてのボーンを返します。
  15. /// Returns all bones used in the component.
  16. /// </summary>
  17. /// <returns></returns>
  18. public Dictionary<string, Transform> GetUsedComponentBones()
  19. {
  20. var boneDict = new Dictionary<string, Transform>();
  21. var bones = GetUsedBones();
  22. foreach (var t in bones)
  23. if (t)
  24. {
  25. if (boneDict.ContainsKey(t.name))
  26. {
  27. if (boneDict[t.name] != t)
  28. Debug.LogWarning($"The bone name is duplicated!:{t.name}");
  29. }
  30. else
  31. boneDict.Add(t.name, t);
  32. }
  33. return boneDict;
  34. }
  35. /// <summary>
  36. /// コンポーネントで使用されているすべてのボーンの名前を返します。
  37. /// Returns all bone names used in the component.
  38. /// </summary>
  39. /// <returns></returns>
  40. public List<string> GetUsedComponentBoneNames()
  41. {
  42. return new List<string>(GetUsedComponentBones().Keys);
  43. }
  44. /// <summary>
  45. /// コンポーネントのボーンを入れ替え再セットアップします。
  46. /// Swap component bones and set up again.
  47. /// https://magicasoft.jp/en/corecomponent-2/
  48. /// </summary>
  49. /// <param name="boneReplaceDict"></param>
  50. public void ReplaceComponentBone(Dictionary<Transform, Transform> boneReplaceDict)
  51. {
  52. ChangeAvatar(boneReplaceDict);
  53. }
  54. /// <summary>
  55. /// コンポーネントのボーンを入れ替え再セットアップします。
  56. /// Swap component bones and set up again.
  57. /// https://magicasoft.jp/en/corecomponent-2/
  58. /// </summary>
  59. /// <param name="boneReplaceDict"></param>
  60. public void ReplaceComponentBone(Dictionary<string, Transform> boneReplaceDict)
  61. {
  62. ChangeAvatar(boneReplaceDict);
  63. }
  64. }
  65. }