コード例 #1
0
 public static void DrawB(MeshHolder holder)
 {
     holder.meshB.vertices = holder.Vertices;
     holder.meshB.uv       = holder.UVs;
     holder.meshB.colors32 = holder.Colors;
     UnityGraphics.DrawMeshNow(holder.meshB, Matrix4x4.identity);
 }
コード例 #2
0
ファイル: PictureHandle.cs プロジェクト: mmuu1987/MyTouchWall
    private void HandleTextureArry(List <Texture2D> texs)
    {
        if (texs == null || texs.Count == 0)
        {
            enabled = false;
            return;
        }

        if (SystemInfo.copyTextureSupport == CopyTextureSupport.None ||
            !SystemInfo.supports2DArrayTextures)
        {
            enabled = false;
            return;
        }
        TexArr = new Texture2DArray(texs[0].width, texs[0].width, texs.Count, TextureFormat.RGBA32, false, false);

        for (int i = 0; i < texs.Count; i++)
        {
            //Debug.Log(" index is" + i);
            try
            {
                Graphics.CopyTexture(texs[i], 0, 0, TexArr, i, 0);
            }
            catch (Exception e)
            {
                Debug.Log("index is" + i);
                throw e;
            }
        }

        TexArr.wrapMode   = TextureWrapMode.Clamp;
        TexArr.filterMode = FilterMode.Bilinear;

        Debug.Log("HandleTextureArry End ===============>>>>>>>>>>>   TexArr Length is " + TexArr.depth);
    }
コード例 #3
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.Graphics o;
     o = new UnityEngine.Graphics();
     pushObject(l, o);
     return(1);
 }
コード例 #4
0
        private static void SaveSplitted(string suffix, Texture2D tex, int xSrc, int ySrc, int width, int height,
                                         int xOffset, int yOffset, int x, int y)
        {
            Texture2D target    = new Texture2D(width, height, TextureFormat.RGBA32, false);
            var       widthSrc  = width - xOffset;
            var       heightSrc = height - yOffset;

            UnityGraphics.CopyTexture(tex, 0, 0, xSrc, ySrc, widthSrc, heightSrc, target, 0, 0, x, y);
            for (int k = 0; k < height && xOffset > 0; ++k)
            {
                var c = target.GetPixel(widthSrc - 1, k);
                for (int kx = widthSrc; kx < width; ++kx)
                {
                    target.SetPixel(kx, k, c);
                }
            }
            for (int k = 0; k < width && yOffset > 0; ++k)
            {
                var c = target.GetPixel(k, heightSrc - 1);
                for (int ky = heightSrc; ky < height; ++ky)
                {
                    target.SetPixel(k, ky, c);
                }
            }
            target.Apply();
            string projectPath = Application.dataPath.Replace("/Assets", "/");
            string path        = AssetDatabase.GetAssetPath(tex);

            path = $"{path.Substring(0, path.LastIndexOf('.'))}_{suffix}.png";
            File.WriteAllBytes(projectPath + path, target.EncodeToPNG());
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
コード例 #5
0
 public void SetRenderTarget(RenderTarget2D renderTarget)
 {
     if (renderTarget != null)
     {
         UnityGraphics.SetRenderTarget(renderTarget.UnityRenderTexture);
     }
     else
     {
         UnityGraphics.SetRenderTarget(null);
     }
 }
コード例 #6
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.Graphics o;
			o=new UnityEngine.Graphics();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #7
0
        public void CacheAppIcon(string appKey, Texture2D tex, bool force = false)
        {
            RenderTexture rt = new RenderTexture(32, 32, 24, RenderTextureFormat.ARGB32);

            Graphics.Blit(tex, rt);

            Directory.CreateDirectory(iconCacheFolder);

            string path = Path.Combine(iconCacheFolder, appKey + ".png");

            DumpRenderTexture(rt, path);
        }
コード例 #8
0
        public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, VertexPositionColorTexture[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
        {
            Debug.Assert(vertexData != null && vertexData.Length > 0, "The vertexData must not be null or zero length!");
            Debug.Assert(indexData != null && indexData.Length > 0, "The indexData must not be null or zero length!");

            var material = _materialPool.Get(Textures[0]);

            var mesh = _meshPool.Get(primitiveCount / 2);

            mesh.Populate(vertexData, numVertices);

            UnityGraphics.DrawMesh(mesh.Mesh, _matrix, material, 0);
        }
コード例 #9
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.Graphics o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.Graphics();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
コード例 #10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Graphics o;
         o = new UnityEngine.Graphics();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #11
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Graphics o;
         o = new UnityEngine.Graphics();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #12
0
        private static void SaveResized(Texture2D tex, int width, int height, int x, int y)
        {
            var target     = new Texture2D(width, height, TextureFormat.RGBA32, false);
            var targetData = target.GetRawTextureData <Color32>();
            var clearColor = Color.clear;

            for (int l = 0; l < height; ++l)
            {
                for (int k = 0; k < x; ++k) //left border
                {
                    targetData[l * width + k] = clearColor;
                }
                for (int k = tex.width - x; k < width; ++k) //right border
                {
                    targetData[l * width + k] = clearColor;
                }
            }
            for (int k = x; k < width - x; ++k)
            {
                for (int l = 0; l < y; ++l) //bottom border
                {
                    targetData[l * width + k] = clearColor;
                }
                for (int l = tex.height - y; l < height; ++l) //top border
                {
                    targetData[l * width + k] = clearColor;
                }
            }
            var rt  = RenderTexture.GetTemporary(tex.width, tex.height);
            var rta = RenderTexture.active;

            RenderTexture.active = rt;
            GL.Clear(false, true, Color.clear);
            GL.LoadPixelMatrix(0, 1, 1, 0);
            UnityGraphics.DrawTexture(new Rect(0, 0, 1, 1), tex, MatCopy, 0);//point copy
            target.ReadPixels(new Rect(0, 0, tex.width, tex.height), x, y);
            RenderTexture.active = rta;
            RenderTexture.ReleaseTemporary(rt);
            string projectPath = Application.dataPath.Replace("/Assets", "/");
            string path        = AssetDatabase.GetAssetPath(tex);

            File.WriteAllBytes(projectPath + path, target.EncodeToPNG());
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
コード例 #13
0
 public static void CreatePreview128()
 {
     AssetDatabase.StartAssetEditing();
     foreach (var tex in Selection.GetFiltered <Texture2D>(SelectionMode.DeepAssets))
     {
         if (tex.width == tex.height)
         {
             continue;
         }
         int  size = tex.width;
         Rect drawRect;
         if (tex.height > tex.width)
         {
             size = tex.height;
             int xr = (size - tex.width) / 2;
             drawRect = new Rect((float)xr / size, 0, (float)tex.width / size, 1);
         }
         else
         {
             int yr = size - tex.height;
             drawRect = new Rect(0, (float)yr / size, 1, (float)tex.width / size);
         }
         int tsize  = 128;
         var target = new Texture2D(tsize, tsize, TextureFormat.RGBA32, false);
         var rt     = RenderTexture.GetTemporary(tsize, tsize);
         var rta    = RenderTexture.active;
         RenderTexture.active = rt;
         GL.Clear(false, true, Color.clear);
         GL.LoadPixelMatrix(0, 1, 1, 0);
         UnityGraphics.DrawTexture(drawRect, tex, MatCopy, 1);//bilinear copy
         target.ReadPixels(new Rect(0, 0, tsize, tsize), 0, 0);
         RenderTexture.active = rta;
         RenderTexture.ReleaseTemporary(rt);
         string projectPath = Application.dataPath.Replace("/Assets", "/");
         string path        = AssetDatabase.GetAssetPath(tex) + "_sqprv.png";
         File.WriteAllBytes(projectPath + path, target.EncodeToPNG());
         AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
     }
     AssetDatabase.StopAssetEditing();
 }
コード例 #14
0
 public static void TrySaveToPNG(this Texture texture, string filePath)
 {
     try
     {
         RenderTexture tmp = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);
         Graphics.Blit(texture, tmp);
         RenderTexture previous = RenderTexture.active;
         RenderTexture.active = tmp;
         Texture2D myTexture2D = new Texture2D(texture.width, texture.height);
         myTexture2D.ReadPixels(new Rect(0, 0, tmp.width, tmp.height), 0, 0);
         myTexture2D.Apply();
         RenderTexture.active = previous;
         RenderTexture.ReleaseTemporary(tmp);
         var bytes = ImageConversion.EncodeToPNG(myTexture2D);
         File.WriteAllBytes(filePath, bytes);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #15
0
    private void HandleTextureArry(List <Texture2D> texs)
    {
        if (texs == null || texs.Count == 0)
        {
            enabled = false;
            return;
        }

        if (SystemInfo.copyTextureSupport == CopyTextureSupport.None ||
            !SystemInfo.supports2DArrayTextures)
        {
            enabled = false;
            return;
        }
        TexArr = new Texture2DArray(texs[0].width, texs[0].width, texs.Count, TextureFormat.DXT5, false, false);

        for (int i = 0; i < texs.Count; i++)
        {
            Graphics.CopyTexture(texs[i], 0, 0, TexArr, i, 0);
        }

        TexArr.wrapMode   = TextureWrapMode.Clamp;
        TexArr.filterMode = FilterMode.Bilinear;
    }
コード例 #16
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.Graphics o;
         o=new UnityEngine.Graphics();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #17
0
ファイル: SDL.cs プロジェクト: sunilcodex/lgeneral-to-android
 public static void copy_image(Graphics graphic, int xdest, int ydest, int w, int h, SDL_Surface src, int xsrc, int ysrc)
 {
     graphic.DrawImage(src.bitmap, xdest, ydest, new Rectangle(xsrc, ysrc, w, h), GraphicsUnit.Pixel);
 }