using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using UnityEngine; /// /// 可编辑脸部部位 /// public enum EditableFacePart { eyebrow, eye, mousewidth } /// /// 可编辑身体部位 /// public enum EditableBodyPart { UpperArm, LowerArm, Hand, UpperLeg, LowerLeg, Foot, None } /// /// 编辑类型 /// public enum ModifyType { Length,//长 Width,//宽 Thick,//厚度 Angle,//角度 Color,//颜色 Sprite,//贴图 Height,//高度 } public static class CustomRoleUtility { public static void UpdateBoneScale(Animator ani,EditableBodyPart part,float value) { Transform transL = null; Transform transR = null; Vector3 beforeScale = Vector3.one; List childList = new List(); bool keepChildWorldScale = false; switch (part) { case EditableBodyPart.UpperArm: transL = ani.GetBoneTransform(HumanBodyBones.LeftUpperArm); transR = ani.GetBoneTransform(HumanBodyBones.RightUpperArm); keepChildWorldScale = true; break; case EditableBodyPart.LowerArm: transL = ani.GetBoneTransform(HumanBodyBones.LeftLowerArm); transR = ani.GetBoneTransform(HumanBodyBones.RightLowerArm); break; case EditableBodyPart.Hand: transL = ani.GetBoneTransform(HumanBodyBones.LeftHand); transR = ani.GetBoneTransform(HumanBodyBones.RightHand); break; case EditableBodyPart.UpperLeg: transL = ani.GetBoneTransform(HumanBodyBones.LeftUpperLeg); transR = ani.GetBoneTransform(HumanBodyBones.RightUpperLeg); keepChildWorldScale = true; break; case EditableBodyPart.LowerLeg: transL = ani.GetBoneTransform(HumanBodyBones.LeftLowerLeg); transR = ani.GetBoneTransform(HumanBodyBones.RightLowerLeg); break; case EditableBodyPart.Foot: transL = ani.GetBoneTransform(HumanBodyBones.LeftFoot); transR = ani.GetBoneTransform(HumanBodyBones.RightFoot); break; case EditableBodyPart.None: break; default: break; } if(transL != null) { beforeScale = transL.localScale; var world_l = transL.lossyScale; transL.SetLocalScaleX(transL.localScale.x * value / world_l.x); transL.SetLocalScaleY(transL.localScale.y * value / world_l.y); transL.SetLocalScaleZ(transL.localScale.z * value / world_l.z); var lcount = transL.childCount; for (int i = 0; i < lcount; i++) { childList.Add(transL.GetChild(i)); } } if(transR != null) { beforeScale = transR.localScale; var world_r = transR.lossyScale; transR.SetLocalScaleX(transR.localScale.x * value / world_r.x); transR.SetLocalScaleY(transR.localScale.y * value / world_r.y); transR.SetLocalScaleZ(transR.localScale.z * value / world_r.z); var rcount = transR.childCount; for (int i = 0; i < rcount; i++) { childList.Add(transR.GetChild(i)); } } if(!keepChildWorldScale) { return; } for (int i = 0; i < childList.Count; i++) { var childTrans = childList[i]; var oldScale = childTrans.localScale; childTrans.SetLocalScaleX(oldScale.x * beforeScale.x / value); childTrans.SetLocalScaleY(oldScale.y * beforeScale.y / value); childTrans.SetLocalScaleZ(oldScale.z * beforeScale.z / value); } } public static void ShowFile() { FileStream fs = File.Open("E:/key.key", FileMode.Open); FileStream fsout = File.Open("E:/keyout9.key", FileMode.Create); BinaryReader br = new BinaryReader(fs); BinaryWriter bw = new BinaryWriter(fsout); Byte[] byData = br.ReadBytes((int)fs.Length); var t = "NKnFb79Sxk+4Xw284MQleA=="; var pid = "1639047545434X1016017"; fs.Close(); //var iv = new byte[16]; //var key = new byte[16]; //for (int i = 0; i < byData.Length; i++) //{ // if(i <= 15) // { // iv[i] = byData[i]; // var ivx = byData[i].ToString("x"); // Debug.Log(iv[i] + " : " + ivx); // } // else // { // key[i - 16] = byData[i]; // var keyx = byData[i].ToString("x"); // Debug.Log(key[i - 16] + " : " + keyx); // } //} //var str = DecryptStringFromBytes_Aes(byData, iv, key); //Debug.Log("result" + str); Debug.Log(byData.Length); IList bData = new List(); string[] strHexs = new string[16]; int[] intData = { 245, 217, 174, 210, 90, 41, 167, 178, 110, 47, 158, 193, 35, 162, 230, 97 }; for (int i = 0; i < 16; i++) { int a = intData[i]; strHexs[i] = a.ToString("x"); //strHexs[i] = a.ToString(); Debug.Log(a + " : " + a.ToString("x")); } foreach (var item in strHexs) { Debug.Log(Convert.ToByte(item, 16)); bData.Add(Convert.ToByte(item, 16)); } bw.Write(bData.ToArray()); fsout.Close(); } }