- Home /
Question by
alesten · Dec 04, 2013 at 12:20 PM ·
UI AND UNITY POSITION
I have this problem, that I want to be able to click on a "tile" on the screen and then a pop-up menu should be shown just next to the tile. I can click on the tile and then a pop-up menu shows up but not where I want it.
On the picture below I've clicked on the top left one.
My code for placing the picture is as following:
using UnityEngine; using System.Collections;
public class TowerMenu : MonoBehaviour { bool showMenu = false; float x; float y; GUIStyle myStyle;
public Texture2D[] towers;
void OnGUI()
{
if(showMenu)
{
//Bear tower
GUI.Button(new Rect(x + 10, y - 25, 50, 50), towers[0]);
//Seal tower
GUI.Button(new Rect(x + 10, y + 25, 50, 50), towers[1]);
}
}
public void ShowMenu(Vector2 pos)
{
showMenu = true;
x = pos.x;
y = pos.y;
}
}
Hope anyone can help me
Comment
Your answer
Follow this Question
Related Questions
Cloud recognition in Vuforia 0 Answers
How to embed a Unity3D into Joomla 1 Answer
School Tour Game 0 Answers
Basic scripting help (FPS Tutorial) 1 Answer
Listener for GUIText.text change? 0 Answers