I created a Guitexture as my menu, and when the user mouse over on the menu, it shows a tooltip. the tootip itself also should be a guitexture. i tried myself but its not working. Please help :roll:
Make sure the the name of your tooltip is ToolTip Menu.js: Code (csharp): private var toolTip : GUITexture; function Start () { toolTip = GameObject.Find ("ToolTip").guiTexture; } function OnMouseEnter () { ShowIcon (true); } function OnMouseExit () { ShowIcon (false); } function ShowIcon (index : boolean) { if (index) { Screen.showCursor = false; toolTip.enabled = true; } else { Screen.showCursor = true; toolTip.enabled = false; } } ToolTip.js: Code (csharp): function Update () { var x = Input.mousePosition.x / Screen.width; var y = Input.mousePosition.y / Screen.height; transform.position = Vector3 (x, y, 0); } Place this one onto the ToolTip guiTexture.
everything works fine just have some minor problem, whenever the mouse cursor stays on the menu, the tool tip keep flickering in and out, it wont stays.
I'm not sure why it is flickering, but try this: Here's an updated ToolTip.js: Code (csharp): private var z : float; function Start () { z = transform.position.z; } function Update () { var x = Input.mousePosition.x / Screen.width; var y = Input.mousePosition.y / Screen.height; transform.position = Vector3 (x, y, z); } Use this script and make the ToolTip's z position less than the Menu's z position. The tooltip will be behind the menu but this is the only way that I could find to stop the flickering. :?
hmm...since it stays behind no point also :? how bout make it show below the menu? How to set a specific coord for the tooltip on display?
erm weird daniel, your package still showing flickering for me...is it related to the FPS ? i tried ur package on another PC, giving me same result..so im wondering, if it doesnt show flickering to u, why it shows to me.
I made some Tooltip functions in my GUI scripts in the Wiki. http://www.unifycommunity.com/wiki/index.php?title=GUIBuilder If you dont need all the functionality, maybe just cut the code block for Tooltips (I think i commented it) Cheers Shaun
yeah, ive gone tru your GuiBuilder on Unify , and you have a part bout the ContextHelpText. I'd play around with that part, but im having a problem to clean up the script...so i thought if i could get a better solution here
All the times I've encountered flickering it was because of the Z value of the textures / text. Make sure that you stack your Zs in the order you want things to appear. The bigger the Z, the higher the layer where that element will be placed. So if your GUI elements are at Z = 0, for example, make your tooltips with a Z = 0.1 and this should stop the flickering. Regards, Afonso
yes, i tried playing with the Z position as well, my tooltip i set Z=1 and for the GUI element i set Z=0. ive try every advise here and also tried to play out myself still cant get it to work,im confused . The thing still flicker (the check box for the GUITexture in the inspector keep turning on/off, that is why causes flicker in the screen).
If you are using Daniel's code, that has to do with the "Ignore Raycast". I'll try to explain what is hapening with your code. 1 - Once you get on top of a gui element, it calls the OnMouseEnter() function, which makes your tooltip appear. 2 - Once your tooltip appears, the mouse is over it, so it makes OnMouseExit() function of the gui element to be called, which makes the tooltip disappear, which makes you go back to point 1, and you keep on this neverending loop. To solve this problem you should only have to make the tooltip be in the "Ignore Raycast" layer so that the mouse never thinks that it is on top of the tooltip. Another workaround could be simply making the tooltip appear with a little offset from the mouse (i.e. not appear under the mouse pointer). But if you move the mouse quickly it could show the flicker, although only momentarily. Regards, Afonso
Thanks for the explanation I'll try to work around with it, if it still cant work, i might just use codes from shaunl. Regards, Ernest
@Hansuke - the tooltip code is extremely simple in my GUIMethods class. Basically you select one (or more) guiTextures as the 'control' object. When the user mouse overs or exits that control object, the Tooltip displays. Using a 'control' object really simplifies things, because it means the actual tooltip itself needs no interactivity (its either visible or not). The control object can be used (this is not in my code, yet) to determine: 1. Position of the Tooltip 2. Fade in/out duration 3. Text content (if any) and size 4. The display period (before fadeout) As for the code in my GUIMethod example, it just controls a GuiTexture... i cut this out for you: Code (csharp): //---This code is for your 'control' GO //--- MOUSE ENTER void OnMouseEnter(){ if(Frozen==false){ MouseIsOver = true; if(ContextHelpText != null){ ContextHelpText.guiTexture.enabled = true; //Put other Tooltip size/position fade stuff here } } } //--- MOUSE EXIT //--- You might also want to capture mouseUp/Down and do the same function (i.e. if button, hide the tooltip on click) void OnMouseExit(){ if(Frozen==false){ MouseIsOver = false; if(ContextHelpText != null){ ContextHelpText.guiTexture.enabled = false; } } } As you can see, its ridiculously simple, so im not sure its what you're looking for. - Also - i would recommend using integers for guiElement Z Depths, it makes life simpler Cheers Shaun