//copytexture public void SetTexture(string path, Texture _texture, OnCallBackTexRect callback) { if (_texture == null || _texture.width > mWidth || _texture.height > mHeight)//不符合规格 { if (callback != null) { callback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务 } Debug.Log("Texture Does not meet the standard:" + path); return; } if (_usingRect.ContainsKey(path)) { if (callback != null) { SaveImageData imagedata = _usingRect[path]; imagedata.referenceCount++; Texture2D tex2D = m_tex2DList[imagedata.texIndex]; callback(tex2D, _usingRect[path].rect, path); } return; } GetImageData data = DynamicAtlasManager.Instance.AllocateGetImageData(); data.path = path; data.callback = callback; mGetImageTasks.Add(data); Texture2D tex = (Texture2D)_texture; OnRenderTexture(path, tex, null); }
//copytexture public void SetTexture(string path, Texture _texture, OnCallBackTexRect callback) { if (_texture == null || _texture.width > mWidth || _texture.height > mHeight)//不符合规格 { if (callback != null) { callback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务 } Debug.Log("Texture Does not meet the standard:" + path); return; } if (_usingRect.ContainsKey(path)) { if (callback != null) { SaveImageData imagedata = _usingRect[path]; imagedata.referenceCount++; Texture2D tex2D = m_tex2DList[imagedata.texIndex]; callback(tex2D, _usingRect[path].rect, path); } return; } Texture2D tex = (Texture2D)_texture; OnLoadRenderTexture(path, tex, callback); }
public void GetTeture(string name, OnCallBackTexRect callback) { if (m_UsingTexture.ContainsKey(name)) { if (callback != null) { SaveTextureData data = m_UsingTexture[name]; data.referenceCount++; Texture2D tex2D = m_PageList[data.texIndex].texture; callback(tex2D, data.rect); } } else { //FIXME! 这里需要改成自己的加载方式 var texture = Resources.Load <Texture2D>(name); //--------------- if (texture == null) { Debug.LogError("Failed To load Texture:" + name); callback(null, new Rect(0, 0, 0, 0)); return; } GetTextureData data = DynamicAtlasMgr.S.AllocateGetTextureData(); data.name = texture.name; data.callback = callback; m_GetTextureTaskList.Add(data); OnRenderTexture(data.name, texture); } }
private GetImageData AllocateGetImageData(string path, OnCallBackTexRect callback = null, OnCallBackMetRect BlitCallback = null) { GetImageData data = DynamicAtlasManager.Instance.AllocateGetImageData(); data.path = path; data.callback = callback; data.BlitCallback = BlitCallback; mGetImageTaskDic.Add(path, data); return(data); }
void OnLoadRenderTexture(string path, Texture2D tex, OnCallBackTexRect callback = null, OnCallBackMetRect BlitCallback = null) { GetImageData data; if (mGetImageTaskDic.TryGetValue(path, out data)) { data.callback += callback; data.BlitCallback += BlitCallback; } else { AllocateGetImageData(path, callback, null); } OnRenderTexture(path, tex); }
//copytexture public void GetImage(string path, OnCallBackTexRect callback) { if (_usingRect.ContainsKey(path)) { if (callback != null) { SaveImageData imagedata = _usingRect[path]; imagedata.referenceCount++; Texture2D tex2D = m_tex2DList[imagedata.texIndex]; callback(tex2D, _usingRect[path].rect, path); } return; } LoadImageAsync(path, callback, null); }
void LoadImageAsync(string path, OnCallBackTexRect callback = null, OnCallBackMetRect BlitCallback = null) { GetImageData data; if (mGetImageTaskDic.TryGetValue(path, out data)) { data.callback += callback; data.BlitCallback += BlitCallback; } else { data = AllocateGetImageData(path, callback, null); var ao = Addressables.LoadAssetAsync <Texture2D>(data.path); ao.Completed += handle => { Texture2D texture2D = handle.Result as Texture2D; OnRenderTexture(path, texture2D); Addressables.Release(handle); }; } }
public void SetTexture(Texture texture, OnCallBackTexRect callBack) { if (texture == null) { Debug.Log("Texture is Null"); callBack(null, new Rect(0, 0, 0, 0)); return; } if (texture.width > m_Width || texture.height > m_Height) { Debug.Log("Texture is too big"); callBack(null, new Rect(0, 0, 0, 0)); return; } if (m_UsingTexture.ContainsKey(texture.name)) { if (callBack != null) { SaveTextureData textureData = m_UsingTexture[texture.name]; textureData.referenceCount++; Texture2D tex2D = m_PageList[textureData.texIndex].texture; callBack(tex2D, textureData.rect); } return; } GetTextureData data = DynamicAtlasMgr.S.AllocateGetTextureData(); data.name = texture.name; data.callback = callBack; m_GetTextureTaskList.Add(data); OnRenderTexture(data.name, (Texture2D)texture); }
//copytexture public void GetImage(string path, OnCallBackTexRect callback) { if (_usingRect.ContainsKey(path)) { if (callback != null) { SaveImageData imagedata = _usingRect[path]; imagedata.referenceCount++; Texture2D tex2D = m_tex2DList[imagedata.texIndex]; callback(tex2D, _usingRect[path].rect, path); } return; } GetImageData data = DynamicAtlasManager.Instance.AllocateGetImageData(); data.path = path; data.callback = callback; mGetImageTasks.Add(data); if (mGetImageTasks.Count > 1) { return; } OnGetImage(); }