Exemple #1
0
 void CallBackNull(GetImageData item, string path)
 {
     if (AtlasConfig.kUsingCopyTexture)
     {
         if (item.callback != null)
         {
             item.callback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务
         }
     }
     else
     {
         if (item.BlitCallback != null)
         {
             item.BlitCallback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务
         }
     }
 }
Exemple #2
0
    void OnRenderTexture(string path, Texture2D data, GetImageData imageData)
    {
        if (data == null)
        {
            for (int i = mGetImageTasks.Count - 1; i >= 0; i--)
            {
                GetImageData item = mGetImageTasks[i];
                if (item.path.Equals(path))
                {
                    if (item.callback != null)
                    {
                        item.callback(null, new Rect(0, 0, 0, 0), path);
                    }
                    if (AtlasConfig.kUsingCopyTexture)
                    {
                        if (item.callback != null)
                        {
                            item.callback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务
                        }
                    }
                    else
                    {
                        if (item.BlitCallback != null)
                        {
                            item.BlitCallback(null, new Rect(0, 0, 0, 0), path);//完成一个任务,就回调一个任务
                        }
                    }

                    DynamicAtlasManager.Instance.ReleaseGetImageData(item);
                    mGetImageTasks.RemoveAt(i);
                }
            }
            return;
        }
        int index;
        IntegerRectangle useArea = InsertArea(data.width, data.height, out index);

        Rect uv = new Rect((useArea.x + offset) * mUVXDiv, (useArea.y + offset) * mUVYDiv, (useArea.width - mPadding - offset * 2) * mUVXDiv, (useArea.height - mPadding - offset * 2) * mUVYDiv);

        if (AtlasConfig.kUsingCopyTexture)
        {
            CopyTexture(useArea.x, useArea.y, index, data);
        }
        else
        {
            BlitTexture(useArea.x, useArea.y, index, data);
        }

        SaveImageData _SaveImageData = DynamicAtlasManager.Instance.AllocateSaveImageData(uv);

        _SaveImageData.texIndex  = index;
        _SaveImageData.rectangle = useArea;
        _usingRect[path]         = _SaveImageData;

        for (int i = mGetImageTasks.Count - 1; i >= 0; i--)
        {
            GetImageData item = mGetImageTasks[i];
            if (item.path.Equals(path))
            {
                _usingRect[path].referenceCount = _usingRect[path].referenceCount + 1;
                if (AtlasConfig.kUsingCopyTexture)
                {
                    if (item.callback != null)
                    {
                        Texture2D dstTex = m_tex2DList[index];
                        item.callback(dstTex, uv, path);//完成一个任务,就回调一个任务
                    }
                }
                else
                {
                    if (item.BlitCallback != null)
                    {
                        Material material = m_MaterialList[index];
                        item.BlitCallback(material, uv, path);//完成一个任务,就回调一个任务
                    }
                }
                DynamicAtlasManager.Instance.ReleaseGetImageData(item);
                mGetImageTasks.RemoveAt(i);
            }
        }
    }