为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > 鼠标悬停显示tips的另类方法

鼠标悬停显示tips的另类方法

2018-04-30 3页 doc 14KB 7阅读

用户头像

is_196623

暂无简介

举报
鼠标悬停显示tips的另类方法鼠标悬停显示tips的另类方法 1. var buttonText : GUIContent = new GUIContent("some dasdfgwbutton"); 2. var buttonStyle : GUIStyle = GUIStyle.none; 3. var leftPosition:float; 4. var topPosition:float; 5. var btn_w :float; 6. var btn_h :float; 7. public var isOver; 8. publ...
鼠标悬停显示tips的另类方法
鼠标悬停显示tips的另类方法 1. var buttonText : GUIContent = new GUIContent("some dasdfgwbutton"); 2. var buttonStyle : GUIStyle = GUIStyle.none; 3. var leftPosition:float; 4. var topPosition:float; 5. var btn_w :float; 6. var btn_h :float; 7. public var isOver; 8. public var create; 9. 10. 11. 12. function Awake(){ 13. isOver = false; 14. create = false; 15. } 16. function Update(){ 17. Over(); 18. } 19. 20. function OnGUI() { 21. 22. GUILayout.Button( "My button" ); 23. if(Event.current.type == EventType.Repaint && 24. GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition )) { 25. //GUILayout.Label( "Mouse over!" ); 26. create = true; 27. if(isOver == true){ 28. if(btn_w<100&&btn_h<200){ 29. btn_w+=1; 30. btn_h+=2; 31. } 32. GUI.Window(0,Rect(leftPosition,topPosition,btn_w,btn_h),ShowTips,""); 33. } 34. }else{ 35. create = false; 36. } 37. 38. var rt : Rect = GUILayoutUtility.GetRect(buttonText, buttonStyle); 39. if (rt.Contains(Event.current.mousePosition)) { 40. create = true; 41. if(isOver == true){ 42. if(btn_w<100&&btn_h<200){ 43. btn_w+=1; 44. btn_h+=2; 45. } 46. } 47. GUI.Label(Rect(leftPosition,topPosition,btn_w,btn_h), "PosX: " + rt.x + "\nPosY: " + rt.y + 48. "\nWidth: " + rt.width + "\nHeight: " + rt.height); 49. } 50. GUI.Button(rt, buttonText, buttonStyle); 51. } 52. function ShowTips(windowID:int){ 53. if(isOver == true){ 54. GUI.Box(Rect(0,0,btn_w,btn_h),"Mouse over!"); 55. } 56. } 57. function Over(){ 58. if(create == true){ 59. leftPosition = Input.mousePosition.x; 60. topPosition = Screen.height - Input.mousePosition.y; 61. isOver = true; 62. }else{ 63. btn_w = 0; 64. btn_h = 0; 65. } 66. }
/
本文档为【鼠标悬停显示tips的另类方法】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索