Tracked grid space position of the mouse
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Fruitomation.Game;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -68,10 +69,26 @@ namespace Fruitomation.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateGridPosition()
|
||||
{
|
||||
Vector2 p0 = RectTransform.anchoredPosition;
|
||||
Vector2 p1 = p0 - new Vector2(0, 100f); // Offset of the grid from the middle of the screen
|
||||
Vector2 p2 = p1 / 40f;
|
||||
Vector2 p3 = p2 + new Vector2(48f, 24f); // Half size of the grid
|
||||
Vector2Int p4 = Vector2Int.FloorToInt(p3);
|
||||
Vector2Int p5 = new
|
||||
(
|
||||
Math.Clamp(p4.x, 0, 95), // size.x - 1
|
||||
Math.Clamp(p4.y, 0, 48) // size.y - 1
|
||||
);
|
||||
Debug.Log(p5);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateMouseState();
|
||||
UpdatePosition();
|
||||
CalculateGridPosition();
|
||||
|
||||
RectTransform.localScale = new Vector3(CurrentMouseClickStrength, CurrentMouseClickStrength, 1f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user