Exemplo n.º 1
0
    // 获取相对目录,
    public static string GetRelativePath(string ResType, string ABName)
    {
        string path     = ResourcesPath.GetRelativePath(ResType, ResourcesPathMode.AssetBundle);
        string fullname = string.Format("{0}{1}{2}", path, ABName, ConstantData.ABEXT);

        return(fullname.ToLower());
    }
Exemplo n.º 2
0
    // 加载mesh动画文件
    //Modify by Aoicocoon 2017/12/06
    //修改打包士兵数据+动画文件
    public override void LoadSoldierAnim(string meshName, string animName, bool IsCache, AssetLoadHook pfun)
    {
        if (null == pfun)
        {
            return;
        }

        string folder = ResourcesPath.GetRelativePath(ResourcesType.ActorSoldierMesh, ResourcesPathMode.AssetBundle);
        string key    = GetKey(folder, meshName + "/" + animName.ToLower());
        string path   = key + ConstantData.ABEXT;

        Object obj = FindAssetObj(key);

        if (null != obj)
        {
            pfun.Invoke(obj);
        }
        else
        {
            ABLoad.LoadAB(path, true,
                          (ab) =>
            {
                LoadQueue.AddLoadTask(path, animName, typeof(Texture2D), IsCache, IsCache, false, pfun);
            });
        }
    }
Exemplo n.º 3
0
    static List <UnitAnimInfo> GetHeroAnimInfo()
    {
        string HeroAnimPath      = ResourcesPath.GetRelativePath(ResourcesType.HeroAnim, ResourcesPathMode.Editor);
        List <UnitAnimInfo> list = new List <UnitAnimInfo>();

        DirectoryInfo dir = new DirectoryInfo(Application.dataPath + "/" + HeroAnimPath);

        DirectoryInfo[] subDirs = dir.GetDirectories();

        for (int i = 0; i < subDirs.Length; i++)
        {
            FileInfo[] files = subDirs[i].GetFiles();
            for (int j = 0; j < files.Length; j++)
            {
                if (!files[j].Name.EndsWith(".anim"))
                {
                    continue;
                }

                string        assetPath = "Assets/" + HeroAnimPath + subDirs[i].Name + "/" + files[j].Name;
                AnimationClip anim      = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AnimationClip)) as AnimationClip;
                if (null != anim)
                {
                    UnitAnimInfo info = new UnitAnimInfo();
                    info.ActorName  = subDirs[i].Name;
                    info.ActName    = files[j].Name.Remove(files[j].Name.LastIndexOf('.'));
                    info.FrameCount = (uint)(anim.frameRate * anim.length);
                    list.Add(info);
                }
            }
            EditorUtility.DisplayProgressBar("导出英雄动画帧数", subDirs[i].Name, (float)(i + 1) / subDirs.Length);
        }
        EditorUtility.ClearProgressBar();
        return(list);
    }
    // 加载配置文件
    public override Object LoadConfig(string name)
    {
        string path     = ResourcesPath.GetRelativePath(ResourcesType.Config, ResourcesPathMode.Editor);
        string ext      = ResourcesPath.GetFileExt(ResourcesType.Config);
        string fullpath = string.Format("Assets/{0}{1}.{2}", path, name, ext);

        return(AssetDatabase.LoadAssetAtPath(fullpath, typeof(Object)));
    }
Exemplo n.º 5
0
    public override void LoadMaterial(string MaterialName, bool async, AssetLoadHook pfun)
    {
        // LoadObj(ResourcesType.Material, MaterialName, "", typeof(Material), true, pfun);
        string   RelativePath = ResourcesPath.GetRelativePath(ResourcesType.Material, ResourcesPathMode.AssetBundle);
        Material go           = Resources.Load <Material>(RelativePath + MaterialName) as Material;

        if (pfun != null)
        {
            pfun(go);
        }
    }
Exemplo n.º 6
0
    // 加载精灵
    public override void LoadSprite(string AtlasName, string SpriteName, bool async, AssetLoadHook pfun)
    {
        //LoadObj(ResourcesType.UIAltas, AtlasName.ToLower(), SpriteName.ToLower(), typeof(Sprite), true, true, false, async,pfun);
        string RelativePath = ResourcesPath.GetRelativePath(ResourcesType.UIAltas, ResourcesPathMode.AssetBundle);
        Sprite go           = Resources.Load <Sprite>(RelativePath + AtlasName + "/" + SpriteName) as Sprite;

        if (pfun != null)
        {
            pfun(go);
        }
    }
Exemplo n.º 7
0
    public override void LoadVoice(string audioName, bool async, AssetLoadHook pfun)
    {
        //LoadObj(ResourcesType.Audio, audioName.ToLower(), audioName.ToLower(), typeof(AudioClip), true, true, false, async,pfun) ;
        string    RelativePath = ResourcesPath.GetRelativePath(ResourcesType.Voice, ResourcesPathMode.AssetBundle);
        AudioClip go           = Resources.Load <AudioClip>(RelativePath + audioName) as AudioClip;

        if (pfun != null)
        {
            pfun(go);
        }
    }
Exemplo n.º 8
0
    // 获取资源存储路径
    public static string GetAssetResourceSavePath(string Type, ResourcesPathMode Mode)
    {
        StringBuilder Builder = new StringBuilder(string.Empty);

        if (Mode == ResourcesPathMode.AssetBundle)
        {
            Builder.Append(AssetBundlePath);
        }

        string str = ResourcesPath.GetRelativePath(Type, Mode);

        Builder.Append(str);
        return(Builder.ToString());
    }
Exemplo n.º 9
0
    /// <summary>
    ///     <para> 获取资源存储路径 </para>
    /// </summary>
    /// <param name="type"></param>
    /// <param name="mode"></param>
    /// <returns></returns>
    public static string GetAssetResourceSavePath(string type, ResourcesPathMode mode)
    {
        StringBuilder stringBuilder = new StringBuilder(string.Empty);

        if (mode == ResourcesPathMode.AssetBundle)
        {
            stringBuilder.Append(BuildSettings.assetBundleOutputPath);
        }

        string path = ResourcesPath.GetRelativePath(type, mode);

        stringBuilder.Append(path);
        return(stringBuilder.ToString());
    }
Exemplo n.º 10
0
 private void LoadDependeAB()
 {
     ReadABResourceInfo();
     foreach (ABResourceUnit unit in m_abResource.listABUnit)
     {
         if (unit.ABdir == ResourcesPath.GetRelativePath(ResourcesType.Shader, ResourcesPathMode.AssetBundle)
             )
         {
             foreach (ABFileUnitInfo ABfileUnit in unit.listAb)
             {
                 ResourceManger.LoadDependeAB(unit.ABdir, ABfileUnit.ABfileName);
             }
         }
     }
     Shader.WarmupAllShaders();
 }
Exemplo n.º 11
0
    /// <summary>
    ///     <para> 设置文件夹下指定后缀资源的ab名,每个资源独立打成一个ab </para>
    /// </summary>
    /// <param name="typename"></param>
    static void ReimportPathUsePathNameWidthResourceType(string typename)
    {
        string inPath = ResourcesPath.GetAssetResourceRunPath(typename, ResourcesPathMode.Editor);

        inPath = inPath.Substring(0, inPath.Length - 1);

        string outPath = ResourcesPath.GetRelativePath(typename, ResourcesPathMode.AssetBundle);

        outPath = outPath.Substring(0, outPath.Length - 1);

        string ext = ResourcesPath.GetFileExt(typename);

        ext = ext.Substring(1);

        ReimportPathUsePathName(inPath, outPath, ext);
    }
Exemplo n.º 12
0
    // 加载预制
    public override void LoadPrefab(string prefabName, string Type, bool IsCahce, bool async, AssetLoadHook pfun)
    {
        string objName = prefabName.ToLower();

        /*if (IsCahce == true) {
         *       LoadObj(Type, prefabName, objName, typeof(GameObject), true, true, false, async, pfun);
         * } else {
         *       LoadObj(Type, prefabName, objName, typeof(GameObject), false, false, true, async, pfun);
         * }*/
        string     RelativePath = ResourcesPath.GetRelativePath(Type, ResourcesPathMode.AssetBundle);
        GameObject go           = Resources.Load <GameObject>(RelativePath + prefabName) as GameObject;

        if (pfun != null)
        {
            pfun(go);
        }
    }
Exemplo n.º 13
0
    // 加载asset接口
    private void LoadObj(string ResType,
                         string ObjName,
                         string subName,
                         System.Type type,
                         bool IsCahce,
                         AssetLoadHook pfun)
    {
        UnityEngine.Object obj     = null;
        string             FileExt = "";

        if (subName == "")
        {
            FileExt = ResourcesPath.GetFileExt(ResType);
        }
        else
        {
            FileExt = "/" + subName + ResourcesPath.GetFileExt(ResType);
        }
        string key = GetKey(ResType, ObjName, FileExt);

        obj = FindAssetObj(key);
        if (obj != null)
        {
            if (pfun != null)
            {
                pfun(obj);
            }
        }
        else
        {
            string PathName = "Assets/" + ResourcesPath.GetRelativePath(ResType, ResourcesPathMode.Editor) + ObjName + FileExt;
            obj = AssetDatabase.LoadAssetAtPath(PathName, type);
            if (obj != null && IsCahce == true)
            {
                AddCache(key, obj);
            }
            else if (null == obj)
            {
                UnityEngine.Debug.Log("LoadAssetAtPahth  Empty : " + PathName + "   Type :  " + type);
            }
            if (pfun != null)
            {
                pfun(obj);
            }
        }
    }
    // 加载asset接口
    private void LoadObj(string resType,
                         string objName,
                         string subName,
                         System.Type type,
                         bool isCahce,
                         AssetLoadHook pfun)
    {
        string fileExt;

        if (subName == "")
        {
            fileExt = ResourcesPath.GetFileExt(resType);
        }
        else
        {
            fileExt = "/" + subName + ResourcesPath.GetFileExt(resType);
        }
        string key = GetKey(resType, objName, fileExt);
        Object obj = FindAssetObj(key);

        if (obj != null)
        {
            if (pfun != null)
            {
                pfun(obj);
            }
        }
        else
        {
            string pathName = "Assets/" + ResourcesPath.GetRelativePath(resType, ResourcesPathMode.Editor) + objName + fileExt;
            obj = AssetDatabase.LoadAssetAtPath(pathName, type);
            if (obj != null && isCahce == true)
            {
                AddCache(key, obj);
            }
            else if (null == obj)
            {
                Debug.Log("LoadAssetAtPahth  Empty : " + pathName + "   Type :  " + type);
            }
            if (pfun != null)
            {
                pfun(obj);
            }
        }
    }
Exemplo n.º 15
0
    // 加载lua文件
    public override byte[] LoadLua(string luaName, bool IsCache)
    {
        string FileExt = ResourcesPath.GetFileExt(ResourcesType.luaData);
        string key     = GetKey(ResourcesType.luaData, luaName, FileExt);

        byte[] AB = FindBytes(key);
        if (AB != null)
        {
            return(AB);
        }
        else
        {
            string    PathName = "Assets/" + ResourcesPath.GetRelativePath(ResourcesType.luaData, ResourcesPathMode.Editor) + luaName + FileExt;
            TextAsset ta       = AssetDatabase.LoadAssetAtPath <TextAsset>(PathName) as TextAsset;
            if (ta != null && IsCache == true)
            {
                AddBytesCache(key, ta.bytes);
                return(ta.bytes);
            }
        }
        return(null);
    }
    public override void LoadSoldierAnim(string meshName, string animName, bool isCache, AssetLoadHook pfun)
    {
        if (null == pfun)
        {
            return;
        }

        string FileExt = ResourcesPath.GetFileExt(ResourcesType.ActorSoldierMesh);
        string key     = GetKey(ResourcesType.ActorSoldierMesh, meshName + "/" + animName, FileExt);

        Object obj = FindAssetObj(key);

        if (null != obj)
        {
            pfun.Invoke(obj);
        }
        else
        {
            string PathName = "Assets/" + ResourcesPath.GetRelativePath(ResourcesType.ActorSoldierMesh, ResourcesPathMode.Editor) + meshName + "/" + animName + FileExt;

            Texture2D ta = AssetDatabase.LoadAssetAtPath <Texture2D>(PathName) as Texture2D;

            if (null != ta)
            {
                if (isCache)
                {
                    AddCache(key, ta);
                }
                pfun.Invoke(ta);
            }
            else
            {
                Debug.Log("LoadAssetAtPath  Empty : " + key);
            }
        }
    }
Exemplo n.º 17
0
    // 加载配置文件
    public override Object LoadConfig(string ResType, string ConfigName)
    {
        string RelativePath = ResourcesPath.GetRelativePath(ResType, ResourcesPathMode.AssetBundle);

        return(Resources.Load <Object>(RelativePath + ConfigName) as Object);
    }
Exemplo n.º 18
0
    // 获取key 的接口
    private string GetKey(string ResType, string ObjName, string FileExt)
    {
        string str = ResourcesPath.GetRelativePath(ResType, ResourcesPathMode.Editor);

        return(str + ObjName + FileExt);
    }
Exemplo n.º 19
0
    // 获取相对目录,
    public static string GetRelativePath(string ResType, string ABName)
    {
        string str = ResourcesPath.GetRelativePath(ResType, ResourcesPathMode.AssetBundle);

        return(str + ABName + ConstantData.ABEXT);
    }
Exemplo n.º 20
0
 private static string GetCopySourcePath(string Type)
 {
     return(Application.dataPath + "/" + ResourcesPath.GetRelativePath(Type, ResourcesPathMode.Editor));
 }
Exemplo n.º 21
0
 private static string GetCopyDestPath(string Type)
 {
     return(Application.dataPath + "/" + "Resources/" + ResourcesPath.GetRelativePath(Type, ResourcesPathMode.AssetBundle));
 }