Tracked grid space position of the mouse
This commit is contained in:
@@ -1302,9 +1302,9 @@ RectTransform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1944344878}
|
- {fileID: 1944344878}
|
||||||
- {fileID: 2112507919}
|
- {fileID: 2112507919}
|
||||||
- {fileID: 1330313875}
|
|
||||||
- {fileID: 2026916298}
|
- {fileID: 2026916298}
|
||||||
- {fileID: 96288173}
|
- {fileID: 96288173}
|
||||||
|
- {fileID: 1330313875}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
@@ -1516,7 +1516,7 @@ MonoBehaviour:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1330313874}
|
m_GameObject: {fileID: 1330313874}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Fruitomation.Game;
|
using Fruitomation.Game;
|
||||||
using UnityEngine;
|
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()
|
private void Update()
|
||||||
{
|
{
|
||||||
UpdateMouseState();
|
UpdateMouseState();
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
|
CalculateGridPosition();
|
||||||
|
|
||||||
RectTransform.localScale = new Vector3(CurrentMouseClickStrength, CurrentMouseClickStrength, 1f);
|
RectTransform.localScale = new Vector3(CurrentMouseClickStrength, CurrentMouseClickStrength, 1f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user