UnityBaseHandler.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using ShadowStudio.Model;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. namespace ShadowStudio.Model
  7. {
  8. /// <summary>
  9. /// Unity组件,例如Cube,Sphere,Cylinder等基本几何体
  10. /// </summary>
  11. public class UnityBaseHandler : ArtInstanceHandler
  12. {
  13. public override UnityEngine.Object LoadArt()
  14. {
  15. if (!LoadCache && Info != null)
  16. {
  17. int type;
  18. if (int.TryParse(Info.Url, out type))
  19. {
  20. var obj = GameObject.CreatePrimitive((PrimitiveType)type);
  21. if (obj)
  22. {
  23. obj.SetActive(false);
  24. }
  25. LoadCache = obj;
  26. }
  27. }
  28. return LoadCache;
  29. }
  30. public override void LoadArtAsyn(string path, Action<float> process, Action<UnityEngine.Object> loaded)
  31. {
  32. process?.Invoke(1);
  33. loaded?.Invoke(LoadArt());
  34. }
  35. }
  36. }