|
@@ -1,6 +1,7 @@
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using TriLibCore;
|
|
|
using UnityEngine;
|
|
|
using XRTool.Util;
|
|
|
|
|
@@ -288,33 +289,91 @@ namespace ShadowStudio.Model
|
|
|
{
|
|
|
if (IsNeedLoad())
|
|
|
{
|
|
|
- LoadArtAsyn("", container.UpdateProcess, (obj) =>
|
|
|
+ if(container is ModelContainer)
|
|
|
{
|
|
|
- if (IsNeedInstance())
|
|
|
- {
|
|
|
- obj = InstanceArt();
|
|
|
- }
|
|
|
- if (obj is GameObject)
|
|
|
- {
|
|
|
- if (!(obj as GameObject).activeSelf)
|
|
|
+ bool isLoaded=false;
|
|
|
+ AssetLoaderContext asc = null;
|
|
|
+ TriLibModelLoad.Load(info.Url, (AssetLoaderContext ac) => {
|
|
|
+ isLoaded = true;
|
|
|
+ Debug.Log("模型加载完成");
|
|
|
+ ChangeLayerRecursively(ac.RootGameObject.transform);
|
|
|
+ container.AddToContainer(ac.RootGameObject, info);
|
|
|
+ var artComponent = InstanceComponent();
|
|
|
+ container.AddArtComponent(artComponent);
|
|
|
+ if (artComponent != null)
|
|
|
+ {
|
|
|
+ artComponent.SetContainer(container as ArtContainerHandler, ac.RootGameObject, info);
|
|
|
+ }
|
|
|
+ }, (AssetLoaderContext ac) => {
|
|
|
+ Debug.Log("载材质加完成");
|
|
|
+
|
|
|
+ }, (AssetLoaderContext ac, float f) => {
|
|
|
+ asc = ac;
|
|
|
+ container.UpdateProcess(f);
|
|
|
+ Debug.Log("开始加载 ParseModel_Coroutine" + f);
|
|
|
+ }, (IContextualizedError error) => {
|
|
|
+ isLoaded = true;
|
|
|
+ }, (container as ModelContainer).ModelRoot.gameObject);
|
|
|
+ Timer t = null;
|
|
|
+ t = TimerMgr.Instance.CreateTimer(()=> {
|
|
|
+ if(!isLoaded&& container!=null&& (container as ModelContainer).ModelRoot!=null)
|
|
|
{
|
|
|
- (obj as GameObject).SetActive(true);
|
|
|
+ (container as ModelContainer).CalculateRendererBounds(true);
|
|
|
+ ChangeLayerRecursively((container as ModelContainer).ModelRoot);
|
|
|
}
|
|
|
- }
|
|
|
- container.AddToContainer(obj, info);
|
|
|
- var artComponent = InstanceComponent();
|
|
|
- container.AddArtComponent(artComponent);
|
|
|
- if (artComponent != null)
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TimerMgr.Instance.DestroyTimer(t);
|
|
|
+ }
|
|
|
+ },1,-1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ LoadArtAsyn("", container.UpdateProcess, (obj) =>
|
|
|
{
|
|
|
- artComponent.SetContainer(container as ArtContainerHandler, obj, info);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (IsNeedInstance())
|
|
|
+ {
|
|
|
+ obj = InstanceArt();
|
|
|
+ }
|
|
|
+ if (obj is GameObject)
|
|
|
+ {
|
|
|
+ if (!(obj as GameObject).activeSelf)
|
|
|
+ {
|
|
|
+ (obj as GameObject).SetActive(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ container.AddToContainer(obj, info);
|
|
|
+ var artComponent = InstanceComponent();
|
|
|
+ container.AddArtComponent(artComponent);
|
|
|
+ if (artComponent != null)
|
|
|
+ {
|
|
|
+ artComponent.SetContainer(container as ArtContainerHandler, obj, info);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
container.SetArtHandler(this);
|
|
|
OnCreateArt?.Invoke(ArtDisPlay);
|
|
|
return container;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void ChangeLayerRecursively(Transform parentTransform)
|
|
|
+ {
|
|
|
+
|
|
|
+ parentTransform.gameObject.layer = LayerMask.NameToLayer("Arrow");
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < parentTransform.childCount; i++)
|
|
|
+ {
|
|
|
+ Transform childTransform = parentTransform.GetChild(i);
|
|
|
+ ChangeLayerRecursively(childTransform);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|