StartLoadOtherModel.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TriLibCore;
  4. using UnityEngine;
  5. public class StartLoadOtherModel : MonoBehaviour
  6. {
  7. public float bz1=0.1f;
  8. public string url;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. TriLibModelLoad.Load(url, (AssetLoaderContext ac) => {
  13. Debug.Log("模型加载完成");
  14. }, (AssetLoaderContext ac) => {
  15. ac.RootGameObject.transform.localEulerAngles = new Vector3(0, 0, 0);
  16. ac.RootGameObject.transform.localPosition = Vector3.zero;
  17. Bounds bounds = GetAllBounds.GetRendererBounds(ac.RootGameObject);
  18. GameObject obj = new GameObject("Test");
  19. obj.transform.position = bounds.center;
  20. obj.transform.SetParent(ac.RootGameObject.transform);
  21. float bizhi = bz1 / bounds.size.x;
  22. ac.RootGameObject.transform.localScale = Vector3.one * bizhi;
  23. ac.RootGameObject.transform.SetParent(this.transform);
  24. ac.RootGameObject.transform.localPosition = Vector3.zero - obj.transform.position ;
  25. ac.RootGameObject.SetActive(true);
  26. }, (AssetLoaderContext ac, float f) => {
  27. Debug.Log("加载中==》" + f);
  28. }, (IContextualizedError error) => {
  29. Debug.Log("加载失败" + error);
  30. });
  31. }
  32. // Update is called once per frame
  33. void Update()
  34. {
  35. }
  36. }