|
@@ -27,15 +27,15 @@ public class TemplateModel : BaseTemPlate
|
|
|
{
|
|
|
if (m_ModelObj && m_ModelObj.GetComponent<Animation>())
|
|
|
{
|
|
|
- Debug.Log("Animation===>1"+ m_ModelObj.name);
|
|
|
+ Debug.Log("Animation===>1" + m_ModelObj.name);
|
|
|
|
|
|
Animation _animation = m_ModelObj.GetComponent<Animation>();
|
|
|
List<AnimationClip> _animations = _animation.GetAllAnimationClips();
|
|
|
m_ModelObj.GetComponent<Animation>().Play(_animations[0].name, PlayMode.StopAll);
|
|
|
}
|
|
|
}
|
|
|
- if(this.gameObject.GetComponent<AudioSource>())
|
|
|
- this.gameObject.GetComponent<AudioSource>().Play();
|
|
|
+ if (this.gameObject.GetComponent<AudioSource>())
|
|
|
+ this.gameObject.GetComponent<AudioSource>().Play();
|
|
|
}
|
|
|
|
|
|
private IEnumerator LoadModel()
|
|
@@ -44,7 +44,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
if (GameManager.Instance.IsRuning && m_ModelObj == null)
|
|
|
{
|
|
|
|
|
|
- Debug.Log("DGJ ==>> "+Data.localLoadPath);
|
|
|
+ Debug.Log("DGJ ==>> " + Data.localLoadPath);
|
|
|
var ab = AssetBundle.LoadFromFileAsync(Data.localLoadPath);
|
|
|
yield return ab;
|
|
|
if (ab == null)
|
|
@@ -75,15 +75,15 @@ public class TemplateModel : BaseTemPlate
|
|
|
{
|
|
|
Debug.LogError(" GHZ_OOBE_230721 物体加载失败,请查看是否导入相关Packages ");
|
|
|
obj = new GameObject();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- m_ModelObj = GameObject.Instantiate(obj,transform);
|
|
|
+ m_ModelObj = GameObject.Instantiate(obj, transform);
|
|
|
m_ModelObj.name = "GongYe";
|
|
|
|
|
|
- if (GameObject.Find("AudioManager") ==null)
|
|
|
+ if (GameObject.Find("AudioManager") == null)
|
|
|
{
|
|
|
GameObject audio = Resources.Load<GameObject>("AudioManager");
|
|
|
- if(audio ==null)
|
|
|
+ if (audio == null)
|
|
|
{
|
|
|
Debug.LogError(" GHZ_OOBE_230721 Packages内AudioManager组件丢失");
|
|
|
audio = new GameObject();
|
|
@@ -102,7 +102,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -114,7 +114,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
ab.assetBundle.Unload(false);
|
|
|
HideCollider();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -129,7 +129,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
}
|
|
|
public void LoadModel(AssetBundle ab)
|
|
|
{
|
|
|
- GameManager.Instance.StartCoroutine(LoadABModel(ab));
|
|
|
+ GameManager.Instance.StartCoroutine(LoadABModel(ab));
|
|
|
|
|
|
}
|
|
|
private IEnumerator LoadABModel(AssetBundle ab)
|
|
@@ -189,7 +189,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
|
|
|
gameObject.AddComponent<ManipulationHandler>();
|
|
|
gameObject.AddComponent<BoundingBox>();
|
|
|
-
|
|
|
+
|
|
|
ab.Unload(false);
|
|
|
HideCollider();
|
|
|
ModelItem.isLoad = false;
|
|
@@ -201,16 +201,16 @@ public class TemplateModel : BaseTemPlate
|
|
|
base.OnAwake();
|
|
|
}
|
|
|
|
|
|
- public override void SetData(MaterialObjValue value, int updateTime)
|
|
|
+ public override void SetData(MaterialObjValue value, long updateTime)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
base.SetData(value, updateTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (!GameManager.Instance.IsRuning|| Data == null)
|
|
|
+ if (!GameManager.Instance.IsRuning || Data == null)
|
|
|
{
|
|
|
|
|
|
|
|
@@ -219,7 +219,7 @@ public class TemplateModel : BaseTemPlate
|
|
|
this.Data = data;
|
|
|
data.downLoadPath = value.DownloadPath;
|
|
|
data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(value.DownloadPath);
|
|
|
- data.updataTime = GameManager.Instance.m_SceneValue.updateTime;
|
|
|
+ data.updataTime = updateTime;
|
|
|
data.type = "3";
|
|
|
MsgHandler.AddListener(value.DownloadPath, HandleMsg);
|
|
|
DownloadResManager.Instance.DownLoad(data);
|
|
@@ -253,14 +253,14 @@ public class TemplateModel : BaseTemPlate
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void HandleMsg(Msg msg)
|
|
|
{
|
|
|
Debug.Log("DGJ TemplateModel ");
|
|
|
|
|
|
- if(msg.Value!=null)
|
|
|
+ if (msg.Value != null)
|
|
|
{
|
|
|
if (IsAB())
|
|
|
LoadABModel();
|
|
@@ -284,8 +284,8 @@ public class TemplateModel : BaseTemPlate
|
|
|
bool finish = false;
|
|
|
|
|
|
string fileName = Path.GetFileName(Data.localLoadPath);
|
|
|
- Debug.Log("HJJ fileName===>"+ fileName);
|
|
|
- if(fileName.Contains(".ghb") ||!fileName.Contains("."))
|
|
|
+ Debug.Log("HJJ fileName===>" + fileName);
|
|
|
+ if (fileName.Contains(".ghb") || !fileName.Contains("."))
|
|
|
{
|
|
|
finish = true;
|
|
|
}
|
|
@@ -295,20 +295,83 @@ public class TemplateModel : BaseTemPlate
|
|
|
|
|
|
private void LoadABModel()
|
|
|
{
|
|
|
- AssetBundle ab = AssetBundle.LoadFromFile(Data.localLoadPath);
|
|
|
- if (ab == null)
|
|
|
+
|
|
|
+ GameManager.Instance.StartCoroutine(LoadABModelNew());
|
|
|
+
|
|
|
+ }
|
|
|
+ static Dictionary<string,GameObject> loadPathstatic = new Dictionary<string, GameObject>();
|
|
|
+ private IEnumerator LoadABModelNew()
|
|
|
+ {
|
|
|
+
|
|
|
+ AssetBundleCreateRequest ab = AssetBundle.LoadFromFileAsync(Data.localLoadPath);
|
|
|
+ yield return ab;
|
|
|
+ if (ab.assetBundle == null)
|
|
|
{
|
|
|
Debug.Log("Failed to load AssetBundle!");
|
|
|
- return;
|
|
|
+ yield return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AssetBundleRequest golist = ab.assetBundle.LoadAllAssetsAsync<GameObject>();
|
|
|
+ yield return golist;
|
|
|
+
|
|
|
+ AssetBundleRequest assetrequest = ab.assetBundle.LoadAssetAsync<GameObject>(golist.allAssets[0].name);
|
|
|
+ yield return assetrequest;
|
|
|
+ GameObject prefab = (GameObject)assetrequest.asset;
|
|
|
+ m_ModelObj = Instantiate(prefab, transform);
|
|
|
+ ab.assetBundle.Unload(false);
|
|
|
+
|
|
|
+ ManipulationHandler manipulation = gameObject.AddComponent<ManipulationHandler>();
|
|
|
+ manipulation.enabled = false;
|
|
|
+ BoundingBox boundingBox = gameObject.AddComponent<BoundingBox>();
|
|
|
+ boundingBox.enabled = false;
|
|
|
+
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ if(loadPathstatic.ContainsKey(Data.localLoadPath))
|
|
|
+ {
|
|
|
+ while(!loadPathstatic[Data.localLoadPath])
|
|
|
+ {
|
|
|
+ yield return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ GameObject prefab = (GameObject)loadPathstatic[Data.localLoadPath];
|
|
|
+ m_ModelObj = Instantiate(prefab, transform);
|
|
|
+ ManipulationHandler manipulation = gameObject.AddComponent<ManipulationHandler>();
|
|
|
+ manipulation.enabled = false;
|
|
|
+ BoundingBox boundingBox = gameObject.AddComponent<BoundingBox>();
|
|
|
+ boundingBox.enabled = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ loadPathstatic.Add(Data.localLoadPath,null);
|
|
|
+ AssetBundleCreateRequest ab = AssetBundle.LoadFromFileAsync(Data.localLoadPath);
|
|
|
+ yield return ab;
|
|
|
+ if (ab.assetBundle == null)
|
|
|
+ {
|
|
|
+ Debug.Log("Failed to load AssetBundle!");
|
|
|
+ yield return null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AssetBundleRequest golist = ab.assetBundle.LoadAllAssetsAsync<GameObject>();
|
|
|
+ yield return golist;
|
|
|
+
|
|
|
+ AssetBundleRequest assetrequest = ab.assetBundle.LoadAssetAsync<GameObject>(golist.allAssets[0].name);
|
|
|
+ yield return assetrequest;
|
|
|
+ loadPathstatic[Data.localLoadPath]= (GameObject)assetrequest.asset;
|
|
|
+ GameObject prefab = (GameObject)assetrequest.asset;
|
|
|
+ m_ModelObj = Instantiate(prefab, transform);
|
|
|
+ ab.assetBundle.Unload(false);
|
|
|
+
|
|
|
+ ManipulationHandler manipulation = gameObject.AddComponent<ManipulationHandler>();
|
|
|
+ manipulation.enabled = false;
|
|
|
+ BoundingBox boundingBox = gameObject.AddComponent<BoundingBox>();
|
|
|
+ boundingBox.enabled = false;
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- var prefab = ab.LoadAsset<GameObject>(ab.LoadAllAssets<GameObject>()[0].name);
|
|
|
- m_ModelObj = Instantiate(prefab, transform);
|
|
|
- ab.Unload(false);
|
|
|
-
|
|
|
- ManipulationHandler manipulation = gameObject.AddComponent<ManipulationHandler>();
|
|
|
- manipulation.enabled = false;
|
|
|
- BoundingBox boundingBox = gameObject.AddComponent<BoundingBox>();
|
|
|
- boundingBox.enabled = false;
|
|
|
}
|
|
|
|
|
|
|