// 加载配置文件
    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)));
    }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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);
            }
        }
    }
Ejemplo n.º 5
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);
            }
        }
    }