Skip to content

Commit

Permalink
Fixing Canvas so UI looks better on android devices and smaller screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Menyueru committed Nov 27, 2016
1 parent 687c094 commit 059dc91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Binary file modified Assets/Scenes/Game.unity
Binary file not shown.
11 changes: 10 additions & 1 deletion Assets/Scripts/BoardHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,23 @@ public void Exit()
Application.Quit();
}

private bool IsPointerOverUIObject()
{
var eventDataCurrentPosition = new PointerEventData(EventSystem.current);
eventDataCurrentPosition.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
var results = new List<RaycastResult>();
EventSystem.current.RaycastAll(eventDataCurrentPosition, results);
return results.Count > 0;
}

// Update is called once per frame
void Update()
{
if (life <= 0)
{
SceneManager.LoadScene("Game");
}
if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject())
if (Input.GetMouseButton(0) && !IsPointerOverUIObject())
{
if (SelectedGameObject != null)
{
Expand Down
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.

0 comments on commit 059dc91

Please sign in to comment.