Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector2Int firstPoint, secondPoint;
- Vector2 selectFirstPoint, selectSecondPoint;
- void RectangleFunction()
- {
- Select.GetComponent<RectTransform>().sizeDelta = new Vector2();
- if (Input.GetMouseButtonDown(0))
- {
- firstPoint = OnPixelInt();
- selectFirstPoint = GlobalMousePosition();
- }
- if (Input.GetMouseButton(0))
- {
- selectSecondPoint = GlobalMousePosition();
- Vector2 Center = (selectFirstPoint + selectSecondPoint) / 2;
- 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));
- Select.transform.position = Center;
- }
- if (Input.GetMouseButtonUp(0))
- {
- secondPoint = OnPixelInt();
- for (int y = Mathf.Min(firstPoint.y, secondPoint.y); y <= Mathf.Max(firstPoint.y, secondPoint.y); y++)
- {
- for (int x = Mathf.Min(firstPoint.x, secondPoint.x); x <= Mathf.Max(firstPoint.x, secondPoint.x); x++)
- {
- if (0 <= y && y < WorkshopScript.pixelsCountY && 0 <= x && x < WorkshopScript.pixelsCountX)
- {
- WorkshopScript.SelectedLayer.SetPixel(x, y, ColorsScript.GetColor());
- }
- }
- }
- WorkshopScript.SelectedLayer.Apply();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement