Пример #1
0
        public T LoadAsset <T>(string _module, string _res) where T : UnityEngine.Object
        {
            T _t = null;

            _module = _module.ToLower();
            _res    = _res.ToLower();
#if UNITY_EDITOR
            if (!string.IsNullOrEmpty(_module))
            {
                _t = EditorLoad <T>(_module, _res);
            }
#endif
            if (_t == null)
            {
                AssetModuleConfig _amc = GetAssetModuleConfigByModule(_module, _res);
                if (_amc == null)
                {
                    return(null);
                }
                _t = LoadAssetBundle <T>(_amc.GetBundleName(_res), _amc.GetResourceName(_res));
            }
            if (_t == null)
            {
                Utility.LogError("模块", _module, "中的资源", _res, "加载失败!");
            }
            return(_t);
        }
Пример #2
0
        public byte[] EditorLoadTextFile(string _module, string _res)
        {
            if (editorRely == null)
            {
                CreateEditorRely();
            }

            _module = _module.ToLower();
            _res    = _res.ToLower();

            AssetModuleConfig _amc  = GetAssetModuleConfigByModule(_module, _res);
            string            _path = editorRely[_module][_res];

            _path  = Path.GetDirectoryName(_path);
            _path += "/";
            string _fname = _amc.GetResourceName(_res);
            string _ext   = Path.GetExtension(_fname);

            if (_ext.EndsWith("bytes"))
            {
                string _nefname = Path.GetFileNameWithoutExtension(_fname);
                while (true)
                {
                    if (File.Exists(_path + _nefname + ".lua"))
                    {
                        _path = _path + _nefname + ".lua";
                        break;
                    }
                    if (File.Exists(_path + _nefname + ".pb"))
                    {
                        _path = _path + _nefname + ".pb";
                        break;
                    }
                    break;
                }
            }
            return(File.ReadAllBytes(_path));
        }