コード例 #1
0
ファイル: U3DAssetDB.cs プロジェクト: Hengle/UnityEditor
    private bool _ApplySerializeObject(U3DAssetDBSerializeObject obj)
    {
        string projPath = EditorHelper.GetProjectPath();

        dbUpdateTime = obj.StrUpdateTime;

        assetTable.Clear();
        foreach (var asset in obj.AssetTable)
        {
            Guid         id      = new Guid(asset.Key);
            U3DAssetInfo info    = asset.Value;
            string       absPath = projPath + info.path;
            //数据库中所述路径所对应文件已经不存在
            if (
                !Directory.Exists(absPath) &&
                !File.Exists(absPath)
                )
            {
                Debug.LogError("Asset数据库已过期!路径\"" + info.path + "\"不存在!");
                return(false);
            }
            ResourceManageToolUtility.InitAssetInfoIcon(ref info);
            assetTable.Add(id, info);
        }

        assetReferencedTable.Clear();
        foreach (var pair in obj.AssetReferencedTable)
        {
            Guid        id             = new Guid(pair.Key);
            List <Guid> referencedList = new List <Guid>();
            foreach (var referencedID in pair.Value)
            {
                Guid refId = new Guid(referencedID);
                referencedList.Add(refId);
            }
            assetReferencedTable.Add(id, referencedList);
        }

        unUsedAssets.Clear();
        foreach (var unUsedAsset in obj.UnUsedAssets)
        {
            Guid id = new Guid(unUsedAsset);
            unUsedAssets.Add(id);
        }
        return(true);
    }
コード例 #2
0
ファイル: U3DAssetDB.cs プロジェクト: Hengle/UnityEditor
    /*
     *  AssetDB持久化相关函数
     */

    private U3DAssetDBSerializeObject _GetSerializeObject()
    {
        U3DAssetDBSerializeObject obj = new U3DAssetDBSerializeObject();

        obj.StrUpdateTime = DBUpdateTime;

        List <KeyValuePair <string, U3DAssetInfo> > assetList =
            new List <KeyValuePair <string, U3DAssetInfo> >();

        foreach (var asset in assetTable)
        {
            KeyValuePair <string, U3DAssetInfo> assetKeyPair = new KeyValuePair <string, U3DAssetInfo>
                                                                   (asset.Key.ToString(), asset.Value);
            assetList.Add(assetKeyPair);
        }

        obj.AssetTable = assetList;


        List <KeyValuePair <string, List <string> > > assetReferenced = new List <KeyValuePair <string, List <string> > >();

        foreach (var asset in assetReferencedTable)
        {
            KeyValuePair <string, List <string> > assetKeyPair = new KeyValuePair <string, List <string> >
                                                                     (asset.Key.ToString(), new List <string>());

            foreach (var id in asset.Value)
            {
                assetKeyPair.Value.Add(id.ToString());
            }
            assetReferenced.Add(assetKeyPair);
        }
        obj.AssetReferencedTable = assetReferenced;

        List <string> unUsedList = new List <string>();

        foreach (var id in unUsedAssets)
        {
            unUsedList.Add(id.ToString());
        }

        obj.UnUsedAssets = unUsedList;

        return(obj);
    }