// DRAWING METHODS // Draw an image inside the editor window public static void DrawImage(UPAImage img) { Rect texPos = img.GetImgRect(); Texture2D bg = new Texture2D(1, 1); bg.SetPixel(0, 0, Color.clear); bg.Apply(); EditorGUI.DrawTextureTransparent(texPos, bg); DestroyImmediate(bg); //Calculate the final image from the layers list Texture2D _result = CalculateBlendedTex(img.layers); //Draw the image _result.SetPixel(1, 1, Color.black); GUI.DrawTexture(texPos, _result); // Draw a grid above the image (y axis first) for (int x = 0; x <= img.width; x += 1) { float posX = texPos.xMin + ((float)texPos.width / (float)img.width) * x - 0.2f; EditorGUI.DrawRect(new Rect(posX, texPos.yMin, 1, texPos.height), gridBGColor); } // Then x axis for (int y = 0; y <= img.height; y += 1) { float posY = texPos.yMin + ((float)texPos.height / (float)img.height) * y - 0.2f; EditorGUI.DrawRect(new Rect(texPos.xMin, posY, texPos.width, 1), gridBGColor); } }
// DRAWING METHODS // Draw an image inside the editor window public static void DrawImage (UPAImage img) { Rect texPos = img.GetImgRect(); Texture2D bg = new Texture2D (1,1); bg.SetPixel (0,0, Color.clear); bg.Apply(); EditorGUI.DrawTextureTransparent (texPos, bg); DestroyImmediate (bg); //Calculate the final image from the layers list Texture2D _result = CalculateBlendedTex(img.layers); //Draw the image _result.SetPixel(1, 1, Color.black); GUI.DrawTexture(texPos, _result); // Draw a grid above the image (y axis first) for (int x = 0; x <= img.width; x += 1) { float posX = texPos.xMin + ( (float)texPos.width / (float)img.width ) * x - 0.2f; EditorGUI.DrawRect (new Rect (posX, texPos.yMin, 1, texPos.height), gridBGColor); } // Then x axis for (int y = 0; y <= img.height; y += 1) { float posY = texPos.yMin + ( (float)texPos.height / (float)img.height ) * y - 0.2f; EditorGUI.DrawRect (new Rect (texPos.xMin, posY, texPos.width, 1), gridBGColor); } }
// DRAWING METHODS // Draw an image inside the editor window public static void DrawImage(UPAImage img) { Rect texPos = img.GetImgRect(); Texture2D bg = new Texture2D(1, 1); bg.SetPixel(0, 0, Color.clear); bg.Apply(); EditorGUI.DrawTextureTransparent(texPos, bg); DestroyImmediate(bg); // Draw image for (int i = 0; i < img.layers.Count; i++) { if (!img.layers[i].enabled) { continue; } GUI.DrawTexture(texPos, img.layers[i].tex); } // Draw a grid above the image (y axis first) for (int x = 0; x <= img.width; x += 1) { float posX = texPos.xMin + ((float)texPos.width / (float)img.width) * x - 0.2f; EditorGUI.DrawRect(new Rect(posX, texPos.yMin, 1, texPos.height), gridBGColor); } // Then x axis for (int y = 0; y <= img.height; y += 1) { float posY = texPos.yMin + ((float)texPos.height / (float)img.height) * y - 0.2f; EditorGUI.DrawRect(new Rect(texPos.xMin, posY, texPos.width, 1), gridBGColor); } }
// DRAWING METHODS // Draw an image inside the editor window public static void DrawImage(UPAImage img) { Rect texPos = img.GetImgRect(); Texture2D bg = new Texture2D (1,1); bg.SetPixel (0,0, Color.clear); bg.Apply(); EditorGUI.DrawTextureTransparent (texPos, bg); DestroyImmediate (bg); // Draw image for (int i = 0; i < img.layers.Count; i++) { if (!img.layers[i].enabled) continue; GUI.DrawTexture (texPos, img.layers[i].tex); } // Draw a grid above the image (y axis first) for (int x = 0; x <= img.width; x += 1) { float posX = texPos.xMin + ( (float)texPos.width / (float)img.width ) * x - 0.2f; EditorGUI.DrawRect (new Rect (posX, texPos.yMin, 1, texPos.height), gridBGColor); } // Then x axis for (int y = 0; y <= img.height; y += 1) { float posY = texPos.yMin + ( (float)texPos.height / (float)img.height ) * y - 0.2f; EditorGUI.DrawRect (new Rect (texPos.xMin, posY, texPos.width, 1), gridBGColor); } }