Esempio n. 1
0
        public string getAbsPathByRelPath(ref string relPath, ref ResLoadType loadType)
        {
            // 获取版本
            string version = Ctx.m_instance.m_versionSys.getFileVer(relPath);
            string absPath = relPath;

            if (!string.IsNullOrEmpty(version))
            {
                absPath = UtilLogic.combineVerPath(Path.Combine(Ctx.m_instance.m_localFileSys.getLocalWriteDir(), relPath), version);
                if (!File.Exists(absPath))
                {
                    absPath = Path.Combine(Ctx.m_instance.m_localFileSys.getLocalReadDir(), relPath);
                    if (!File.Exists(absPath))
                    {
                        absPath = "";
                    }
                    else
                    {
                        loadType = ResLoadType.eStreamingAssets;
                    }
                }
                else
                {
                    relPath  = UtilLogic.combineVerPath(relPath, version);        // 在可写目录下,文件名字是有版本号的
                    loadType = ResLoadType.ePersistentData;
                }
            }
            else
            {
                loadType = ResLoadType.eStreamingAssets;
            }

            return(absPath);
        }
Esempio n. 2
0
    public static string GetPath(string localPath, ResLoadType loadType)
    {
        StringBuilder path = new StringBuilder();

        switch (loadType)
        {
        case ResLoadType.Streaming:
#if UNITY_EDITOR
            path.Append(Application.dataPath);
            path.Append("/StreamingAssets/");
            break;
#else
            path.Append(Application.streamingAssetsPath);
            path.Append("/");
            break;
#endif

        case ResLoadType.Persistent:
            path.Append(Application.persistentDataPath);
            path.Append("/");
            break;
        }

        path.Append(localPath);
        path.Append(".assetBundle");
        return(path.ToString());
    }
Esempio n. 3
0
 //保存一个文本
 public static void WriteTextFile(string path, string content, ResLoadType type)
 {
     #if UNITY_EDITOR
     ResourceIOTool.WriteStringByFile(GetPath(path, type), content);
     #else
     #endif
 }
Esempio n. 4
0
 //保存一个文本
 public static void WriteTextFile(string path, string content, ResLoadType type)
 {
     #if UNITY_EDITOR
     ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(type, path), content);
     #else
     #endif
 }
Esempio n. 5
0
        /// <summary>
        /// 根据策划资源表的主键加载到POOL
        /// </summary>
        /// <param name="entityResType">对应资源表主键</param>
        /// <returns></returns>
        public GameObjectPool GetGameObjectPool(int entityResType)
        {
            GameObjectPool pool = null;

            if (!gameObjectPools.TryGetValue(entityResType, out pool))
            {
                var cell = Config.resourceConfig.getInstace().getCell(entityResType);
                if (null == cell)
                {
                    string e = string.Format("资源表没有这个资源 {0}", entityResType);
                    throw new System.Exception(e);
                }

                ResLoadType eResLoadType = (ResLoadType)cell.loadtype;
                switch (eResLoadType)
                {
                case ResLoadType.OnlyPrefab:
                    return(this.LoadOnlyPrefab(cell, entityResType));

                case ResLoadType.PrefabAndTexture:
                    return(this.PrefabAndTexture(cell, entityResType));

                default:
                    string e = string.Format("没有这种加载类型{0}", cell.loadtype);
                    throw new System.Exception(e);
                }
            }

            return(pool);
        }
Esempio n. 6
0
 public void copyFrom(ResItem rhv)
 {
     m_resPackType      = rhv.m_resPackType;
     m_resLoadType      = rhv.m_resLoadType;
     m_path             = rhv.m_path;
     m_pathNoExt        = rhv.m_pathNoExt;
     m_extName          = rhv.m_extName;
     m_resNeedCoroutine = rhv.m_resNeedCoroutine;
     m_refCountResLoadResultNotify.copyFrom(rhv.refCountResLoadResultNotify);
 }
Esempio n. 7
0
    public static ResLoadType GetLoadType(ResLoadType loadType)
    {
        //如果设置从Resource中加载则忽略打包设置
        if (gameLoadType == ResLoadType.Resource)
        {
            return(ResLoadType.Resource);
        }

        return(loadType);
    }
Esempio n. 8
0
        private IResLoader LoaderFactory(ResLoadType type)
        {
            if (type == ResLoadType.LoadByAssetsBundle)
            {
                loader = new ResLoader();
            }
            else
            {
                loader = new ResLoaderAB();
            }

            return(loader);
        }
Esempio n. 9
0
    /// <summary>
    /// 根据bundleName获取加载路径
    /// </summary>
    /// <param name="bundleName"></param>
    /// <returns></returns>
    public static string GetBundlePath(ResourcesConfig config)
    {
        bool isLoadByPersistent = RecordManager.GetData(c_HotUpdateRecordName).GetRecord(config.name, false);

        ResLoadType loadType = ResLoadType.Streaming;

        //加载路径由 加载根目录 和 相对路径 合并而成
        //加载根目录由配置决定
        if (isLoadByPersistent)
        {
            loadType = ResLoadType.Persistent;
        }

        return(PathTool.GetAbsolutePath(loadType, config.path + "." + c_AssetsBundlesExpandName));
    }
Esempio n. 10
0
        public List <string> m_pakExtNameList; // 打包的扩展名字列表

        public Config()
        {
            StreamingAssets = "StreamingAssets/";
            UIModelLayer    = "UIModel";

            m_ip   = "192.168.122.253";
            m_port = 10002;
            m_zone = 30;

            m_webIP          = "http://127.0.0.1/UnityServer/";
            m_webPort        = 80;
            m_netLogPhp      = "/netlog/NetLog.php";
            m_pakExtNameList = new List <string>();

            m_resLoadType = ResLoadType.eLoadDisc;
            m_pathLst     = new string[(int)ResPathType.eTotal];
            m_pathLst[(int)ResPathType.ePathScene]      = "Scenes/";
            m_pathLst[(int)ResPathType.ePathSceneXml]   = "Scenes/Xml/";
            m_pathLst[(int)ResPathType.ePathModule]     = "Module/";
            m_pathLst[(int)ResPathType.ePathComUI]      = "UI/";
            m_pathLst[(int)ResPathType.ePathComUIScene] = "UIScene/";
            m_pathLst[(int)ResPathType.ePathBeingPath]  = "Being/";
            m_pathLst[(int)ResPathType.ePathAIPath]     = "AI/";
            m_pathLst[(int)ResPathType.ePathTablePath]  = "Table/";
            m_pathLst[(int)ResPathType.ePathLangXml]    = "Languages/";
            m_pathLst[(int)ResPathType.ePathXmlCfg]     = "XmlConfig/";
            m_pathLst[(int)ResPathType.ePathModel]      = "Model/";
            m_pathLst[(int)ResPathType.ePathMaterial]   = "Model/Materials/";
            m_pathLst[(int)ResPathType.ePathBuildImage] = "Image/Build/";
            m_pathLst[(int)ResPathType.ePathCardImage]  = "Image/Card/";
            m_pathLst[(int)ResPathType.ePathWord]       = "Word/";
            m_pathLst[(int)ResPathType.ePathAudio]      = "Sound/";
            m_pathLst[(int)ResPathType.ePathAtlas]      = "Atlas/";
            m_pathLst[(int)ResPathType.ePathSpriteAni]  = "Effect/SpriteEffect/";
            m_pathLst[(int)ResPathType.ePathSceneAnimatorController] = "Animation/Scene/";
            m_pathLst[(int)ResPathType.ePathLuaScript]   = "LuaScript/";
            m_pathLst[(int)ResPathType.ePathSkillAction] = "SkillAction/";

            m_dataPath = Application.dataPath;

            m_pakExtNameList.Add("prefab");
            m_pakExtNameList.Add("png");
            m_pakExtNameList.Add("shader");
            m_pakExtNameList.Add("unity");
        }
Esempio n. 11
0
        public List<string> m_pakExtNameList;       // 打包的扩展名字列表

        public Config()
        {
            StreamingAssets = "StreamingAssets/";
            UIModelLayer = "UIModel";

            m_ip = "192.168.122.253";
            m_port = 10002;
            m_zone = 30;

            m_webIP = "http://127.0.0.1/UnityServer/";
            m_webPort = 80;
            m_netLogPhp = "/netlog/NetLog.php";
            m_pakExtNameList = new List<string>();

            m_resLoadType = ResLoadType.eLoadDisc;
            m_pathLst = new string[(int)ResPathType.eTotal];
            m_pathLst[(int)ResPathType.ePathScene] = "Scenes/";
            m_pathLst[(int)ResPathType.ePathSceneXml] = "Scenes/Xml/";
            m_pathLst[(int)ResPathType.ePathModule] = "Module/";
            m_pathLst[(int)ResPathType.ePathComUI] = "UI/";
            m_pathLst[(int)ResPathType.ePathComUIScene] = "UIScene/";
            m_pathLst[(int)ResPathType.ePathBeingPath] = "Being/";
            m_pathLst[(int)ResPathType.ePathAIPath] = "AI/";
            m_pathLst[(int)ResPathType.ePathTablePath] = "Table/";
            m_pathLst[(int)ResPathType.ePathLangXml] = "Languages/";
            m_pathLst[(int)ResPathType.ePathXmlCfg] = "XmlConfig/";
            m_pathLst[(int)ResPathType.ePathModel] = "Model/";
            m_pathLst[(int)ResPathType.ePathMaterial] = "Model/Materials/";
            m_pathLst[(int)ResPathType.ePathBuildImage] = "Image/Build/";
            m_pathLst[(int)ResPathType.ePathCardImage] = "Image/Card/";
            m_pathLst[(int)ResPathType.ePathWord] = "Word/";
            m_pathLst[(int)ResPathType.ePathAudio] = "Sound/";
            m_pathLst[(int)ResPathType.ePathAtlas] = "Atlas/";
            m_pathLst[(int)ResPathType.ePathSpriteAni] = "Effect/SpriteEffect/";
            m_pathLst[(int)ResPathType.ePathSceneAnimatorController] = "Animation/Scene/";
            m_pathLst[(int)ResPathType.ePathLuaScript] = "LuaScript/";
            m_pathLst[(int)ResPathType.ePathSkillAction] = "SkillAction/";

            m_dataPath = Application.dataPath;

            m_pakExtNameList.Add("prefab");
            m_pakExtNameList.Add("png");
            m_pakExtNameList.Add("shader");
            m_pakExtNameList.Add("unity");
        }
Esempio n. 12
0
    public static void LoadAsync(string name, LoadCallBack callBack)
    {
        BundleConfig packData = BundleConfigManager.GetBundleConfig(name);

        if (packData == null)
        {
            return;
        }

        ResLoadType loadTypeTmp = GetLoadType(packData.loadType);

        if (loadTypeTmp == ResLoadType.Resource)
        {
            ResourceIOTool.ResourceLoadAsync(packData.path, callBack);
        }
        else
        {
            AssetsBundleManager.LoadAsync(name, callBack);
        }
    }
Esempio n. 13
0
    public static object Load(string name)
    {
        BundleConfig packData = BundleConfigManager.GetBundleConfig(name);

        if (packData == null)
        {
            throw new Exception("Load Exception not find " + name);
        }

        ResLoadType loadTypeTmp = GetLoadType(packData.loadType);

        if (loadTypeTmp == ResLoadType.Resource)
        {
            return(Resources.Load(packData.path));
        }
        else
        {
            return(AssetsBundleManager.Load(name));
        }
    }
Esempio n. 14
0
        public static void modifyLoadParam(string resPath, LoadParam param)
        {
#if PKG_RES_LOAD
            param.m_origPath = resPath;             // 记录原始的资源名字

            string retPath = resPath;

            if ("Module/AutoUpdate.prefab" == resPath)       // 自动更新模块更新还没有实现
            {
                param.m_resLoadType = ResLoadType.eStreamingAssets;
            }
            else
            {
                // 获取包的名字
                if (Ctx.m_instance.m_pPakSys.path2PakDic.ContainsKey(resPath))
                {
                    retPath = Ctx.m_instance.m_pPakSys.path2PakDic[resPath].m_pakName;
                }

                if (param != null)
                {
                    Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref param.m_resLoadType);
                }
                else
                {
                    ResLoadType tmp = ResLoadType.eStreamingAssets;
                    Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref tmp);
                }
            }
            param.m_path    = retPath;
            param.m_pakPath = param.m_path;
#elif UnPKG_RES_LOAD
            if (param != null)
            {
                param.m_resLoadType = ResLoadType.eStreamingAssets;
            }
            param.m_path = resPath;
#else
            param.m_path = resPath;
#endif
        }
Esempio n. 15
0
    public static ResLoadType gameLoadType = ResLoadType.Resource; //默认从resourcePath中读取

    public static string GetPath(string localPath, ResLoadType loadType)
    {
        StringBuilder path = new StringBuilder();

        switch (loadType)
        {
        case ResLoadType.Resource:
                #if UNITY_EDITOR
            path.Append(Application.dataPath);
            path.Append("/Resources/");
            break;
                #endif
        case ResLoadType.Streaming:
                #if UNITY_EDITOR
            path.Append(Application.dataPath);
            path.Append("/StreamingAssets/");
            break;
                #else
            path.Append(Application.streamingAssetsPath);
            path.Append("/");
            break;
                #endif

        case ResLoadType.Persistent:
            path.Append(Application.persistentDataPath);
            path.Append("/");
            break;

        case ResLoadType.Catch:
            path.Append(Application.temporaryCachePath);
            path.Append("/");
            break;

        default:
            Debug.LogError("Type Error !" + loadType);
            break;
        }

        path.Append(localPath);
        return(path.ToString());
    }
Esempio n. 16
0
        // 获取当前资源所在的包文件名字
        public string getCurResPakPathByResPath(string resPath, LoadParam param)
        {
            //Ctx.m_instance.m_shareData.m_resInPakPath = resPath;
            //return Ctx.m_instance.m_shareData.m_resInPakPath;
#if PKG_RES_LOAD
            string retPath = resPath;

            if ("Module/AutoUpdate.prefab" == resPath)       // 自动更新模块更新还没有实现
            {
                param.m_resLoadType = ResLoadType.eStreamingAssets;
            }
            else
            {
                // 获取包的名字
                if (m_path2PakDic.ContainsKey(resPath))
                {
                    retPath = m_path2PakDic[resPath].m_pakName;
                }

                if (param != null)
                {
                    retPath = Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref param.m_resLoadType);
                }
                else
                {
                    ResLoadType tmp = ResLoadType.eStreamingAssets;
                    retPath = Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref tmp);
                }
            }
            return(retPath);
#elif UnPKG_RES_LOAD
            if (param != null)
            {
                param.m_resLoadType = ResLoadType.eStreamingAssets;
            }
            return(resPath);
#else
            return(resPath);
#endif
        }
Esempio n. 17
0
    //资源路径数据不依赖任何其他数据
    static Dictionary <string, SingleField> GetResourcesConfig()
    {
        string dataJson = "";

        if (ResourceManager.m_gameLoadType == ResLoadType.Resource)
        {
            dataJson = ResourceIOTool.ReadStringByResource(
                PathTool.GetRelativelyPath(ConfigManager.c_directoryName,
                                           c_configFileName,
                                           ConfigManager.c_expandName));
        }
        else
        {
            ResLoadType type = ResLoadType.Streaming;

            if (RecordManager.GetData(AssetsBundleManager.c_HotUpdateRecordName).GetRecord(c_configFileName, false))
            {
                type = ResLoadType.Persistent;
            }

            dataJson = ResourceIOTool.ReadStringByBundle(
                PathTool.GetAbsolutePath(
                    type,
                    PathTool.GetRelativelyPath(
                        ConfigManager.c_directoryName,
                        c_configFileName,
                        AssetsBundleManager.c_AssetsBundlesExpandName)));
        }

        if (dataJson == "")
        {
            throw new Exception("ResourcesConfig not find " + c_configFileName);
        }
        else
        {
            return(JsonTool.Json2Dictionary <SingleField>(dataJson));
        }
    }
Esempio n. 18
0
 public void Init(ResLoadType type)
 {
     loader = LoaderFactory(type);
 }
Esempio n. 19
0
 /// <summary>
 /// 组合绝对路径
 /// </summary>
 /// <param name="loadType">资源加载类型</param>
 /// <param name="relativelyPath">相对路径</param>
 /// <returns>绝对路径</returns>
 public static string GetAbsolutePath(ResLoadType loadType, string relativelyPath)
 {
     return(GetPath(loadType) + relativelyPath);
 }
Esempio n. 20
0
 public EquipmentRes(string resName, LoadType loadtype, ResLoadType mResLoadType, Action <UnityEngine.Object> func) : base(resName, loadtype, mResLoadType, func)
 {
     loadABType = LoadABType.WholePackage;
     LoadResByType <EquipmentRes>("/Equipments/" + mResName, loadABType);
 }
Esempio n. 21
0
        public string getAbsPathByRelPath(ref string relPath, ref ResLoadType loadType)
        {
            // 获取版本
            string version = Ctx.m_instance.m_versionSys.getFileVer(relPath);
            string absPath = relPath;
            if (!string.IsNullOrEmpty(version))
            {
                absPath = UtilLogic.combineVerPath(Path.Combine(Ctx.m_instance.m_localFileSys.getLocalWriteDir(), relPath), version);
                if (!File.Exists(absPath))
                {
                    absPath = Path.Combine(Ctx.m_instance.m_localFileSys.getLocalReadDir(), relPath);
                    if (!File.Exists(absPath))
                    {
                        absPath = "";
                    }
                    else
                    {
                        loadType = ResLoadType.eStreamingAssets;
                    }
                }
                else
                {
                    relPath = UtilLogic.combineVerPath(relPath, version);         // 在可写目录下,文件名字是有版本号的
                    loadType = ResLoadType.ePersistentData;
                }
            }
            else
            {
                loadType = ResLoadType.eStreamingAssets;
            }

            return absPath;
        }
Esempio n. 22
0
 public void copyFrom(ResItem rhv)
 {
     m_resPackType = rhv.m_resPackType;
     m_resLoadType = rhv.m_resLoadType;
     m_path = rhv.m_path;
     m_pathNoExt = rhv.m_pathNoExt;
     m_extName = rhv.m_extName;
     m_resNeedCoroutine = rhv.m_resNeedCoroutine;
     m_refCountResLoadResultNotify.copyFrom(rhv.refCountResLoadResultNotify);
 }