Beispiel #1
0
        public void SetTexture(string name, Texture texture)
        {
            if (texture == null)
            {
                Log.Info("Texture is Null");
                return;
            }

            if (texture.width > m_Width || texture.height > m_Height)
            {
                Log.Info("Texture is too big");
                return;
            }

            if (m_UsingTexture.ContainsKey(name))
            {
                return;
            }

            GetTextureData data = GetTextureData.Create();

            data.name = name;
            m_GetTextureTaskList.Add(data);

            OnRenderTexture(data.name, (Texture2D)texture);
        }
Beispiel #2
0
        private void OnRenderTexture(string name, Texture2D texture2D)
        {
            if (texture2D == null)
            {
                for (int i = m_GetTextureTaskList.Count - 1; i >= 0; i--)
                {
                    GetTextureData task = m_GetTextureTaskList[i];
                    task.Dispose();
                    m_GetTextureTaskList.RemoveAt(i);
                }

                return;
            }

            int index = 0;
            IntegerRectangle useArea = InsertArea(texture2D.width, texture2D.height, out index);

            // Log.Info(name + ":texture2D:" + texture2D.width+"  "+texture2D.height);

            if (useArea == null)
            {
                Log.Error("No Area");
                return;
            }

            Rect uv = new Rect((useArea.x), (useArea.y), texture2D.width, texture2D.height);

            m_PageList[index].AddTexture(useArea.x, useArea.y, texture2D);

            SaveTextureData saveTextureData = SaveTextureData.Create();

            saveTextureData.texIndex = index;
            saveTextureData.rect     = uv;
            m_UsingTexture[name]     = saveTextureData;

            for (int i = m_GetTextureTaskList.Count - 1; i >= 0; i--)
            {
                GetTextureData task = m_GetTextureTaskList[i];
                if (task.name.Equals(name))
                {
                    m_UsingTexture[name].referenceCount++;
                }
                task.Dispose();
                m_GetTextureTaskList.RemoveAt(i);
            }
        }