private void MergeAssets(AssetFolderInfo from, ProjectItem to, int ordinal) { List <AssetInfo> fromAssets = from.Assets; if (fromAssets == null) { return; } if (to.Children == null) { to.Children = new List <ProjectItem>(); } for (int i = 0; i < fromAssets.Count; ++i) { AssetInfo assetFrom = fromAssets[i]; if (assetFrom.Object == null) { continue; } AssetItem assetTo = to.Children.OfType <AssetItem>().Where(item => item.Name == assetFrom.name).FirstOrDefault(); if (assetTo == null) { assetTo = new AssetItem(); to.Children.Add(assetTo); } assetTo.Name = assetFrom.name; assetTo.ItemID = m_assetDB.ToStaticResourceID(ordinal, assetFrom.PersistentID); assetTo.Parent = to; assetTo.TypeGuid = m_typeMap.ToGuid(assetFrom.Object.GetType()); assetTo.Preview = null; //must rebuild preview if (assetFrom.PrefabParts != null) { assetTo.Parts = new PrefabPart[assetFrom.PrefabParts.Count]; for (int j = 0; j < assetFrom.PrefabParts.Count; ++j) { PrefabPartInfo prefabPart = assetFrom.PrefabParts[j]; Guid typeGuid = m_typeMap.ToGuid(prefabPart.Object.GetType()); if (prefabPart != null && prefabPart.Object != null && typeGuid != Guid.Empty) { assetTo.Parts[j] = new PrefabPart { Name = prefabPart.Object.name, ParentID = prefabPart.ParentPersistentID, PartID = prefabPart.PersistentID, TypeGuid = typeGuid }; } else { assetTo.Parts[j] = null; } } } } }