コード例 #1
0
		public override void DestroyTexture()
		{
			for (int i = 0; i < texNumber; i++) {
				if (m_PixelsHandle[i].IsAllocated == true) {
					m_PixelsHandle[i].Free();
					Texture2D.Destroy(m_Texture[i]);
				}
			}
			m_Texture      = null;
			m_Pixels       = null;
			m_PixelsHandle = null;
		}
コード例 #2
0
        private void ResizeColors(int size)
        {
            if (colors.Length != size)
                colors = new Color32[size][];

            for (int i = 0; i < size; i++)
            {
                colors[i] = new Color32[xSize * ySize];
            }
        }
コード例 #3
0
		public override IEnumerator CreateTexture()
		{
			m_Texture	   = new Texture2D[texNumber];
			m_Pixels	   = new Color32[texNumber][];
			m_PixelsHandle = new GCHandle[texNumber];

			for (int i = 0; i < texNumber; i++) {
				m_Texture[i] = new Texture2D(width, height, TextureFormat.ARGB32, false);
				m_Texture[i].wrapMode = TextureWrapMode.Clamp;
				// "pin" the array in memory, so we can pass direct pointer to it's data to the plugin,
				// without costly marshaling of array of structures.
				m_Pixels[i] = m_Texture[i].GetPixels32(0);
				m_PixelsHandle[i] = GCHandle.Alloc(m_Pixels[i], GCHandleType.Pinned);
				if ((i + 1) != texNumber) {
					yield return false;
				}
			}
		}