예제 #1
0
    /// <summary>
    /// 添加文件
    /// </summary>
    /// <param name="path"></param>
    /// <param name="groupName"></param>
    public static string AddAssetToGroup(string path, string groupName)
    {
        ResGroupCfg data = resInfo.GetGroupInfo(groupName);

        if (data == null)
        {
            return("");
        }

        string assetName = Path.GetFileNameWithoutExtension(path);

        if (!data.keys.Contains(assetName))
        {
            data.keys.Add(assetName);
            if (!resInfo.resources.Exists(a => a.name == assetName))
            {
                ResInfoData da = new ResInfoData();
                da.name           = assetName;
                da.path           = path.Replace("\\", "/");
                da.type           = Path.GetExtension(path);
                da.isFairyGuiPack = false;
                if (da.type == ".bytes")
                {
                    TextAsset text      = AssetDatabase.LoadAssetAtPath <TextAsset>(da.path);
                    byte []   descBytes = text.bytes;

                    if (ResMgr.ResIsFUIPack(descBytes))
                    {
                        da.isFairyGuiPack = true;
                    }
                }

                da.isKeepInMemory = true;

                da.isResourcesPath = da.path.Contains("Assets/Resources");
                if (da.isResourcesPath)
                {
                    string rootPath = da.path
                                      .Replace("Assets/Resources/", "");
                    rootPath  = Path.GetDirectoryName(rootPath);
                    da.ABName = rootPath;
                    //da.ABName = da.path.Replace(Application.dataPath + "/Resources")
                }
                else
                {
                    string rootPath = Path.GetDirectoryName(da.path);
                    rootPath  = rootPath.Substring(rootPath.LastIndexOf("/") + 1);
                    da.ABName = rootPath.ToLower();
                }
                resInfo.resources.Add(da);
            }
        }
        return(assetName);
    }