CustomRoleUtility.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using UnityEngine;
  7. /// <summary>
  8. /// 可编辑脸部部位
  9. /// </summary>
  10. public enum EditableFacePart
  11. {
  12. eyebrow,
  13. eye,
  14. mousewidth
  15. }
  16. /// <summary>
  17. /// 可编辑身体部位
  18. /// </summary>
  19. public enum EditableBodyPart
  20. {
  21. UpperArm = 0,
  22. LowerArm = 1,
  23. Hand = 2,
  24. UpperLeg = 3,
  25. LowerLeg = 4,
  26. Foot = 5,
  27. All = 6,
  28. Neck = 7,
  29. Clavicle = 8,
  30. Shoulder = 9,
  31. Chest = 10,//胸
  32. Pleural = 11,//胸腔下部
  33. Belly = 12,//肚子
  34. UpperArmUp = 13,
  35. UpperArmDown = 14,
  36. UpperLegUp = 15,
  37. UpperLegDown = 16,
  38. LowerLegUp = 17,
  39. LowerLegDown = 18,
  40. Head = 19,
  41. None = 20,
  42. }
  43. /// <summary>
  44. /// 编辑类型
  45. /// </summary>
  46. public enum ModifyType
  47. {
  48. Length = 0,//长
  49. Width = 1,//宽
  50. Thick = 2,//厚度
  51. LengthWidthThick = 3,//长宽厚
  52. Angle = 4,//角度
  53. UpDown = 5,//上下
  54. LeftRight = 6,//左右
  55. ForwardBehind = 7,//前后
  56. }
  57. public static class CustomRoleUtility
  58. {
  59. public static void UpdateBoneScale(Animator ani,EditableBodyPart part,float value)
  60. {
  61. Transform transL = null;
  62. Transform transR = null;
  63. Vector3 beforeScale = Vector3.one;
  64. List<Transform> childList = new List<Transform>();
  65. bool keepChildWorldScale = false;
  66. switch (part)
  67. {
  68. case EditableBodyPart.UpperArm:
  69. transL = ani.GetBoneTransform(HumanBodyBones.LeftUpperArm);
  70. transR = ani.GetBoneTransform(HumanBodyBones.RightUpperArm);
  71. keepChildWorldScale = true;
  72. break;
  73. case EditableBodyPart.LowerArm:
  74. transL = ani.GetBoneTransform(HumanBodyBones.LeftLowerArm);
  75. transR = ani.GetBoneTransform(HumanBodyBones.RightLowerArm);
  76. break;
  77. case EditableBodyPart.Hand:
  78. transL = ani.GetBoneTransform(HumanBodyBones.LeftHand);
  79. transR = ani.GetBoneTransform(HumanBodyBones.RightHand);
  80. break;
  81. case EditableBodyPart.UpperLeg:
  82. transL = ani.GetBoneTransform(HumanBodyBones.LeftUpperLeg);
  83. transR = ani.GetBoneTransform(HumanBodyBones.RightUpperLeg);
  84. keepChildWorldScale = true;
  85. break;
  86. case EditableBodyPart.LowerLeg:
  87. transL = ani.GetBoneTransform(HumanBodyBones.LeftLowerLeg);
  88. transR = ani.GetBoneTransform(HumanBodyBones.RightLowerLeg);
  89. break;
  90. case EditableBodyPart.Foot:
  91. transL = ani.GetBoneTransform(HumanBodyBones.LeftFoot);
  92. transR = ani.GetBoneTransform(HumanBodyBones.RightFoot);
  93. break;
  94. case EditableBodyPart.None:
  95. break;
  96. default:
  97. break;
  98. }
  99. if(transL != null)
  100. {
  101. beforeScale = transL.localScale;
  102. var world_l = transL.lossyScale;
  103. transL.SetLocalScaleX(transL.localScale.x * value / world_l.x);
  104. transL.SetLocalScaleY(transL.localScale.y * value / world_l.y);
  105. transL.SetLocalScaleZ(transL.localScale.z * value / world_l.z);
  106. var lcount = transL.childCount;
  107. for (int i = 0; i < lcount; i++)
  108. {
  109. childList.Add(transL.GetChild(i));
  110. }
  111. }
  112. if(transR != null)
  113. {
  114. beforeScale = transR.localScale;
  115. var world_r = transR.lossyScale;
  116. transR.SetLocalScaleX(transR.localScale.x * value / world_r.x);
  117. transR.SetLocalScaleY(transR.localScale.y * value / world_r.y);
  118. transR.SetLocalScaleZ(transR.localScale.z * value / world_r.z);
  119. var rcount = transR.childCount;
  120. for (int i = 0; i < rcount; i++)
  121. {
  122. childList.Add(transR.GetChild(i));
  123. }
  124. }
  125. if(!keepChildWorldScale)
  126. {
  127. return;
  128. }
  129. for (int i = 0; i < childList.Count; i++)
  130. {
  131. var childTrans = childList[i];
  132. var oldScale = childTrans.localScale;
  133. childTrans.SetLocalScaleX(oldScale.x * beforeScale.x / value);
  134. childTrans.SetLocalScaleY(oldScale.y * beforeScale.y / value);
  135. childTrans.SetLocalScaleZ(oldScale.z * beforeScale.z / value);
  136. }
  137. }
  138. public static void ShowFile()
  139. {
  140. FileStream fs = File.Open("E:/key.key", FileMode.Open);
  141. FileStream fsout = File.Open("E:/keyout9.key", FileMode.Create);
  142. BinaryReader br = new BinaryReader(fs);
  143. BinaryWriter bw = new BinaryWriter(fsout);
  144. Byte[] byData = br.ReadBytes((int)fs.Length);
  145. var t = "NKnFb79Sxk+4Xw284MQleA==";
  146. var pid = "1639047545434X1016017";
  147. fs.Close();
  148. //var iv = new byte[16];
  149. //var key = new byte[16];
  150. //for (int i = 0; i < byData.Length; i++)
  151. //{
  152. // if(i <= 15)
  153. // {
  154. // iv[i] = byData[i];
  155. // var ivx = byData[i].ToString("x");
  156. // Debug.Log(iv[i] + " : " + ivx);
  157. // }
  158. // else
  159. // {
  160. // key[i - 16] = byData[i];
  161. // var keyx = byData[i].ToString("x");
  162. // Debug.Log(key[i - 16] + " : " + keyx);
  163. // }
  164. //}
  165. //var str = DecryptStringFromBytes_Aes(byData, iv, key);
  166. //Debug.Log("result" + str);
  167. Debug.Log(byData.Length);
  168. IList<byte> bData = new List<byte>();
  169. string[] strHexs = new string[16];
  170. int[] intData = {
  171. 245,
  172. 217,
  173. 174,
  174. 210,
  175. 90,
  176. 41,
  177. 167,
  178. 178,
  179. 110,
  180. 47,
  181. 158,
  182. 193,
  183. 35,
  184. 162,
  185. 230,
  186. 97
  187. };
  188. for (int i = 0; i < 16; i++)
  189. {
  190. int a = intData[i];
  191. strHexs[i] = a.ToString("x");
  192. //strHexs[i] = a.ToString();
  193. Debug.Log(a + " : " + a.ToString("x"));
  194. }
  195. foreach (var item in strHexs)
  196. {
  197. Debug.Log(Convert.ToByte(item, 16));
  198. bData.Add(Convert.ToByte(item, 16));
  199. }
  200. bw.Write(bData.ToArray());
  201. fsout.Close();
  202. }
  203. }