Modellnterpret.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEditor;
  2. using UnityEngine;
  3. using System;
  4. using System.IO;
  5. namespace James.Editor {
  6. public class CustomizeAnim {
  7. public string name;
  8. public int start;
  9. public int end;
  10. public CustomizeAnim() { }
  11. }
  12. public class ModelInterpret {
  13. public CustomizeAnim[] anims;
  14. public string abName;
  15. public string abPath;
  16. public ModelInterpret() { }
  17. }
  18. //读取配置模型的配置
  19. public class ModelInterpretor {
  20. public static ModelInterpret read(string HowToClipCfgPath) {
  21. ModelInterpret mi = new ModelInterpret();
  22. if (!string.IsNullOrEmpty(HowToClipCfgPath)) {
  23. TextAsset textAsset = AssetDatabase.LoadAssetAtPath(HowToClipCfgPath, typeof(TextAsset)) as TextAsset;
  24. string line = textAsset.text;
  25. try {
  26. mi = UnityEngine.JsonUtility.FromJson<ModelInterpret>(line);
  27. //delete after read
  28. string jsonFile = Directory.GetCurrentDirectory() + "/" + HowToClipCfgPath;
  29. if (File.Exists(jsonFile))
  30. File.Delete(jsonFile);
  31. }
  32. catch (Exception ex)
  33. {
  34. Debug.Log(ex.ToString());
  35. }
  36. }
  37. return mi;
  38. }
  39. }
  40. }