CustomManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GameFramework.Event;
  5. using UnityEngine;
  6. using GameFramework.DataTable;
  7. using DG.Tweening;
  8. namespace MetaClient
  9. {
  10. public class CustomManager : MonoBehaviour
  11. {
  12. public static CustomManager Instance;
  13. public RoleCustomData bodyData;
  14. public const float valueFloating = 1f;
  15. public CustomRoleController testPlayer = null;
  16. public Dictionary<string, Transform> bones = new Dictionary<string, Transform>();
  17. private void Awake()
  18. {
  19. Instance = this;
  20. }
  21. public void Init()
  22. {
  23. GameEntry.Event.Subscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  24. CreateCustomBodyData();
  25. }
  26. /// <summary>
  27. /// 生成玩家自定义数据信息
  28. /// </summary>
  29. public void CreateCustomBodyData()
  30. {
  31. testPlayer = GameObject.Find("123123").GetComponent<CustomRoleController>();
  32. bodyData = new RoleCustomData();
  33. //初始化身体部分
  34. IDataTable<DRCustomBody> drCB = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  35. DRCustomBody[] dtCB = drCB.GetAllDataRows();
  36. for (int i = 0; i < dtCB.Length; i++)
  37. {
  38. var partData = new PartData(
  39. dtCB[i].Id,
  40. dtCB[i].BoneName.Split(','),
  41. dtCB[i].ScaleRangeMin,
  42. dtCB[i].ScaleRangeMax,
  43. dtCB[i].ScaleChange,
  44. dtCB[i].PositionChange,
  45. dtCB[i].RotationChange,
  46. dtCB[i].IsBlend,
  47. dtCB[i].BiggerBlendName,
  48. dtCB[i].SmallerBlendName,
  49. dtCB[i].DefaultBlendValue,
  50. dtCB[i].ExtraKeepBoneName,
  51. dtCB[i].IsKeepChildrenScale
  52. );
  53. bodyData.bodyList.Add(dtCB[i].Id, partData);
  54. }
  55. //初始化脸部分
  56. IDataTable<DRCustomFace> drCF = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  57. DRCustomFace[] dtCF = drCF.GetAllDataRows();
  58. for (int i = 0; i < dtCF.Length; i++)
  59. {
  60. var partData = new PartData(
  61. dtCF[i].Id,
  62. dtCF[i].BoneName==""?null:dtCF[i].BoneName.Split(','),
  63. dtCF[i].ScaleRangeMin,
  64. dtCF[i].ScaleRangeMax,
  65. dtCF[i].ScaleChange,
  66. dtCF[i].PositionChange,
  67. dtCF[i].RotationChange,
  68. dtCF[i].IsBlend,
  69. dtCF[i].BiggerBlendName,
  70. dtCF[i].SmallerBlendName,
  71. dtCF[i].DefaultBlendValue,
  72. "",
  73. true,
  74. dtCF[i].IsMirror
  75. );
  76. bodyData.faceList.Add(dtCF[i].Id, partData);
  77. }
  78. bones.Clear();
  79. foreach (var item in bodyData.bodyList)
  80. {
  81. var key = item.Key;
  82. var value = item.Value;
  83. if(!value.useBlend)
  84. {
  85. for (int i = 0; i < value.bones.Length; i++)
  86. {
  87. var transform = CustomRoleUtility.GetChild(testPlayer.transform, value.bones[i]);
  88. if (!transform)
  89. {
  90. continue;
  91. }
  92. if (!bones.ContainsKey(value.bones[i]))
  93. {
  94. bones.Add(value.bones[i], transform);
  95. }
  96. }
  97. }
  98. }
  99. foreach (var item in bodyData.faceList)
  100. {
  101. var key = item.Key;
  102. var value = item.Value;
  103. if (!value.useBlend)
  104. {
  105. for (int i = 0; i < value.bones.Length; i++)
  106. {
  107. var transform = CustomRoleUtility.GetChild(testPlayer.transform, value.bones[i]);
  108. if (!transform)
  109. {
  110. continue;
  111. }
  112. if (!bones.ContainsKey(value.bones[i]))
  113. {
  114. bones.Add(value.bones[i], transform);
  115. }
  116. }
  117. }
  118. }
  119. Debug.Log( "一共有"+ bones.Count + "部位的骨骼自定义修改");
  120. //获取自定义骨骼的初始数据
  121. foreach (var item in bones)
  122. {
  123. var key = item.Key;
  124. var value = item.Value;
  125. bodyData.orginLocalScaleList.Add(key, value.localScale);
  126. bodyData.orginChangeScaleList.Add(key, new Vector3(1,1,1));
  127. bodyData.ChangedScaleParamsList.Add(key, new Vector3(1,1,1));
  128. bodyData.orginLocalPositionList.Add(key, value.localPosition);
  129. bodyData.orginLocalRotationList.Add(key, value.localEulerAngles);
  130. }
  131. }
  132. public void Clear()
  133. {
  134. GameEntry.Event.Unsubscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  135. }
  136. private void UpdateBody(object sender, GameEventArgs e)
  137. {
  138. CustomRoleBodyEventArgs crf = (CustomRoleBodyEventArgs)e;
  139. if (crf != null)
  140. {
  141. PartData partData = null;
  142. switch (crf.Type)
  143. {
  144. case ECustomStyple.None:
  145. break;
  146. case ECustomStyple.NieLian:
  147. partData = bodyData.faceList[crf.Part];
  148. break;
  149. case ECustomStyple.Body:
  150. partData = bodyData.bodyList[crf.Part];
  151. break;
  152. case ECustomStyple.Cloth:
  153. break;
  154. case ECustomStyple.Ornament:
  155. break;
  156. default:
  157. break;
  158. }
  159. //更新数据
  160. if(partData == null)
  161. {
  162. Debug.LogError("ID :" + crf.Part + " 无数据");
  163. return;
  164. }
  165. if(partData.useBlend)
  166. {
  167. ChangeBlendShape(partData, crf.ChangeValue);
  168. }
  169. else
  170. {
  171. ChangeBone(partData, crf.ChangeValue);
  172. }
  173. }
  174. }
  175. /// <summary>
  176. /// 变形器改变
  177. /// </summary>
  178. /// <param name="partData"></param>
  179. /// <param name="changeValue"></param>
  180. private void ChangeBlendShape(PartData partData, Vector3 changeValue)
  181. {
  182. partData.floatValue = changeValue.x;
  183. Debug.Log(partData.id + " : "+ partData.floatValue);
  184. if(partData.oneBlend)
  185. {
  186. RefreshRoleBlendShape(partData.biggerBlendName, partData.floatValue * 100);
  187. return;
  188. }
  189. if(partData.floatValue == 0.5f)
  190. {
  191. RefreshRoleBlendShape(partData.biggerBlendName, 0);
  192. RefreshRoleBlendShape(partData.smallerBlendName, 0);
  193. }
  194. if(partData.floatValue > 0.5f)
  195. {
  196. RefreshRoleBlendShape(partData.biggerBlendName, (partData.floatValue - 0.5f) * 2 * 100);
  197. RefreshRoleBlendShape(partData.smallerBlendName, 0);
  198. }
  199. if(partData.floatValue < 0.5f)
  200. {
  201. RefreshRoleBlendShape(partData.biggerBlendName, 0);
  202. RefreshRoleBlendShape(partData.smallerBlendName, (0.5f - partData.floatValue) * 2 * 100);
  203. }
  204. }
  205. /// <summary>
  206. /// 骨骼改变
  207. /// </summary>
  208. /// <param name="partData"></param>
  209. /// <param name="changeValue"></param>
  210. private void ChangeBone(PartData partData,Vector3 changeValue)
  211. {
  212. if (partData.scaleChange != Vector3.zero)
  213. {
  214. if (changeValue.x == 0.5f)
  215. {
  216. partData.floatValue = 1;
  217. }
  218. if (changeValue.x < 0.5f)
  219. {
  220. partData.floatValue = partData.minChangeValue + (1 - partData.minChangeValue) * (changeValue.x / 0.5f);
  221. }
  222. if (changeValue.x > 0.5f)
  223. {
  224. partData.floatValue = 1 + (partData.maxChangeValue - 1) * ((changeValue.x - 0.5f) / 0.5f);
  225. }
  226. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  227. for (int i = 0; i < partData.bones.Length; i++)
  228. {
  229. //var orginBoneScale = bodyData.orginWorldScaleList[partData.bones[i]];
  230. var orginBoneScale = bodyData.orginLocalScaleList[partData.bones[i]];
  231. var changeScale = bodyData.orginChangeScaleList[partData.bones[i]];
  232. var bone = bones[partData.bones[i]];
  233. var nowBone = bones[partData.bones[i]];
  234. //var scale = nowBone.lossyScale;
  235. var scale = nowBone.localScale;
  236. var nowScale = new Vector3(scale.x / orginBoneScale.x, scale.y / orginBoneScale.y, scale.z / orginBoneScale.z);
  237. //var newBoneScale = new Vector3(orginBoneScale.x * (partData.scaleChange.x == 1 ? partData.floatValue : 1) * nowScale.x, orginBoneScale.y * (partData.scaleChange.y == 1 ? partData.floatValue : 1) * nowScale.y, orginBoneScale.z * (partData.scaleChange.z == 1 ? partData.floatValue : 1) * nowScale.y);
  238. var newBoneScale = new Vector3(
  239. partData.scaleChange.x == 1 ? partData.floatValue * orginBoneScale.x * changeScale.x : scale.x,
  240. partData.scaleChange.y == 1 ? partData.floatValue * orginBoneScale.y * changeScale.y : scale.y,
  241. partData.scaleChange.z == 1 ? partData.floatValue * orginBoneScale.z * changeScale.z : scale.z
  242. );
  243. bodyData.changedScaleList[partData.bones[i]] = newBoneScale;
  244. bodyData.ChangedScaleParamsList[partData.bones[i]] = new Vector3(newBoneScale.x / orginBoneScale.x / changeScale.x, newBoneScale.y / orginBoneScale.y / changeScale.y, newBoneScale.z / orginBoneScale.z / changeScale.z);
  245. Debug.Log(partData.bones[i] + " : " + bodyData.ChangedScaleParamsList[partData.bones[i]]);
  246. if(!partData.keepChild)
  247. {
  248. continue;
  249. }
  250. //子物体
  251. var count = nowBone.childCount;
  252. for (int j = 0; j < count; j++)
  253. {
  254. var childname = nowBone.GetChild(j).name;
  255. if (bones.ContainsKey(childname))
  256. {
  257. var orginChildBoneScale = bodyData.orginLocalScaleList[childname];
  258. var beforeChildScaleParams = bodyData.ChangedScaleParamsList[childname];
  259. bodyData.orginChangeScaleList[childname] = new Vector3(orginBoneScale.x / newBoneScale.x, orginBoneScale.y / newBoneScale.y, orginBoneScale.z / newBoneScale.z);
  260. bodyData.changedScaleList[childname] = new Vector3(
  261. beforeChildScaleParams.x * bodyData.orginChangeScaleList[childname].x * orginChildBoneScale.x,
  262. beforeChildScaleParams.y * bodyData.orginChangeScaleList[childname].y * orginChildBoneScale.y,
  263. beforeChildScaleParams.z * bodyData.orginChangeScaleList[childname].z * orginChildBoneScale.z
  264. );
  265. Debug.Log(childname + " : " + bodyData.ChangedScaleParamsList[childname]);
  266. }
  267. }
  268. if (partData.extraBones == null || partData.extraBones.Length == 0)
  269. {
  270. continue;
  271. }
  272. for (int j = 0; j < partData.extraBones.Length; j++)
  273. {
  274. var childname = partData.extraBones[j];
  275. if (bones.ContainsKey(childname))
  276. {
  277. var orginChildBoneScale = bodyData.orginLocalScaleList[childname];
  278. var beforeChildScaleParams = bodyData.ChangedScaleParamsList[childname];
  279. bodyData.orginChangeScaleList[childname] = new Vector3(orginBoneScale.x / newBoneScale.x, orginBoneScale.y / newBoneScale.y, orginBoneScale.z / newBoneScale.z);
  280. bodyData.changedScaleList[childname] = new Vector3(
  281. beforeChildScaleParams.x * bodyData.orginChangeScaleList[childname].x * orginChildBoneScale.x,
  282. beforeChildScaleParams.y * bodyData.orginChangeScaleList[childname].y * orginChildBoneScale.y,
  283. beforeChildScaleParams.z * bodyData.orginChangeScaleList[childname].z * orginChildBoneScale.z
  284. );
  285. Debug.Log(childname + " : " + bodyData.ChangedScaleParamsList[childname]);
  286. }
  287. }
  288. }
  289. }
  290. //修改位置
  291. if (partData.positionChange != Vector3.zero)
  292. {
  293. if (changeValue.x == 0.5f)
  294. {
  295. partData.floatValue = 0;
  296. }
  297. if (changeValue.x < 0.5f)
  298. {
  299. partData.floatValue = partData.minChangeValue * (0.5f - changeValue.x) * 2;
  300. }
  301. if (changeValue.x > 0.5f)
  302. {
  303. partData.floatValue = partData.maxChangeValue * (changeValue.x - 0.5f) * 2;
  304. }
  305. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  306. for (int i = 0; i < partData.bones.Length; i++)
  307. {
  308. var nowBone = bones[partData.bones[i]];
  309. var orginBonePosition = bodyData.orginLocalPositionList[partData.bones[i]];
  310. var newBonePosition = new Vector3(
  311. partData.positionChange.x == 1 ? partData.floatValue + orginBonePosition.x : orginBonePosition.x,
  312. partData.positionChange.y == 1 ? partData.floatValue + orginBonePosition.y : orginBonePosition.y,
  313. partData.positionChange.z == 1 ? partData.floatValue + orginBonePosition.z : orginBonePosition.z
  314. );
  315. bodyData.changedPositionList[partData.bones[i]] = newBonePosition;
  316. }
  317. }
  318. //修改旋转
  319. if (partData.rotationChange != Vector3.zero)
  320. {
  321. if (changeValue.x == 0.5f)
  322. {
  323. partData.floatValue = 0;
  324. }
  325. if (changeValue.x < 0.5f)
  326. {
  327. partData.floatValue = partData.minChangeValue * (0.5f - changeValue.x) * 2;
  328. }
  329. if (changeValue.x > 0.5f)
  330. {
  331. partData.floatValue = partData.maxChangeValue * (changeValue.x - 0.5f) * 2;
  332. }
  333. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  334. for (int i = 0; i < partData.bones.Length; i++)
  335. {
  336. var changeVal = 1;
  337. if(i == 1 && partData.isMirror)
  338. {
  339. changeVal = -1;
  340. }
  341. var nowBone = bones[partData.bones[i]];
  342. var rotate = nowBone.localEulerAngles;
  343. var orginBoneRot = bodyData.orginLocalRotationList[partData.bones[i]];
  344. var newBoneRot = new Vector3(
  345. partData.rotationChange.x == 1 ? changeVal * partData.floatValue + orginBoneRot.x : rotate.x,
  346. partData.rotationChange.y == 1 ? changeVal * partData.floatValue + orginBoneRot.y : rotate.y,
  347. partData.rotationChange.z == 1 ? changeVal * partData.floatValue + orginBoneRot.z : rotate.z
  348. );
  349. bodyData.changedRotationList[partData.bones[i]] = newBoneRot;
  350. }
  351. }
  352. RefreshRoleBone();
  353. }
  354. public float GetBodyBoneValue(ECustomStyple styple,int id)
  355. {
  356. PartData partData = null;
  357. switch (styple)
  358. {
  359. case ECustomStyple.None:
  360. break;
  361. case ECustomStyple.NieLian:
  362. partData = bodyData.faceList[id];
  363. break;
  364. case ECustomStyple.Body:
  365. partData = bodyData.bodyList[id];
  366. break;
  367. case ECustomStyple.Cloth:
  368. break;
  369. case ECustomStyple.Ornament:
  370. break;
  371. default:
  372. break;
  373. }
  374. if(partData == null)
  375. {
  376. return 0;
  377. }
  378. Debug.Log(partData.id + " :" + partData.useBlend + " : " + partData.floatValue);
  379. if (partData.useBlend)
  380. {
  381. return partData.floatValue;
  382. }
  383. Debug.Log(id +": GetBodyBoneValue + " + partData.scaleChange + " " + partData.floatValue);
  384. if (partData.scaleChange.x == 1 || partData.scaleChange.y == 1 || partData.scaleChange.z == 1)
  385. {
  386. if (partData.floatValue == 1)
  387. {
  388. return 0.5f;
  389. }
  390. if (partData.floatValue < 1)
  391. {
  392. return (partData.floatValue - partData.minChangeValue) / (1 - partData.minChangeValue)/2;
  393. }
  394. if (partData.floatValue > 1)
  395. {
  396. return 0.5f + (partData.floatValue - 1) / (partData.maxChangeValue - 1)/2;
  397. }
  398. }
  399. if (partData.positionChange.x == 1 || partData.positionChange.y == 1 || partData.positionChange.z == 1)
  400. {
  401. if (partData.floatValue == 0)
  402. {
  403. return 0.5f;
  404. }
  405. if (partData.floatValue < 0)
  406. {
  407. return partData.floatValue / partData.maxChangeValue/2;
  408. }
  409. if (partData.floatValue > 0)
  410. {
  411. return 0.5f + partData.floatValue / partData.maxChangeValue / 2;
  412. }
  413. }
  414. if (partData.rotationChange.x == 1 || partData.rotationChange.y == 1 || partData.rotationChange.z == 1)
  415. {
  416. if (partData.floatValue == 0)
  417. {
  418. return 0.5f;
  419. }
  420. if (partData.floatValue < 0)
  421. {
  422. return partData.floatValue / partData.maxChangeValue / 2;
  423. }
  424. if (partData.floatValue > 0)
  425. {
  426. return 0.5f + partData.floatValue / partData.maxChangeValue / 2;
  427. }
  428. }
  429. return 0.5f;
  430. }
  431. /// <summary>
  432. /// 重置角色数据
  433. /// </summary>
  434. public void ResetRole()
  435. {
  436. if(testPlayer == null)
  437. {
  438. Debug.LogError("没有模型存在");
  439. return;
  440. }
  441. Debug.Log("重置模型");
  442. foreach (var item in bodyData.bodyList)
  443. {
  444. var key = item.Key;
  445. var value = item.Value;
  446. if(value.useBlend)
  447. {
  448. value.floatValue = 0;
  449. }
  450. else
  451. {
  452. value.floatValue = 1;
  453. }
  454. }
  455. //重置缩放
  456. foreach (var item in bodyData.orginLocalScaleList)
  457. {
  458. var key = item.Key;
  459. var value = item.Value;
  460. testPlayer.SetBoneScale(key, value);
  461. //testPlayer.SetBoneWorldScale(key, value);
  462. if (bodyData.changedScaleList.ContainsKey(key))
  463. {
  464. bodyData.changedScaleList[key] = bodyData.orginLocalScaleList[key];
  465. }
  466. bodyData.orginChangeScaleList[key] = new Vector3(1, 1, 1);
  467. bodyData.ChangedScaleParamsList[key] = new Vector3(1, 1, 1);
  468. }
  469. //重置旋转
  470. foreach (var item in bodyData.orginLocalRotationList)
  471. {
  472. var key = item.Key;
  473. var value = item.Value;
  474. testPlayer.SetBoneRot(key, value);
  475. }
  476. //重置位置
  477. foreach (var item in bodyData.orginLocalPositionList)
  478. {
  479. var key = item.Key;
  480. var value = item.Value;
  481. testPlayer.SetBonePos(key, value);
  482. }
  483. testPlayer.ResetAllBlendShape();
  484. }
  485. public void RefreshRoleBlendShape(string name,float value)
  486. {
  487. if (testPlayer == null)
  488. {
  489. Debug.LogError("没有模型存在");
  490. return;
  491. }
  492. testPlayer.SetBlendShape(name, value);
  493. }
  494. public void RefreshRoleBone()
  495. {
  496. if (testPlayer == null)
  497. {
  498. Debug.LogError("没有模型存在");
  499. return;
  500. }
  501. Debug.Log("刷新模型");
  502. //刷新缩放
  503. //foreach (var item in bodyData.orginLocalScaleList)
  504. //{
  505. // var key = item.Key;
  506. // var value = item.Value;
  507. // if(bodyData.changedScaleList.ContainsKey(key))
  508. // {
  509. // testPlayer.SetBoneScale(key, bodyData.changedScaleList[key]);
  510. // }
  511. // else
  512. // {
  513. // testPlayer.SetBoneScale(key, value);
  514. // }
  515. //}
  516. foreach (var item in bodyData.changedScaleList)
  517. {
  518. var key = item.Key;
  519. var value = item.Value;
  520. //testPlayer.SetBoneWorldScale(key, value, bodyData.orginLocalScaleList[key], bodyData.orginWorldScaleList[key]);
  521. testPlayer.SetBoneScale(key, value);
  522. }
  523. foreach (var item in bodyData.changedPositionList)
  524. {
  525. var key = item.Key;
  526. var value = item.Value;
  527. testPlayer.SetBonePos(key, value);
  528. }
  529. foreach (var item in bodyData.changedRotationList)
  530. {
  531. var key = item.Key;
  532. var value = item.Value;
  533. testPlayer.SetBoneRot(key, value);
  534. }
  535. }
  536. /// <summary>
  537. /// 旋转模特
  538. /// </summary>
  539. public void RotateModel(float offset)
  540. {
  541. if (testPlayer == null)
  542. {
  543. Debug.LogError("没有模型存在");
  544. return;
  545. }
  546. testPlayer.RotateSelf(offset);
  547. }
  548. public void ChangeCustomCamera(ECustomStyple type)
  549. {
  550. switch (type)
  551. {
  552. case ECustomStyple.None:
  553. break;
  554. case ECustomStyple.NieLian:
  555. Camera.main.transform.DOMove(new Vector3(-0.26f, 0.4f, -5), 0.3f);
  556. Camera.main.DOOrthoSize(0.25f, 0.3f);
  557. break;
  558. case ECustomStyple.Body:
  559. case ECustomStyple.Cloth:
  560. Camera.main.transform.DOMove(new Vector3(0, -0.24f, -5), 0.3f);
  561. Camera.main.DOOrthoSize(1.5f, 0.3f);
  562. break;
  563. case ECustomStyple.Ornament:
  564. break;
  565. default:
  566. break;
  567. }
  568. }
  569. public void ChangeClothing(int id)
  570. {
  571. Debug.Log("换衣服咯 : " + id);
  572. IDataTable<DRClothing> drCloth = GameEntry.DataTable.GetDataTable<DRClothing>();
  573. DRClothing clothdata = drCloth.GetDataRow(id);
  574. if(clothdata == null)
  575. {
  576. Debug.LogError("cloth " + id + "不存在");
  577. return;
  578. }
  579. var path = clothdata.Prefab;
  580. GameEntry.Resource.LoadAsset(AssetUtility.GetMeshAsset(path), new GameFramework.Resource.LoadAssetCallbacks(
  581. (assetName, asset, duration, userData) =>
  582. {
  583. GameObject go = GameObject.Instantiate((GameObject)asset, testPlayer.transform);
  584. var component = testPlayer.GetComponent<CombineSkinMesh>();
  585. component.ChangeCloth((ClothType)clothdata.ParentStyple, go);
  586. }
  587. ));
  588. }
  589. /// <summary>
  590. /// 保存
  591. /// </summary>
  592. public void Save()
  593. {
  594. }
  595. /// <summary>
  596. /// 加载
  597. /// </summary>
  598. public void Reload()
  599. {
  600. }
  601. }
  602. }