コード例 #1
0
        private void OnGetProjectTreeCompleted(Error error, ProjectItem rootFolder, ProjectAsyncOperation ao, ProjectEventHandler callback)
        {
            m_root = rootFolder;

            for (int i = 0; i < m_staticReferences.Length; ++i)
            {
                AssetLibraryReference assetLibrary = m_staticReferences[i];
                if (assetLibrary == null)
                {
                    continue;
                }
                assetLibrary.Ordinal = i;
                m_assetDB.AddLibrary(assetLibrary, i);

                CleanupTree(m_root, i);
                MergeAssetLibrary(assetLibrary, i);
            }

            AssetItem[] assetItems = m_root.Flatten(true).OfType <AssetItem>().ToArray();
            m_idToAssetItem = assetItems.ToDictionary(item => item.ItemID);
            for (int i = 0; i < assetItems.Length; ++i)
            {
                AssetItem assetItem = assetItems[i];
                if (assetItem.Parts != null)
                {
                    for (int j = 0; j < assetItem.Parts.Length; ++j)
                    {
                        PrefabPart prefabPart = assetItem.Parts[j];
                        if (prefabPart != null)
                        {
                            m_idToAssetItem.Add(prefabPart.PartID, assetItem);
                        }
                    }
                }
            }
            if (callback != null)
            {
                callback(error);
            }

            ao.Error       = error;
            ao.IsCompleted = true;
        }
コード例 #2
0
ファイル: Project.cs プロジェクト: daef/Unity_RuntimeEditor
        private void MergeAssetLibrary(AssetLibraryReference asset, int ordinal)
        {
            if (!asset.KeepRuntimeProjectInSync)
            {
                return;
            }

            AssetLibraryInfo assetLibrary = asset.AssetLibrary;

            if (assetLibrary == null)
            {
                return;
            }

            assetLibrary.BuildTree();

            AssetFolderInfo rootFolder = assetLibrary.Folders.Where(folder => folder.depth == -1).First();

            MergeFolders(rootFolder, m_root, ordinal);
        }
コード例 #3
0
        private void SaveAsset()
        {
            AssetLibraryInfo assetLibrary     = Asset.AssetLibrary;
            string           assetLibraryPath = AssetDatabase.GetAssetPath(Asset);
            int    assetExtIndex = assetLibraryPath.LastIndexOf(".asset");
            string proxyPath     = assetLibraryPath.Remove(assetExtIndex) + "_Ref.asset";

            AssetLibraryReference reference = AssetDatabase.LoadAssetAtPath <AssetLibraryReference>(proxyPath);

            if (reference == null)
            {
                reference = CreateInstance <AssetLibraryReference>();
                AssetDatabase.CreateAsset(reference, proxyPath);
            }

            reference.AssetLibrary             = assetLibrary.CloneVisible();
            reference.AssetLibraryPath         = assetLibraryPath;
            reference.KeepRuntimeProjectInSync = Asset.KeepRuntimeProjectInSync;

            EditorUtility.SetDirty(reference);
            EditorUtility.SetDirty(Asset);
            AssetDatabase.SaveAssets();
        }