Browse Source

数据的深度复制

DGJ 1 year ago
parent
commit
a4de989170

+ 8 - 1
Assets/2.0/User/Model/ModelList.cs

@@ -2,7 +2,7 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
-public class ModelList
+public class ModelList: System.ICloneable
 {
    public int id { get; set; }
     public bool select { get; set; }
@@ -371,4 +371,11 @@ public class ModelList
         ObjectValue objectValue = new ObjectValue(id, parentid, mat.name, go, go.transform.localPosition, go.transform.localEulerAngles, go.transform.localScale);
         return objectValue;
     }
+
+    public object Clone()
+    {
+        ModelList clonedObject = (ModelList)this.MemberwiseClone();
+
+        return clonedObject;
+    }
 }

+ 24 - 23
Assets/2.0/User/Model/ModelManager.cs

@@ -45,39 +45,40 @@ public class ModelManager : Singleton<ModelManager>
             Models = JsonConvert.DeserializeObject<List<ModelList>>(message);
             Debug.Log(Models.Count + " AddDicModelList " + message);
             for (int i = 0; i < Models.Count; i++)
-            {
-                Models[i].materalLibrary = materialLibrary.transform;
-                modellist.Add(Models[i].id, Models[i]);
-                if (Models[i].Model == null)
-                    Debug.Log(" 初始化 Model ");
-                for (int j = 0; j < Models[i].materialList.Count; j++)
-                {
-                    Debug.Log("DownloadPath>>>>   " + Models[i].materialList[j].DownloadPath);
-                    Models[i].materialList[j].init(Models[i].Model);
-                }
+            {            
+                modellist.Add(Models[i].id, Models[i]);          
+                StartModelList(Models[i], materialLibrary);
                 // DownLoadModel(ModelList[i]);
             }
         }
 
     }
 
-
-    public ModelList GetModelList(int id)
+    /// <summary>
+    ///  初始化 ModelList , 根据ModelList生成组合素材
+    /// </summary>
+    /// <param name="modelList"></param>
+    /// <param name="parent"> </param>
+    public void StartModelList( ModelList modelList, GameObject parent )
     {
-        List<ModelList> Models2 = new List<ModelList>(Models.ToArray());
-        Debug.Log( "Models2    "+Models2.Count);
-        for (int i = 0; i < Models2.Count; i++)
-        {
-            if(Models2[i].id == id)
-            {
-                return Models2[i];
-               
-            }
+
+        modelList.materalLibrary = parent.transform;     
+        for (int j = 0; j < modelList.materialList.Count; j++)
+        {         
+            modelList.materialList[j].init(modelList.Model);
         }
-        return null;
+    }
 
+    /// <summary>
+    /// 从素材库中查找指定素材
+    /// </summary>
+    /// <param name="id"> 素材ID </param>
+    /// <returns></returns>
+    public ModelList GetModelList(int id)
+    {
+        
         if (modellist.ContainsKey(id))
-            return Clone.DeepCopy<ModelList>(modellist[id]);
+            return (ModelList)modellist[id].Clone();
         else
             return null;
     }

+ 2 - 2
ProjectSettings/ProjectSettings.asset

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