Hi all,
I am trying to make a tooltip appear and so far i have a window that pops up. On this window, on hover over the button, the tooltip appears at a location (Working on dynamic location but i dont have issues with that).
Now the problem is i cant seem to bring my tooltip to be on top of the window.
Do i need to create another window, place my tooltip in it and bring it to front in order for it to hover on top of the button?
Or is there some other way to work around that?
Attached is the Code,
private string _toolTip = "";
public Achievement[] aList;
public Rect achievementWindowRect = new Rect(20, 30, 600, Screen.height-40);
// Use this for initialization
void Start () {
achControl = GetComponent("AchievementController") as AchievementController;
aList = achControl.GetAvaliableAchievements();
achievementWindowRect.x = 20;
achievementWindowRect.y = 30;
achievementWindowRect.width = 600;
achievementWindowRect.height = (Screen.height - 40);
}//end start
void OnGUI(){
if(GUILayout.Button ("Achievement")){
if(showAchievement){
showAchievement = false;
}else{
showAchievement = true;
}//end if else
}//end Achievement
if(showAchievement){
achievementWindowRect = GUILayout.Window(ACHIEVEMENT_WINDOW_ID, achievementWindowRect, AchievementWindow, "Achievements");
}
displayToolTip();
}//end onGui
void AchievementWindow(int windowID) {
int titleWidth = (int)(((achievementWindowRect.width - 40)/10)*3);
int yPos = 20;
GUI.DragWindow(new Rect(0,0,achievementWindowRect.width - 60,20));
GUILayout.Label("");
for(int i = 0; i< listLength;i++){
if(GUI.Button(new Rect(((achievementWindowRect.width/2)- (titleWidth/2)), yPos, titleWidth,40),new GUIContent(aList[i].title,aList[i].ToolTip())))
{
}//end if
yPos += 50;
}//end for
setToolTip();
//TODO: Fix close button
// close button
if(GUI.Button(new Rect(achievementWindowRect.width-60, 0, 50 , 20),"close")){
showAchievement = false;
}//end close button
}//end AchievementWindow
private void setToolTip(){
if(Event.current.type == EventType.Repaint GUI.tooltip != _toolTip){
if(_toolTip != ""){
_toolTip = "";
}//end if
if(GUI.tooltip != ""){
_toolTip = GUI.tooltip;
}//end if
}//end if
}//end setToolTip
private void displayToolTip(){
if(_toolTip != ""){
GUI.Box(new Rect(0,0,400,100), _toolTip);
}//end if
}//end displayToolTip
Thanks in advance (: