diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 186bbc1..351a2b1 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1302,9 +1302,9 @@ RectTransform: m_Children: - {fileID: 1944344878} - {fileID: 2112507919} - - {fileID: 1330313875} - {fileID: 2026916298} - {fileID: 96288173} + - {fileID: 1330313875} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -1516,7 +1516,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1330313874} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: diff --git a/Assets/Scripts/UI/GameCursor.cs b/Assets/Scripts/UI/GameCursor.cs index 3045db0..a810218 100644 --- a/Assets/Scripts/UI/GameCursor.cs +++ b/Assets/Scripts/UI/GameCursor.cs @@ -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); }