TestModelLoader.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using ShadowStudio.Model;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using XRTool.Util;
  7. public class TestModelLoader : MonoBehaviour
  8. {
  9. public ArtType artType;
  10. public int indexOfArt;
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. ArtInfoMgr.Instance.OpenLocalData();
  15. StartCoroutine(Test1());
  16. }
  17. private IEnumerator Test1()
  18. {
  19. yield return Test2();
  20. print("Test1");
  21. }
  22. private IEnumerator Test2()
  23. {
  24. yield return new WaitForSeconds(2);
  25. print("Test2");
  26. }
  27. // Update is called once per frame
  28. void Update()
  29. {
  30. if (Input.GetKeyDown(KeyCode.C))
  31. {
  32. CreateArt(artType, indexOfArt);
  33. }
  34. if (Input.GetKeyDown(KeyCode.F))
  35. {
  36. for (int i = 0; i < ArtInfoMgr.Instance.ArtInfoList.Count; i++)
  37. {
  38. CreateArt(ArtInfoMgr.Instance.ArtInfoList[i]);
  39. }
  40. }
  41. }
  42. private void CreateArt(ArtInfo info)
  43. {
  44. ArtHandler handler = ArtInfoMgr.Instance.CreateArtHandler(info);
  45. handler.CreateArt();
  46. }
  47. private void CreateArt(ArtType artType, int indexOfArt)
  48. {
  49. Debug.Log(artType);
  50. var list = ArtInfoMgr.Instance.GetArtInfoList(artType);
  51. if (list != null)
  52. {
  53. print(list.Count);
  54. if (indexOfArt >= 0 && indexOfArt < list.Count)
  55. {
  56. ArtInfo info = list[indexOfArt];
  57. //print(info.ArtName);
  58. ArtHandler handler = ArtInfoMgr.Instance.CreateArtHandler(info);
  59. //print(handler.GetIcon());
  60. var container = handler.CreateArt();
  61. container.Position = Vector3.zero;
  62. //gameObject.hideFlags = HideFlags.HideAndDontSave;
  63. }
  64. }
  65. else
  66. {
  67. UnityLog.LogError(artType.ToString() + " is null list!");
  68. }
  69. }
  70. }