string ILibaryHandle.GetTextAsset(string objName) { string _type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_TextAsset]; FileStateObj stateObj = GetFileStateObj(_type, objName); if (stateObj != null) { string path = stateObj.m_Path; string str = null; if (stateObj.m_Asset == null) { stateObj.m_Asset = ResLibaryTool.LoadFileStr(path); } ; str = (string)stateObj.m_Asset; if (str != null && stateObj.m_ExistStatus == AssetExistStatusEnum.Quote) { stateObj.m_Quote++; } if (stateObj.m_ExistStatus == AssetExistStatusEnum.Once) { stateObj.m_Asset = null; } return(str); } return(null); }
Texture2D ILibaryHandle.GetTexture2d(string objName) { string _type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D]; FileStateObj stateObj = GetFileStateObj(_type, objName); if (stateObj != null) { if (stateObj.m_Asset == null) { stateObj.m_Asset = ResLibaryTool.readLocalTexture2d(stateObj.m_Path); stateObj.m_Quote = 0; } Texture2D t = (Texture2D)stateObj.m_Asset; if (t != null && stateObj.m_ExistStatus == AssetExistStatusEnum.Quote) { stateObj.m_Quote++; } if (stateObj.m_ExistStatus == AssetExistStatusEnum.Once) { stateObj.m_Asset = null; } return(t); } return(null); }
private void Awake() { ResLibaryTool t = gameObject.GetComponent <ResLibaryTool>(); if (singletonObj == null) { singletonObj = gameObject; DontDestroyOnLoad(gameObject); singletonObj.name = typeof(ResLibaryTool).FullName; instance = t; OnInit(); _applicationIsQuitting = false; } else if (singletonObj != gameObject) { MonoBehaviour[] monos = gameObject.GetComponents <MonoBehaviour>(); if (monos.Length > 1) { Destroy(t); } else { Destroy(gameObject); } } }
string ILibaryHandle.GetTextAsset(string objName) { string _type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_TextAsset]; string streamingAssetPath = Application.streamingAssetsPath; if (resourceDict.ContainsKey(_type)) { Dictionary <string, FileStateObj> _Dict = resourceDict[_type]; FileStateObj stateObj; _Dict.TryGetValue(objName, out stateObj); if (stateObj != null) { string path = Path.Combine(streamingAssetPath, stateObj.m_Path); string str = null; if (stateObj.m_Asset == null) { stateObj.m_Asset = ResLibaryTool.LoadFileStr(path); } ; str = (string)stateObj.m_Asset; if (str != null && stateObj.m_ExistStatus == AssetExistStatusEnum.Quote) { stateObj.m_Quote++; } if (stateObj.m_ExistStatus == AssetExistStatusEnum.Once) { stateObj.m_Asset = null; } return(str); } } return(null); }
Texture2D ILibaryHandle.GetTexture2d(string objName) { string _type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D]; string streamingAssetPath = Application.streamingAssetsPath; if (resourceDict.ContainsKey(_type)) { Dictionary <string, FileStateObj> _Dict = resourceDict[_type]; FileStateObj stateObj; _Dict.TryGetValue(objName, out stateObj); if (stateObj != null) { if (stateObj.m_Asset == null) { stateObj.m_Asset = ResLibaryTool.readLocalTexture2d(Path.Combine(streamingAssetPath, stateObj.m_Path)); stateObj.m_Quote = 0; } Texture2D t = (Texture2D)stateObj.m_Asset; if (t != null && stateObj.m_ExistStatus == AssetExistStatusEnum.Quote) { stateObj.m_Quote++; } if (stateObj.m_ExistStatus == AssetExistStatusEnum.Once) { stateObj.m_Asset = null; } return(t); } } return(null); }
void ILibaryHandle.InsertLibrary(object data) { if (data.GetType().Name != "LibaryStreamingAssetSetting") { return; } LibaryStreamingAssetSetting assetSetting = (LibaryStreamingAssetSetting)data; ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.texture2ds)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.textAssets)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.audios)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.videos)); }
void ILibaryHandle.InsertLibrary(object data) { if (data.GetType().Name != "LibaryAssetSetting") { return; } LibaryAssetSetting assetSetting = (LibaryAssetSetting)data; ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.texture2ds)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.renderTextures)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.movieTextures)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.sprites)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.materials)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.textAssets)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.prefabs)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.audios)); ResLibaryTool.UTStartCoroutine(InitLibaryAssetSetting(assetSetting.videos)); }
public void UpdateLibary(string localUrl, AssetExistStatusEnum assetStatus = AssetExistStatusEnum.Quote) { FileInfo file = new FileInfo(localUrl); if (file.Exists) { string existension = file.Extension; FileStateObj fileObj = null; if (ResLibaryConfig.ResourceTxtExts.Contains(existension)) { fileObj = new FileStateObj(); fileObj.m_Path = localUrl; fileObj.m_Type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_TextAsset]; if (assetStatus == AssetExistStatusEnum.Globle) { fileObj.m_Asset = ResLibaryTool.LoadFileStr(localUrl); } } else if (ResLibaryConfig.ResourceImgExts.Contains(existension)) { fileObj = new FileStateObj(); fileObj.m_Path = localUrl; fileObj.m_Type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Texture2D]; FileStateObj sfObj = new FileStateObj(); sfObj.m_Path = localUrl; sfObj.m_Type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_Sprite]; if (assetStatus == AssetExistStatusEnum.Globle) { Texture2D tex2d = ResLibaryTool.readLocalTexture2d(localUrl); fileObj.m_Asset = tex2d; sfObj.m_Asset = Sprite.Create(tex2d, new Rect(0, 0, tex2d.width, tex2d.height), Vector2.zero); } string fullFileName = System.IO.Path.GetFileName(localUrl); //int position = fullFileName.LastIndexOf("."); string fileName = System.IO.Path.GetFileNameWithoutExtension(localUrl);//fullFileName.Substring(0, position - 1); sfObj.m_Name = fileName; if (!resourceDict.ContainsKey(sfObj.m_Type)) { resourceDict[sfObj.m_Type] = new Dictionary <string, FileStateObj>(); } Dictionary <string, FileStateObj> dict = resourceDict[sfObj.m_Type]; dict[sfObj.m_Name] = sfObj; LibaryStateObj libaryObj = new LibaryStateObj(); libaryObj.m_Name = sfObj.m_Name; libaryObj.m_Status = LibaryStatusEnum.DIR_FILE; libaryObj.m_Type = sfObj.m_Type; libaryObj.m_Path = localUrl; if (UpdateAssetCallback != null) { UpdateAssetCallback(libaryObj); } //ResLibaryMgr.Instance.UpdateLibary(libaryObj); } else if (ResLibaryConfig.ResourceVideoExts.Contains(existension)) { fileObj = new FileStateObj(); fileObj.m_Path = localUrl; fileObj.m_Type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_VideoClip]; fileObj.m_Asset = localUrl; } else if (ResLibaryConfig.ResourceAudioExts.Contains(existension)) { fileObj = new FileStateObj(); fileObj.m_Path = localUrl; fileObj.m_Type = ResLibaryConfig.ExistType[LibaryTypeEnum.LibaryType_AudioClip]; fileObj.m_Asset = localUrl; } if (fileObj != null) { string fullFileName = System.IO.Path.GetFileName(localUrl); //int position = fullFileName.LastIndexOf("."); string fileName = System.IO.Path.GetFileNameWithoutExtension(localUrl);//fullFileName.Substring(0, position - 1); fileObj.m_Name = fileName; if (!resourceDict.ContainsKey(fileObj.m_Type)) { resourceDict[fileObj.m_Type] = new Dictionary <string, FileStateObj>(); } Dictionary <string, FileStateObj> dict = resourceDict[fileObj.m_Type]; dict[fileObj.m_Name] = fileObj; LibaryStateObj libaryObj = new LibaryStateObj(); libaryObj.m_Name = fileObj.m_Name; libaryObj.m_Status = LibaryStatusEnum.DIR_FILE; libaryObj.m_Type = fileObj.m_Type; libaryObj.m_Path = localUrl; if (UpdateAssetCallback != null) { UpdateAssetCallback(libaryObj); } //ResLibaryMgr.Instance.UpdateLibary(libaryObj); } } }
public void UpdateAssetBundle(string bundleUrl, AssetExistStatusEnum bundelExistStatus = AssetExistStatusEnum.Scene) { ResLibaryTool.UTStartCoroutine(AddAssetBundle(bundleUrl, bundelExistStatus)); }