Browse Source

位置修改

胡佳骏 1 year ago
parent
commit
49d5b62bf9

+ 2 - 2
Assets/2.0/Tools/DownLoadItem.cs

@@ -239,12 +239,12 @@ public class DownLoadItem : MonoBehaviour
       
 
     }
-
+    public DownLoadMaterial data;
     public void DownloadFileMsg()
     {
         Debug.Log("查询需要下载的updateTime"+updateTime  + downLoadPath);
         MsgHandler.AddListener(downLoadPath, HandleMsg);
-        DownLoadMaterial data = new DownLoadMaterial();
+        data = new DownLoadMaterial();
         data.downLoadPath = downLoadPath;
         data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(downLoadPath);
         if(type == ModelType.vuforial)

+ 1 - 1
Assets/2.0/Tools/LoadManager.cs

@@ -86,7 +86,7 @@ public class LoadManager : Singleton<LoadManager>
                     if(downList[dName].downLoadData!=null)
                     {
                         Debug.Log(" LoadManager  " + dName + "  Length :  " + downList[dName].downLoadData.Length);
-                        model.SetData(downList[dName].downLoadData);
+                        model.SetData(downList[dName].downLoadData, downList[dName].data);
                     }else if(model.prefabModel==null)
                     {
                         model.prefabModel = new GameObject("空物体"+ downList[dName].id);

+ 41 - 4
Assets/2.0/User/Model/ModelItem.cs

@@ -223,14 +223,18 @@ public class ModelItem : System.ICloneable
 
         return clonedObject;
     }
-    public void SetData(byte[] data)
+    public byte[] abByte;
+    public static bool isLoad;
+    public static Queue<ModelItem> loadAB = new Queue<ModelItem>();
+    public void SetData(byte[] data, DownLoadMaterial dm)
     {
         if(data ==null && modelType!= ModelType.Video)
         {
             Debug.LogError(name + " 未下载完成  !!!!!");
         }
 
-        
+
+        Debug.Log("HJJTEST  ModelType   " + modelType);
         switch (modelType)
         {
             case ModelType.Image:
@@ -258,9 +262,13 @@ public class ModelItem : System.ICloneable
                 prefabModel.GetComponent<TemplateVideo>().SetData(Application.persistentDataPath+"/Material/"+Path.GetFileName(DownloadPath));
                 break;
             case ModelType.ABModel:
+                    prefabModel.GetComponent<TemplateModel>().Data = dm;
+                    abByte = data;
+                    loadAB.Enqueue(this);
+                /*
                 AssetBundle assetBundle = AssetBundle.LoadFromMemory(data);
                 Debug.Log(data.Length);
-                prefabModel.GetComponent<TemplateModel>().LoadModel(assetBundle);
+                prefabModel.GetComponent<TemplateModel>().LoadModel(assetBundle);*/
                 break;
             case ModelType.Text:
                 Debug.Log("HJJTEST  ModelType.Text   " + DownloadPath);
@@ -294,7 +302,36 @@ public class ModelItem : System.ICloneable
         {
             case ModelType.Text:
             prefabModel.GetComponent<TemplateText>().SetData(textContent, TextBJ);
-                Debug.Log(" ddddddddddddddddddddd"+prefabModel.name);
+                //Set text position
+                if (textPosition == "top")
+                {
+                    if (objectTransform.nowPos == Vector3.zero && prefabModel.transform.localPosition!= new Vector3(0, 0.4f, 0))
+                    {
+                        prefabModel.transform.localPosition = new Vector3(0, 0.4f, 0);
+                    }
+                }
+                else if (textPosition == "bottom")
+                {
+                    if (objectTransform.nowPos == Vector3.zero && prefabModel.transform.localPosition != new Vector3(0, 0.4f, 0))
+                    {
+                        prefabModel.transform.localPosition = new Vector3(0, -0.4f, 0);
+                    }
+                }
+                else if (textPosition == "left")
+                {
+                    if (objectTransform.nowPos == Vector3.zero && prefabModel.transform.localPosition != new Vector3(0, 0.3f, 0))
+                    {
+                        prefabModel.transform.localPosition = new Vector3(-0.3f, 0, 0);
+                    }
+                }
+                else if (textPosition == "right")
+                {
+                    if (objectTransform.nowPos == Vector3.zero && prefabModel.transform.localPosition != new Vector3(0, 0.3f, 0))
+                    {
+                        prefabModel.transform.localPosition = new Vector3(0.3f, 0f, 0);
+                    }
+                }
+                Debug.Log(" ddddddddddddddddddddd"+prefabModel.name+"_" + textPosition);
             break;
             default:
                 break;

+ 3 - 1
Assets/Scripts/LayoutTemplate/TemplateModel.cs

@@ -174,6 +174,7 @@ public class TemplateModel : BaseTemPlate
            // yield return new WaitForSeconds(0.3f);
             ab.Unload(false);
             HideCollider();
+            ModelItem.isLoad = false;
         }
     }
 
@@ -292,9 +293,10 @@ public class TemplateModel : BaseTemPlate
         boundingBox.enabled = false;
     }
 
-    private void TriLibModel()
+    public void TriLibModel()
     {
 
+        Debug.Log("模型加载完成TriLibModel" + Data.localLoadPath);
         TriLibModelLoad.Load(Data.localLoadPath, (AssetLoaderContext ac) => {
             Debug.Log("模型加载完成");
         }, (AssetLoaderContext ac) => {

+ 31 - 0
Assets/Scripts/UI/GameManager.cs

@@ -5,11 +5,13 @@ using OpenCVForUnity.ImgcodecsModule;
 using OpenCVForUnity.ImgprocModule;
 using OpenCVForUnity.UnityUtils;
 using SC.XR.Unity;
+using SC.XR.Unity.Module_InputSystem;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using System.Threading;
+using TriLibCore;
 using Unity.VisualScripting;
 using UnityEngine;
 using UnityEngine.UI;
@@ -470,8 +472,37 @@ public class GameManager : MonoSingleton<GameManager>
             avplayer = video.m_Video;
         }
 
+        if(ModelItem.loadAB.Count>0&&!ModelItem.isLoad)
+        {
+            ModelItem mi = ModelItem.loadAB.Dequeue();
+            if (IsAB(mi))
+            {
+                ModelItem.isLoad = true;
+                AssetBundle assetBundle = AssetBundle.LoadFromMemory(mi.abByte);
+                Debug.Log(mi.abByte.Length);
+                mi.prefabModel.GetComponent<TemplateModel>().LoadModel(assetBundle);
+            }else
+            {
+                Debug.Log("HJJ   fileName==2=>" + mi.DownloadPath);
+                mi.prefabModel.GetComponent<TemplateModel>().TriLibModel();
+            }
+        }
+    }
+
 
+    public bool IsAB(ModelItem mi)
+    {
+        bool finish = false;
+
+        Debug.Log("HJJ   fileName===>" + mi.DownloadPath);
+        if (mi.DownloadPath.Contains(".ghb") || !mi.DownloadPath.Contains("."))
+        {
+            finish = true;
+        }
+
+        return finish;
     }
+
     float lockTime = 0;
    public  AVProVideoPlayer avplayer;