Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dju4ic · Aug 07, 2013 at 06:54 PM · c#windowfocustooltip

C# Tooltips through multiple windows

I am currently working on a script to auto-focus on the Gui window that is hovered over, the problem I am having is the window focus and tooltips. It seems as if the focus is shifted to the window, but the tooltips in the window will not show still until it is clicked on (manually focused).

Easy to test, just float over the windows, if the tooltip on the label doesnt show, click it and then it will.. Any ideas on how to fix this issue?

 using UnityEngine;
 using System.Collections;
 
 public class TestScript : MonoBehaviour {
     Rect charwindowRect = new Rect(10, 10, 200, 60);
     Rect inventoryRect = new Rect(10, 80, 200, 60);
     Rect tooltipRect = new Rect(10, 150, 200, 60);
     
     private string _tooltip;
     private int _tempfocus;
     
     void OnGUI() { 
         charwindowRect = GUILayout.Window(3, charwindowRect, CharWindow, "Char window");
         inventoryRect = GUILayout.Window(2, inventoryRect, InventoryWindow, "Inventory");
         tooltipRect = GUILayout.Window(1, tooltipRect, TooltipWindow, "Tooltips");
     }
     
     void CharWindow(int windowID) { 
         FocusWindow(charwindowRect, windowID);
         
         GUILayout.BeginHorizontal();
             GUI.Label(new Rect(25,20,265,20),  new GUIContent("char", "charwindow tooltip"));
         GUILayout.EndHorizontal();
         
         if (Event.current.type == EventType.Repaint) {
             _tooltip = GUI.tooltip; 
         }
     }
     
     void InventoryWindow ( int windowID) { 
         FocusWindow(inventoryRect, windowID);
         
         GUILayout.BeginHorizontal();
             GUI.Label(new Rect(25,20,265,20),  new GUIContent("inv", "inv window tooltip"));
         GUILayout.EndHorizontal();
         
         if (Event.current.type == EventType.Repaint) {
             _tooltip = GUI.tooltip; 
         }
     }
     
     void TooltipWindow ( int windowID) { 
         GUILayout.BeginHorizontal();
             GUI.Label(new Rect(25,20,265,20), _tooltip );
         GUILayout.EndHorizontal();
     }
     
     void FocusWindow(Rect thisRect, int windowID) { 
             if(thisRect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
             {
                 if(_tempfocus != windowID) {
                 _tempfocus = windowID;
                 GUI.FocusWindow(windowID);
             }
         }
     }
 }
 
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dju4ic · Aug 07, 2013 at 09:45 PM 0
Share

Awesome, just added in GUI.BringWindowToFront(windowID) in the FocusWindow function, it now focuses and shows tooltip. Thanks!

avatar image Molix · Aug 08, 2013 at 07:56 PM 0
Share

We've just noticed in our game that GUI.tooltip is not being set unless the window has focus, and that is definitely new behaviour. Previously we were able to do something like what you have without requiring a focus change. Has anyone else noticed this? (I have tried in 4.1.0 and 4.1.3).

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by AVividLight · Aug 07, 2013 at 09:10 PM

Hey dju4ic,

You should try using GUI.BringWindowToFront, it may be your problem.

I hope this helps! -Gibson

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Keeping Unity Focused 0 Answers

Trouble using C# tooltips 1 Answer

On object clicked open a window using C# 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges