SHARE
TWEET

Untitled

a guest Jul 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Vector2Int firstPoint, secondPoint;
  2.     Vector2 selectFirstPoint, selectSecondPoint;
  3.     void RectangleFunction()
  4.     {
  5.         Select.GetComponent<RectTransform>().sizeDelta = new Vector2();
  6.  
  7.         if (Input.GetMouseButtonDown(0))
  8.         {
  9.             firstPoint = OnPixelInt();
  10.             selectFirstPoint = GlobalMousePosition();
  11.         }
  12.  
  13.         if (Input.GetMouseButton(0))
  14.         {
  15.             selectSecondPoint = GlobalMousePosition();
  16.             Vector2 Center = (selectFirstPoint + selectSecondPoint) / 2;
  17.             Select.GetComponent<RectTransform>().sizeDelta = new Vector2(Mathf.Max(selectFirstPoint.x, selectSecondPoint.x) - Mathf.Min(selectFirstPoint.x, selectSecondPoint.x), Mathf.Max(selectFirstPoint.y, selectSecondPoint.y) - Mathf.Min(selectFirstPoint.y, selectSecondPoint.y));
  18.             Select.transform.position = Center;
  19.         }
  20.  
  21.         if (Input.GetMouseButtonUp(0))
  22.         {
  23.             secondPoint = OnPixelInt();
  24.  
  25.             for (int y = Mathf.Min(firstPoint.y, secondPoint.y); y <= Mathf.Max(firstPoint.y, secondPoint.y); y++)
  26.             {
  27.                 for (int x = Mathf.Min(firstPoint.x, secondPoint.x); x <= Mathf.Max(firstPoint.x, secondPoint.x); x++)
  28.                 {
  29.                     if (0 <= y && y < WorkshopScript.pixelsCountY && 0 <= x && x < WorkshopScript.pixelsCountX)
  30.                     {
  31.                         WorkshopScript.SelectedLayer.SetPixel(x, y, ColorsScript.GetColor());
  32.                     }
  33.                 }
  34.             }
  35.             WorkshopScript.SelectedLayer.Apply();
  36.         }
  37.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top