123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using UnityEngine;
- /// <summary>
- /// 可编辑脸部部位
- /// </summary>
- public enum EditableFacePart
- {
- eyebrow,
- eye,
- mousewidth
- }
- /// <summary>
- /// 可编辑身体部位
- /// </summary>
- public enum EditableBodyPart
- {
- UpperArm = 0,
- LowerArm = 1,
- Hand = 2,
- UpperLeg = 3,
- LowerLeg = 4,
- Foot = 5,
- All = 6,
- Neck = 7,
- Clavicle = 8,
- Shoulder = 9,
- Chest = 10,//胸
- Pleural = 11,//胸腔下部
- Belly = 12,//肚子
- UpperArmUp = 13,
- UpperArmDown = 14,
- UpperLegUp = 15,
- UpperLegDown = 16,
- LowerLegUp = 17,
- LowerLegDown = 18,
- Head = 19,
- None = 20,
- }
- /// <summary>
- /// 编辑类型
- /// </summary>
- public enum ModifyType
- {
- Length = 0,//长
- Width = 1,//宽
- Thick = 2,//厚度
- LengthWidthThick = 3,//长宽厚
- Angle = 4,//角度
- UpDown = 5,//上下
- LeftRight = 6,//左右
- ForwardBehind = 7,//前后
- }
- 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<Transform> childList = new List<Transform>();
- 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<byte> bData = new List<byte>();
- 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();
- }
- }
|