ShowModelManager.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TriLibCore;
  4. using UnityEngine;
  5. public class ShowModelManager : MonoBehaviour
  6. {
  7. public GameObject root;
  8. public void Onupdate(string url)
  9. {
  10. if(root!=null)
  11. {
  12. Destroy(root);
  13. }
  14. TriLibModelLoad.Load(url, (AssetLoaderContext ac) => {
  15. ac.RootGameObject.SetActive(false);
  16. //Debug.Log("模型加载完成");
  17. }, (AssetLoaderContext ac) => {
  18. //Debug.Log("载材质加完成");
  19. root = ac.RootGameObject;
  20. ac.RootGameObject.transform.parent = this.transform;
  21. ac.RootGameObject.transform.localPosition = Vector3.zero;
  22. ac.RootGameObject.transform.localEulerAngles = Vector3.zero;
  23. ac.RootGameObject.transform.localScale = Vector3.one;
  24. ac.RootGameObject.SetActive(true);
  25. }, (AssetLoaderContext ac, float f) => {
  26. //Debug.Log("加载中==》" + f);
  27. }, (IContextualizedError error) => {
  28. //Debug.Log("加载失败" + error);
  29. });
  30. }
  31. }