Browse Source

添加素材库数据处理

DGJ 1 year ago
parent
commit
d932565a8b

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

@@ -13,7 +13,7 @@ public class LoadManager : Singleton<LoadManager>
         {
             GameObject obj = new GameObject(dName);
             DownLoadItem dli = obj.AddComponent<DownLoadItem>();
-            dli.Init(model.url, model.id);
+            dli.Init(model.url, model.uid);
         }
 
 
@@ -28,8 +28,8 @@ public class LoadManager : Singleton<LoadManager>
             {
                 if (!downList[dName].isAction)
                 {
-                    //下载成功并无处理
-                    switch (model.type)
+                    //涓嬭浇鎴愬姛骞舵棤澶勭悊
+                    switch (model.modelType)
                     {
                         case ModelItem.ModelType.Image:
 
@@ -46,7 +46,7 @@ public class LoadManager : Singleton<LoadManager>
             }
             else
             {
-                //下载失败
+                //涓嬭浇澶辫触
             }
         };
     }

+ 87 - 21
Assets/2.0/User/Model/ModelItem.cs

@@ -10,33 +10,29 @@ public class ModelItem
 
         Video,
 
-        ABModel
+        ABModel,
 
-    }
-    //模型所在场景
-    public UserSceneItem sceneItem;
-
-    //模型id
-    public string id;
+        Text
 
-    //模型name
-    public string name;
+    }
+    //妯″瀷鎵€鍦ㄧ粍鍚堢礌鏉愬唴
+    public GameObject modelList;
 
     private GameObject _model;
 
-    //模型数据
+    //妯″瀷鏁版嵁
     public GameObject Model
     {
         get { 
             if(_model==null)
             {
                 _model = new GameObject(name);
-                _model.transform.parent = sceneItem.SceneModel.transform;
+                _model.transform.parent = modelList.transform;
                 _model.transform.localPosition = getInfoPos();
                 _model.transform.localEulerAngles = getInfoEul();
                 LoadManager.Instance.load(this, (float f)=> {
 
-                   //显示加载
+                   //鏄剧ず鍔犺浇
                 
                 
                 },(GameObject obj)=> {
@@ -54,25 +50,95 @@ public class ModelItem
 
 
 
-    //模型地址
+    //妯″瀷鍦板潃
     public string url;
 
-    //模型类型
-    public ModelType type;
+    //妯″瀷绫诲瀷
+    public ModelType modelType;
 
-    //模型原始信息
-    public string info;
+    ////妯″瀷鍘熷�淇℃伅
+    //public string info;
 
-    //模型版本
-    public string Version;
+    //妯″瀷鐗堟湰
+    public string Version { get; set; }
 
     Vector3 getInfoPos()
     {
-        return Vector3.zero;
+        //return Vector3.zero;
+        if (objectTransform.nowPos == Vector3.zero)
+            return objectTransform.startPos;
+        else
+            return objectTransform.nowPos;
     }
     Vector3 getInfoEul()
     {
-        return Vector3.zero;
+        if (objectTransform.nowRot == Vector3.zero)
+            return objectTransform.startRot;
+        else
+            return objectTransform.nowRot;
+        // return Vector3.zero;
+    }
+
+    Vector3 getInfoScale()
+    {
+        if (objectTransform.nowScale == Vector3.zero)
+            return objectTransform.startScale;
+        else
+            return objectTransform.nowScale;
+    }
+
+    //妯″瀷id
+    public string uid { get; set; }
+
+    //妯″瀷name
+    public string name { get; set; }
+    /// <summary>
+    /// 妯″瀷绫诲瀷
+    /// </summary>
+    public int type { get; set; }
+    /// <summary>
+    /// 鏂囨湰鍐呭�
+    /// </summary>
+    public string textContent { get; set; }
+
+    /// <summary>
+    /// 涓嬭浇鍦板潃
+    /// </summary>
+    public string DownloadPath { get; set; }
+    /// <summary>
+    /// 鏈�湴淇濆瓨鍦板潃
+    /// </summary>
+    public string localSavePath { get; set; }
+    /// <summary>
+    ///  鍧愭爣
+    /// </summary>
+    public ObjectTransform objectTransform { get; set; }
+
+
+    public void init(GameObject modelList)
+    {
+        switch (type)
+        {
+            case 1:  // 鍥剧墖
+                modelType = ModelType.Image;
+                break;
+            case 2:  // 瑙嗛�
+                modelType = ModelType.Video;
+                break;
+            case 3:  // 妯″瀷
+                modelType = ModelType.ABModel;
+                break;
+            case 4:  // 鏂囧瓧
+                modelType = ModelType.Text;
+                break;
+            default:
+                Debug.LogError(name + "  绱犳潗缁撴瀯绫诲瀷寮傚父锛侊紒锛�");
+                break;
+        }
+        url = DownloadPath;
+        this.modelList = modelList;
+        if (Model != null)
+            Debug.Log(" 娣诲姞妯″瀷 " + name);
     }
 
 }

+ 94 - 0
Assets/2.0/User/Model/ModelList.cs

@@ -0,0 +1,94 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class ModelList
+{
+   public int id { get; set; }
+
+    public string name { get; set; }
+    public int type { get; set; }
+    
+    public string describe { get; set; }
+
+    public List<ModelItem> materialList { get; set; }
+
+    public int updatTime { get; set; }
+
+    public string typesetting { get; set; }
+
+    public ObjectTransform objectTransform { get; set; }
+
+    public Transform materalLibrary;
+
+    private GameObject _model;
+
+    //组合模型数据
+    public GameObject Model
+    {
+        get
+        {
+            if (_model == null)
+            {
+                _model = new GameObject(name);
+                _model.SetActive(false);
+                InitObjectTransform();
+                _model.transform.parent = materalLibrary;
+                _model.transform.localPosition = getInfoPos();
+                _model.transform.localEulerAngles = getInfoEul();
+              
+            }
+            return _model;
+        }
+    }
+
+    Vector3 getInfoPos()
+    {
+        
+        //return Vector3.zero;
+        if (objectTransform.nowPos == Vector3.zero)
+            return objectTransform.startPos;
+        else
+            return objectTransform.nowPos;
+    }
+    Vector3 getInfoEul()
+    {
+        if (objectTransform.nowRot == Vector3.zero)
+            return objectTransform.startRot;
+        else
+            return objectTransform.nowRot;
+        // return Vector3.zero;
+    }
+
+    Vector3 getInfoScale()
+    {
+        if (objectTransform.nowScale == Vector3.zero)
+            return objectTransform.startScale;
+        else
+            return objectTransform.nowScale;
+    }
+
+    private void InitObjectTransform()
+    {
+        if(objectTransform==null)
+        {
+            objectTransform = new ObjectTransform();
+            objectTransform.startPos = Vector3.zero;
+            objectTransform.nowPos = Vector3.zero;
+            objectTransform.startRot = Vector3.zero;
+            objectTransform.nowRot = Vector3.zero;
+            objectTransform.startScale = Vector3.one;
+            objectTransform.nowScale = Vector3.zero;
+        }
+    }
+    //public ModelList( int id , string name, int type ,string describe ,int updaTime,string typesetting, List<ModelItem> listModelItem)
+    //{
+    //    this.id = id;
+    //    this.name = name;
+    //    this.type = type;
+    //    this.describe = describe;
+    //    this.updatTime = updaTime;
+    //    this.typesetting = typesetting;
+    //    this.listModelItem = listModelItem;
+    //}
+}

+ 11 - 0
Assets/2.0/User/Model/ModelList.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4d0dd85291cc8284786ce778eb8afd68
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 2
Assets/2.0/User/Model/ModelManager.cs

@@ -1,3 +1,4 @@
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using System.Collections;
 using System.Collections.Generic;
@@ -5,10 +6,12 @@ using UnityEngine;
 
 public class ModelManager : Singleton<ModelManager>
 {
-    public Dictionary<string, ModelItem> modellist = new Dictionary<string, ModelItem>();
+  //  public Dictionary<string, ModelItem> modellist = new Dictionary<string, ModelItem>();
+    public Dictionary<int, ModelList> modellist = new Dictionary<int, ModelList>();
+    public GameObject materialLibrary;
     public void init(string message)
     {
-        GameManager.Instance.text.text = " »ñÈ¡ËØ²ÄÁбí";
+        GameManager.Instance.text.text = " 获�素�列表";
         JObject jObject = JObject.Parse(message);
         string data = jObject["data"].ToString();
 
@@ -18,6 +21,44 @@ public class ModelManager : Singleton<ModelManager>
         string library = dataObject["library"].ToString();
         string combination = dataObject["combination"].ToString();
 
+        materialLibrary = new GameObject("MaterailLibrary");
+        // 把三个素�库数�转�素�列表
+        AddDicModelList(single);
+        AddDicModelList(library);
+        AddDicModelList(combination);
+      
+    }
+
+    private void AddDicModelList(string message)
+    {
+     if (!string.IsNullOrWhiteSpace(message))
+        {
+          
+            List<ModelList> ModelList = JsonConvert.DeserializeObject<List<ModelList>>(message);
+            Debug.Log(ModelList.Count + " AddDicModelList " + message);
+            for (int i = 0; i < ModelList.Count; i++)
+            {
+                ModelList[i].materalLibrary = materialLibrary.transform;
+                modellist.Add(ModelList[i].id, ModelList[i]);          
+                for (int j = 0; j < ModelList[i].materialList.Count; j++)
+                {
+                    ModelList[i].materialList[j].init( ModelList[i].Model);
+                }
+                //DownLoadModel(ModelList[i]);
+            }
+        }
+
+    }
+
+   
 
+    private void DownLoadModel(ModelList list)
+    {
+        for (int i = 0; i < list.materialList.Count; i++)
+        {
+            if (list.materialList[i].Model != null)
+                Debug.Log(" 检测下载 " + list.materialList[i].name);
+        }
     }
+
 }

+ 2 - 2
Packages/manifest.json

@@ -14,8 +14,8 @@
     "com.unity.xr.arkit-face-tracking": "4.2.7",
     "com.unity.xr.interactionsubsystems": "1.0.1",
     "com.unity.xr.openxr": "1.5.3",
-    "con.ghz.obe": "file:D:/JiHe/OOBEPackageXR/package",
-    "jh.xr.engine": "file:D:/JiHe/XRSDK/package",
+    "jh.immersalsdk.engine": "file:G:/GUnityProject/ImmersalSDK/package",
+    "jh.xr.engine": "file:G:/GUnityProject/NavigatorXRSDK/XRSDK/package",
     "com.unity.modules.ai": "1.0.0",
     "com.unity.modules.androidjni": "1.0.0",
     "com.unity.modules.animation": "1.0.0",

+ 1 - 31
Packages/packages-lock.json

@@ -200,30 +200,6 @@
       },
       "url": "https://packages.unity.cn"
     },
-    "com.unity.xr.core-utils": {
-      "version": "2.0.0",
-      "depth": 2,
-      "source": "registry",
-      "dependencies": {
-        "com.unity.modules.xr": "1.0.0"
-      },
-      "url": "https://packages.unity.cn"
-    },
-    "com.unity.xr.interaction.toolkit": {
-      "version": "2.0.4",
-      "depth": 1,
-      "source": "registry",
-      "dependencies": {
-        "com.unity.inputsystem": "1.3.0",
-        "com.unity.ugui": "1.0.0",
-        "com.unity.xr.core-utils": "2.0.0",
-        "com.unity.xr.legacyinputhelpers": "2.1.8",
-        "com.unity.modules.audio": "1.0.0",
-        "com.unity.modules.imgui": "1.0.0",
-        "com.unity.modules.physics": "1.0.0"
-      },
-      "url": "https://packages.unity.cn"
-    },
     "com.unity.xr.interactionsubsystems": {
       "version": "1.0.1",
       "depth": 0,
@@ -267,12 +243,6 @@
       },
       "url": "https://packages.unity.cn"
     },
-    "con.ghz.obe": {
-      "version": "file:G:/GUnityProject/OBEPackage/package",
-      "depth": 0,
-      "source": "local",
-      "dependencies": {}
-    },
     "jh.immersalsdk.engine": {
       "version": "file:G:/GUnityProject/ImmersalSDK/package",
       "depth": 0,
@@ -284,7 +254,7 @@
       }
     },
     "jh.xr.engine": {
-      "version": "file:G:/GUnityProject/XRSDK/package",
+      "version": "file:G:/GUnityProject/NavigatorXRSDK/XRSDK/package",
       "depth": 0,
       "source": "local",
       "dependencies": {

+ 3 - 3
ProjectSettings/ProjectSettings.asset

@@ -924,6 +924,7 @@ PlayerSettings:
   metroSplashScreenUseBackgroundColor: 1
   platformCapabilities:
     WindowsStoreApps:
+      EnterpriseAuthentication: False
       OfflineMapsManagement: False
       HumanInterfaceDevice: False
       Location: False
@@ -935,7 +936,6 @@ PlayerSettings:
       PrivateNetworkClientServer: False
       InternetClientServer: False
       VideosLibrary: False
-      BackgroundMediaPlayback: False
       Objects3D: False
       RemoteSystem: False
       BlockedChatMessages: False
@@ -958,9 +958,9 @@ PlayerSettings:
       RecordedCallsFolder: False
       Contacts: False
       InternetClient: True
-      Proximity: False
       CodeGeneration: False
-      EnterpriseAuthentication: False
+      BackgroundMediaPlayback: False
+      Proximity: False
   metroTargetDeviceFamilies:
     Desktop: False
     Holographic: False