• button和Rect上悬停显示tips


    转自:http://www.cnblogs.com/Mygirl/archive/2011/07/07/2099740.html

    /*button 和Rect上悬停显示tips */
    var buttonText : GUIContent = new GUIContent("some dasdfgwbutton");
    var buttonStyle : GUIStyle = GUIStyle.none;
    var leftPosition:float;
    var topPosition:float;
    var btn_w :float;
    var btn_h :float;
    public var isOver;
    public var create;
    
    function Awake(){
      isOver = false;
      create = false;
    }
    function Update()
    {   Over(); }
    function OnGUI()
    {   GUILayout.Button(
    "My button" );   if(Event.current.type == EventType.Repaint &&     GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition ))
      {
        //GUILayout.Label( "Mouse over!" );     create = true;     if(isOver == true)
        {
          if(btn_w<100&&btn_h<200)
          {         btn_w
    +=1;         btn_h+=2;     }     GUI.Window(0,Rect(leftPosition,topPosition,btn_w,btn_h),ShowTips,"");     }   }else
      {     create = false;   }   var rt : Rect = GUILayoutUtility.GetRect(buttonText, buttonStyle);   if (rt.Contains(Event.current.mousePosition))
      {     create
    = true;     if(isOver == true)
        {
          if(btn_w<100&&btn_h<200)
          {         btn_w
    +=1;         btn_h+=2;       }     }     GUI.Label(Rect(leftPosition,topPosition,btn_w,btn_h), "PosX: " + rt.x + "\nPosY: " + rt.y +       "\nWidth: " + rt.width + "\nHeight: " + rt.height);   }   GUI.Button(rt, buttonText, buttonStyle); }
    function ShowTips(windowID:int)
    {   
    if(isOver == true)
      {     GUI.Box(Rect(
    0,0,btn_w,btn_h),"Mouse over!");   } }
    function Over()
    {   
    if(create == true)
      {     leftPosition
    = Input.mousePosition.x;     topPosition = Screen.height - Input.mousePosition.y;     isOver = true;   }else
      {     btn_w = 0;     btn_h = 0;   } }
  • 相关阅读:
    什么是透视图?
    Eclipse 视图
    Eclipse 菜单
    Eclipse 窗口说明
    Eclipse 修改字符集
    Eclipse 安装(Oxygen版本)
    Eclipse 教程
    jQuery 教程
    就表单验证说用户体验
    需要配置执行path?no
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/2788796.html
Copyright © 2020-2023  润新知