Search Unity

[Released] ProTips - Tooltip System for UGUI

Discussion in 'Assets and Asset Store' started by zangad, Aug 25, 2015.

  1. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,664
    The Mega Sale runs until December 8th.
     
  2. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    Thx Mauri! Hoping this Asset can dovetail with ui3dobject...
     
  3. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Yes, I was able to test out the UIObject3D with ProTips tonight, and it worked great. UIObject3D is a very neat asset. Since it inherits from Image, setting up a new tooltip template with a 3D object is as simple as replacing the image with the UIObject3D script. Then, at runtime, you can assign/change the Transform the script renders.

    Here's how to do it:

    1) First, create a new tooltip template that uses the UIObject3D component instead of an Image.



    2) Add code that holds the 3D object you want in the tooltip, and that gets a reference to the UIObject3D component and sets it to point to your 3D object when the tooltip is triggered.



    Results:



    And here's a video showing a little more of the results:



    Hope that helps!
     
    Last edited: Nov 29, 2017
  4. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    Wow! Excellent. Sold.
     
  5. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
    Hi @zangad ,

    Quick questions :
    1. Can I force my tooltip to not exceed the screen ?
    2. Can I have a tooltip following mouse ?
    Thks
     
  6. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @TheGoodDrive,

    1) Yes, you can force a tooltip to not exceed the screen. On the TooltipManager, there is a global setting to turn on/off Overflow Protection. If you turn this on, it will check if the tooltip flows off the canvas, and if so, it will flip the tooltip so it's on the other side of the trigger element. You can turn this off if you don't need it, to save a few extra logic checks and increase performance slightly.



    2) No, ProTips doesn't currently have the option to force tooltips to follow the mouse. That's a good idea, though! I've seen that effect on older or retro-styled games. I've added this to our feature backlog.
     
  7. TheGoodDrive

    TheGoodDrive

    Joined:
    Sep 23, 2015
    Posts:
    9
  8. Goldensnitch

    Goldensnitch

    Joined:
    Nov 4, 2016
    Posts:
    60
    Hello Zangad i have little problem with fonts. How do i change the fonts. Cause on webgl my fonts are not visible. How do i change the font my own font on the tooltip.
    Also is it possibe can you make 3d clickable tooltip billboard annotation that can be included in your asset. Thank you
     
  9. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @Goldensnitch,
    To change the font for a tooltip, open the Tooltip Workshop scene and find the tooltip you want to change. Click the element you want to change to select it. In the Inspector, change the font field in the Text element to a custom font in your project. The font will need to be a TrueType (.ttf) or Open Type Face (.otf) font.

    We haven't had to do anything special to get fonts to work properly in a WebGL project. Our ProTips Demo is a WebGL project, and has custom fonts on most of its tooltips (see the Copper Simple and SciFi Simple buttons).

    Some things that might help isolate the problem:
    • What browser are you using to test your WebGL project?
    • Are the fonts not visible across all browsers, or just some of them?
    • Are the custom fonts not visible only in ProTips tooltips, or are they also not visible in other places on your application?
    • Are you using standard Unity Canvas Text elements, or are you using something like TextMeshPro or Unity's legacy GUI system?
    • Are the fonts visible when you do a Windows/Mac build, but not when you do an HTML5 build? If so, you might check your Quality settings for differences between the two build types. (Your WebGL build may be using more aggressive settings for performance, which could be causing a problem.)
    • Check your browser's dev tools while loading your WebGL project to see if errors are being reported in the console. (In Chrome: With your website open, hit F12 and click on the Network tab. Select Disable Cache. Click on the Console tab. Then refresh the page (CNTL+F5) and after the page loads, check both Network and Console tabs for errors.
    All in all, though, you shouldn't have to do anything special to get custom fonts to work in WebGL with ProTips. We just use the standard Unity Canvas, Text elements, and fonts. No special shaders or anything.

    Do you mean 3D as in a mesh, like an .obj or .fbx file? If so, that's not something we're looking into for ProTips, because 3D objects don't make use of the Unity Canvas, and that's the primary focus of ProTips. While it would be possible to display a 3D object at a tooltip's location (the transform.location vector in world space), the complexity comes when you want to resize or flip a 3D object to prevent it from overlapping the canvas.

    ProTips tooltips were designed to be flexible in size and still look good with expandable borders, headers, and docked image areas. To do the same with 3D objects would probably require creating dynamic meshes, which is outside the scope of ProTips. If you can expand on what you envision for the 3D tooltip and how to overcome the limitations, we would definitely consider it. I like the idea, just don't know how to do it and keep it within scope. :)
     
    Last edited: Jan 30, 2018
  10. Goldensnitch

    Goldensnitch

    Joined:
    Nov 4, 2016
    Posts:
    60
    It will be so helpful to me if Protips support cyrillic fonts on webgl. I am stack hehe. Thank you for your advice Zangad.
     
  11. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Are you using a font that supports Cyrillic characters, and are you making sure the font is included in your project? Here are a few you can try it out with: https://www.lingualift.com/blog/cyrillic-russian-fonts/

    Searching for Unity and WebGL turned up this post:
    https://forum.unity.com/threads/lan...e-a-numbers-english-only.339376/#post-2197613

    "Are you using a font which has cyrillic characters? On other platforms, it would just get these characters from OS fonts. In WebGL, it cannot do that, as WebGL cannot access your font ttf files on disk. So you need to supply a font which has the characters you need.

    From the docs (http://docs.unity3d.com/Manual/class-Font.html)"​

    I was able to do a WebGL build and change the font to a Cyrillic font. I used this one, if you want to try it out.
    https://www.dafont.com/days.font

    cyrillic.png
     
  12. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Hey there, I'm using inventory pro and the default tooltip provided isn't as configurable as I'd like.
    I saw ProTips and it has apparently what I require... only issue is that I'm no coder (building everything with Playmaker so far)

    So here are the 2 important questions before buying:
    -I read that there are no Playmaker support but you could help with actions here and there. But would I require Playmaker for the tooltip itself? With Playmaker there is a full Unity GUI support and I can interact with everything and change text or images on the fly. So what would be required code wise to use ProTips?

    -That's going to be more challenging I guess, but maybe you already have figured it out (even though I didn't see anyone on the forums requesting that). As I'm using Inventory pro, a lot of information are already set for my items (such as Rarity, price, category, stats...). Is there a way (that doesn't involve coding :D) to grab those different information and have them on a tool tip ingame? I'm thinking about objects in my inventory. If I mouse over an item, I'd like to have ProTips displaying whatever I want and of course those Inventory Pro stats and info (not all always, I need to customise depending on the item)

    Hope that last part would be achievable somehow

    Thanks a lot
     
  13. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Necka,
    ProTips creates Unity UI elements and positions, fades, and resizes them based on a set of rules coded into the scripts. The system was designed to be very flexible and save you time - it works out of the box to provide most of the features you'd want, and you can extend the code to handle almost any scenario.

    However, there's no third-party support for visual scripting tools at this time. One of the reasons is, there are multiple visual scripting tools, so if we did make a version of ProTips fully integrated with Playmaker, we'd need to make another version for Bolt, and so on.

    As you said, you might be able to get it to work for your needs using Playmaker to manipulate images and text. I've created some very simple Playmaker Actions, but most who want Playmaker support want full integration, and that's unfortunately a larger undertaking.
    It's certainly possible to pull information into the tooltips - the starter templates we provide in the demo scene have placeholders that are replaced with data at runtime. But currently, it requires changing the scripts to suit your needs. That's not to say we won't add Playmaker support in the future (it's on our list, and every request increases the likelihood), but currently there is no integration.
     
  14. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Thanks for the information. From what I've read in the documentation and what you confirmed here; I think I won't have the skills to update the dynamic tooltips with code here (like feeding dynamically the equipped items while hovering over the character inventory)

    It would clearly requires some Playmaker actions to manage that with no coding skills :(

    But I'll wait, I will follow this forum and the asset store page, hopefully you guys will implement that one day :)

    Thanks a lot
     
  15. Goldensnitch

    Goldensnitch

    Joined:
    Nov 4, 2016
    Posts:
    60
    Hi Zangad, Its me again. Is it possible to attach xml files to this tooltip. So it will be easy i could rather type texts directly into Dynamic text fields. If its possible please guide me thank you Zangad
     
  16. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I would like to have two tooltips on the same game object. but with different delays, a short delay for a basic information tooltip, and a longer delay to display a tooltip with more detailed information. However, I see the time delay is in the manager, and not on the trigger component. What would be the way to accomplish this?

    Also, I have a slight problem using tooltips with my third person controller. My own character can get between the main camera and a game object, blocking the trigger action. Any thoughts on this? The player can always zoom in to first person view and activate the tool tip, but I was wondering if maybe layers or something could solve this problem.

    Great asset, by the way.
     
    pavonis likes this.
  17. Lohrion

    Lohrion

    Joined:
    Aug 16, 2013
    Posts:
    107
    Hi there,

    I'm currently reworking an ingame tutorial with ProTips. Sometimes I'd like to show a window centered just in the middle of the screen (though the CanvasTopMiddle position is ok for now). I understood that all tooltips have to be anchored to another gameobject. So how exactly would I go about this?

    Is there maybe a tutorial that shows some best practices on how to create a tutorial with this?

    And I have a suggestion, it would be nice to be able to add a callback for a button from code. I've added the following lines to the Popup function of the TooltipTrigger class to achieve this, along with a parameter of type Action:
    Code (CSharp):
    1.          
    2. var button = Tooltip.GameObject.GetComponentInChildren<Button>();
    3.  
    4. if (button != null)
    5. {
    6.     button.onClick.AddListener(() => { buttonDelegate(); });
    7. }
    8.  
    Kind regards,
    Patrick
     
    Last edited: May 11, 2018
  18. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @zangad , can you create a tooltip template with a scrollable area (which could contain list of skills or stats say) by way of an example in the Asset... Would help a lot... ;)

    So say %equipped% or %stats% as scrollable areas?
     
  19. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Duffer123,

    Thank you for the suggestion, we had another customer who was also interested in getting ProTips working with scrollable areas. I've bumped this feature up to the top of our backlog and added notes to it. We will take a look at it as soon as we can. Thanks!
     
    Last edited: Aug 27, 2018
    Duffer123 likes this.
  20. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Goldensnitch,

    Sorry for the late reply, we didn't get notified that there was a post on the forum so we just saw this.

    Yes, it is possible to attach XML files to tooltips, but it's not something we would be looking to add at this time, as it would complicate the code and make it harder to integrate into people's projects who aren't wanting to use XML (ie, they have simple tooptip needs).

    However, you can extend the code to do this yourself. You would just need to create a new class for your tooltip, say TooltipXml, and then read your XML file into an instance of the class. Once you have that, you could populate the fields on the tooltip.

    Here's an example on StackOverflow of how to read an XML file into a class in C#. This is where I'd start:
    https://stackoverflow.com/questions...l-file-into-c-sharp-class-using-serialization
     
  21. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi wood333,

    Sorry for the late reply, we didn't get notified that there was a post on our forum, so we missed it.

    Thanks for your request, I think what would help is to have a TooltipDelay Override on the Tooltip Trigger script. This way, you could set the default delay for all tooltips, but then override it for specific ones, like in your example you could make the delay longer for your detailed information tooltips.

    I've added a task to our backlog to add this tooltip delay override to the TooltipTrigger script. However, if you want to implement it now and you know some coding, you can take a look at the TooltipTrigger.cs script, in the Update() method, and you will see this:
    Code (CSharp):
    1. tooltipDelay = TooltipManager.Instance.tooltipDelay;
    So in the TooltipTrigger, it is just setting the delay to whatever is specified in the TooltipManager. You could create your own public variable at the top of the TooltipTrigger script called tooltipDelayOverride and write a simple IF statement to use that variable if it exists, otherwise use the one on the TooltipManager. Like so:
    Code (CSharp):
    1. if (tooltipDelayOverride != 0f)
    2.     tooltipDelay = tooltipDelayOverride;
    3. else
    4.     tooltipDelay = TooltipManager.Instance.tooltipDelay;
    It sounds like what's happening is your character controller is blocking the OnMouseOver() event of the tooltip trigger. The simple fix for this is to assign your character controller game object to the Ignore Raycast layer. That will allow OnMouseOver() events to pass right through the character controller and onto the tooltip trigger.
     
    wood333 likes this.
  22. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Lohrion,

    Thanks for the suggestion. We don't currently have a way to display a tooltip in the center of the screen, but that's a good feature to have, and it rounds out the Canvas Top Middle and Canvas Bottom Middle tooltip positions we added for another customer.

    I've added this suggestion to our development backlog. For now, if you need to implement this before we can get around to adding/testing/publishing it, I would suggest adding a new TipPosition to the enum called CanvasMiddle. Here's the code for positioning it properly in the TooltipExtensions.cs script, SetPosition() method.

    This code displays the tooltip in the center of the canvas:
    Code (CSharp):
    1. case TipPosition.CanvasMiddle:
    2.     offsetVector = new Vector2(0, style.tipOffset);
    3.     pos = triggerCorners[1] + (triggerCorners[3] - triggerCorners[1]) / 2;
    4.     tooltipRectTrans.pivot = new Vector2(.5f, .5f);
    5.     tooltipRectTrans.anchorMin = tooltipRectTrans.anchorMax = new Vector2(.5f, .5f);
    6.     bkgImage.sprite = style.bottomMiddle;
    7.     break;
     
    Duffer123 likes this.
  23. NandusMasta

    NandusMasta

    Joined:
    Apr 9, 2011
    Posts:
    63
    Hi. I am having problems with your asset, I use it extensively on my project and there is a particular issue with it now, that's wrecking my brain; mostly because I can't reproduce it 100% of times.

    Basically what happens is that the TooltipManager.Instance.TooltipContainer is destroyed, some time before a StarHover event fires and the TooltipTrigger attempts to initialize itself. That's when I get a MissingReferenceException then. You can find the full error trace bellow:


    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    ModelShark.TooltipTrigger.Initialize () (at Assets/ProTips/Scripts/Behaviors/TooltipTrigger.cs:73)
    ModelShark.TooltipTrigger.StartHover () (at Assets/ProTips/Scripts/Behaviors/TooltipTrigger.cs:213)
    ModelShark.TooltipTrigger.Update () (at Assets/ProTips/Scripts/Behaviors/TooltipTrigger.cs:97)


    The real problem is that I can't reproduce this error consistently, my game is turn based and this can happen anywhere from turn 12 to turn 88(last two times I reproduced it). I load other scenes through an async process, but this doesn't seem to affect the issue, since it happens regardless.

    Do you have any idea why this could be? Without a clear indication of how to generate the error, I won't be able to send you an example or anything. However any tips you can give me to check, would be greatly appreciated. This represents the last major bug in my game I need to crack. In any case thanks in advance.
     
  24. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi NandusMasta, thanks for reaching out to us.

    It looks like the error is happening on TooltipTrigger.cs line 73, which calls into the TooltipManager.Instance, and judging by the missing reference exception, it's probably trying to access the script to create the instance, but it doesn't exist at that point for some reason (maybe it's being destroyed during scene changes?).

    Are you persisting the TooltipManager instance across scene loads with DontDestroyOnLoad()? If not, you might give that a try. In the Awake() method on TooltipManager.cs, change it to the following:
    Code (CSharp):
    1. private void Awake()
    2. {
    3.     instance = this;
    4.     DontDestroyOnLoad(this.gameObject);
    5.     if (!isInitialized)
    6.         Initialize();
    7. }
    Also, to prevent duplicate TooltipManager objects from being created on each scene, you'll need to remove them from the Hierarchy on all your scenes except the first one.

    The idea is, when the player first starts your game and enters the first scene, a TooltipManager instance is created, and that instance of the object will persist from scene to scene until the player leaves the game.

    Please let us know if that doesn't fix your issue and we can investigate further.
     
  25. NandusMasta

    NandusMasta

    Joined:
    Apr 9, 2011
    Posts:
    63
    Hi zangad. Thanks for the quick reply on this. Sadly I already tried to persis the TooltipManager object between scenes, without any success. The error happens even if I don't change scenes. Basically I have a menu, main and battle scenes. If I start and play from the game scene, without loading the battle or menu scenes, the error still happens.

    Now I noticed that the code moves the TooltipContainer(which is the object for which the code looses the reference for), by parenting it to the parent canvas of the TooltipTrigger object. I have lots of in world canvases in my UI and depending on the case, these can trigger a tooltip. What I did is disregard that and keep the TooltipContainer parented to the main UI canvas. I am still testing, but it seems more stable now.

    I am working on the assumption that somehow the parent object get deleted in game(still can't find where exactly though), thus causing the missing reference on the script. I will let you know if that is the case in the end. Thanks again for your time on this.
     
  26. Caffeen

    Caffeen

    Joined:
    Dec 25, 2013
    Posts:
    34
    Hello, first off, this is a fantastic asset. Has really saved me a lot of time so far, so thanks!

    The only issue I'm having is that I haven't been able to get the TurnSectionOff methods to work. My understanding is that it's supposed to deactivate the game object associated with the dynamic field name string you pass in, yes?

    Is there anything in particular I need to know to get it to work? I've tried calling it right before enabling the TooltipTrigger component, and I've also tried calling it right after enabling it, and the field I'm trying to deactivate still shows up.

    I would really appreciate any guidance, because I feel like I must be using it incorrectly. Thank you!
     
  27. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Caffeen,
    Thank you for the kind words! :)

    Thanks for reaching out to us with your question. I did some research, and in looking at the code, ProTips doesn't care what the name of your gameobject is - only what the name of the DynamicSection placeholder is. If you look at the "Grunge" tooltip used in the demo scene that has a DynamicSection used for showing inventory item comparison, you can click on the dynamic part and see that it has a script on it called DynamicSection with a placeholder called EquipmentItem.



    The DynamicSection's Placeholder Name is the name it is looking for in the sample code to turn on/off that section. It just so happens that in this case, the name of the dynamic section placeholder is the same as the name of the gameobject. I can see how that would cause confusion - sorry about that! But if you just make sure to include a DynamicSection script on the part you want to show/hide, and then give it a name that matches what your code is looking for, it should work.

    I hope that helps. But please let us know if you still have trouble and we can take a look at your project and further debug what's going on.
     
    Caffeen likes this.
  28. Caffeen

    Caffeen

    Joined:
    Dec 25, 2013
    Posts:
    34
    My mistake was not realizing that the "DynamicSection" component existed; I was under the impression that it used the string that referenced the text field the same way as SetText().

    With this extra information it works perfectly. Thank you for your help!
     
  29. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    Hi, love the package, just running into a wee bit of weirdness with it at the moment. So I have some static buttons, etc. in my UI that have tooltips on them. They work great! However, I have a series of RawImages on my UI that I want to have tooltips on. They work fine until I make them a prefab and instantiate them via code, then no bueno. :(

    It is basically a series of a dozen or so small RawImages that are layed out in a horizontal Grid element.

    EDIT: I removed the script from the prefab and added it to the image's GameObject at runtime in code, but still no love. I'm wondering if it has to do with the Grid?

    EDIT: I took a working image/tooltip combo and put it in a new grid, and the tooltip stops working. So that's my best guess at this point.

    Any ideas?
     
    Last edited: Nov 8, 2018
  30. dogfacedesign

    dogfacedesign

    Joined:
    Jan 10, 2016
    Posts:
    70
    Figured it out ... just needed to add a Graphics Raycaster to my canvas .... derp.
     
    Duffer123 likes this.
  31. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi dogfacedesign,

    Glad you figured it out. Thanks for posting your question and solution, so it might help others who may run into this in the future.
     
    dogfacedesign and Duffer123 like this.
  32. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @zangad , any chance of scrollable sections in tooltips examples in a new release?
     
  33. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    We're trying to wrap up an update to DestroyIt at the moment, but we'll try to get to this as soon as possible.
     
    Duffer123 likes this.
  34. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @DeadlyAccurate ,

    Excellent. As soon as. Going to take a look at DestroyIt.
     
  35. Razeoryuno

    Razeoryuno

    Joined:
    Feb 28, 2018
    Posts:
    5
    Hi, your asset is very good to start off tooltip in my project. Right now I working on Interactable Text which will show a tooltip when hovering. It not a direct approach for this asset. I mainly follow your AddTooltipDynamically and found a little trouble.

    Since in my scene I don't have any TooltipTrigger component add. And the TooltipContainer will not pre-load TooltipStyle for me. This give me 1 null reference exception ( it happen on Tooltip.WarmUp() method) the first time i try to show it with my own logic (that using LateUpdate). I try to fix this by dummy TooltipTrigger in my scene and disable it right away.

    Is there any proper way to pre-load the TooltipStyle or revamp my idea of using it.

    Thank, And sorry for my bad English.
     
  36. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Razeoryuno,

    I think what would be easiest is if you can upload your project and share it with us. I can take a look and see what you're trying to do and see if I can fix it. But from your description, I don't fully understand what the scenario is, or why it's failing.

    If you can't upload your project, then a video that demonstrates the issue or the effect you're trying to achieve would be helpful.

    Just going off your description, for interactive text (such as a textbox), I would put the tooltip trigger on the textbox and set it to a tooltip prefab, that way it would be pre-loaded in the tooltip container. And assuming I wanted to show or react in some way to the text in the input box, my script would be on the same gameobject as the tooltip trigger, so it could find the tooltip and change the text appropriately.

    But this is just going off my interpretation of the desired effect. I would need to see your project or a similar scenario so I could try to reproduce it and help.

    You can email us directly at modelsharkstudio@gmail.com and we'll work with you to solve the problem.
     
  37. Razeoryuno

    Razeoryuno

    Joined:
    Feb 28, 2018
    Posts:
    5
    Hi @zangad,

    Thank for the quick response. I sent you an email with sample project.
     
  38. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    @Razeoryuno,

    I checked our email and I still don't see anything. I checked the Spam folder, too, and didn't see anything in there. We also did a quick test and were able to send an email to ourselves, so the email address appears to be working fine.

    Can you check the email address? Note - you probably won't be able to send us any file through gmail that's over 10MB, so you'll need to upload it to a free cloud service (like Dropbox, Google Drive, GitHub, OneDrive, etc) and email us a link to it.
     
    Last edited: Dec 9, 2018
  39. Razeoryuno

    Razeoryuno

    Joined:
    Feb 28, 2018
    Posts:
    5
    @zangad,

    Yes, It got rejected because of size. i will resend it soon. Sorry for the ruckus.
     
  40. hacaro76

    hacaro76

    Joined:
    Oct 14, 2015
    Posts:
    25
    Hi Zangad,

    i've a problem with Dynamic popup. It happens only when I change scene and the return back.

    I explain better :

    I' have 3 Scene :
    Main Scene
    Gallery Scene
    And World Scene

    In the World Scene, I use the Tooltips Dynamically like your example.

    Code (CSharp):
    1. GameObject destinationSprite = (GameObject)Instantiate(myPrefab);
    2. TooltipTrigger tooltipTrigger = destinationSprite.gameObject.AddComponent<TooltipTrigger>();
    3.              
    4.                 TooltipStyle tooltipStyle = Resources.Load<TooltipStyle>("MetroSimple");
    5.                 tooltipTrigger.tooltipStyle = tooltipStyle;
    6.                 // Set the tooltip text.
    7.                 tooltipTrigger.SetText("BodyText", String.Format("<b>" + d.name + "</b>" + "This object was created at <b><color=#F3B200>runtime</color></b> from a prefab that <b><color=#F3B200>did not</color></b> already have a tooltip on it. The tooltip was added programmatically and the message and other parameters modified through code. This \"metro\" tooltip style was also added dynamically to the scene.\n\nObject created and tooltip text assigned at {0}.", DateTime.Now));          
    8.  
    9.                 tooltipTrigger.maxTextWidth = 250;
    10.                 tooltipTrigger.backgroundTint = Color.white;
    11.                 tooltipTrigger.tipPosition = TipPosition.MouseTopMiddle;

    When i start directly the "World" scene, all works fine, and the Tooltips works. But, when I load the main scene and then go into the "World" scene i receive theese errors.

    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    ModelShark.Tooltip.WarmUp () (at Assets/ProTips/Scripts/ObjectModels/Tooltip.cs:90)
    ModelShark.TooltipTrigger.StartHover () (at Assets/ProTips/Scripts/Behaviors/TooltipTrigger.cs:217)
    ModelShark.TooltipTrigger.Update () (at Assets/ProTips/Scripts/Behaviors/TooltipTrigger.cs:89)


    It's is strange, because all gameobjects are created at runtime at the scene start, and are present in the hierarchy with the TooltipTrigger component attached.

    Can you help me to solve this ?

    Thanks in advance and Best Regards
     
  41. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    @hacaro76 Hi there, I responded to your email to our gmail support with troubleshooting details and a couple questions. Please take a look, and let me know if you don't see the email. Thanks!
     
  42. JeBuSBrian

    JeBuSBrian

    Joined:
    Mar 3, 2013
    Posts:
    15
    So I'm trying to integrate ProTips into my current project and I'm at a point where I'm stumped. I've got some 3D objects setup with a Tooltip Trigger. They work great for the hover functionality. But I'm trying to get a different behavior.

    I want the tooltip to display when the user selects the 3D object. So I've got an event that fires when the 3D object is selected. I've hooked to the event so that it does ttTrigger.Popup() when the event fires. That works fine too. Until I add another triggerable 3D object to the scene. With more than one object, only the last one properly opens the tooltip. All of the 3D objects use the same tooltip prefab.

    The Popup() method is called, and I can trace all through the TooltipTrigger and TooltipManager classes. It seems like the code is doing its thing. But if I'm looking at the scene hierarchy, I can see that under the root canvas, the tooltip inside Tooltip Container is disabled. Its text doesn't get updated.

    Any idea what's happening here, @zangad ?


    I would like to be able to control when the tooltip disappears. (Like if I want to hide it before its timer runs out). What is the methodology I should use to control when a tooltip should popup and disappear?
     
  43. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi JeBuSBrian,

    I tried to recreate the scenario you described, but I wasn't able to reproduce the issue. There are a lot of variables to consider (the type of canvas space you're using, multiple canvases or not, the type of tooltips you're using and various settings, etc). If you can send me a link to your project I can take a look at it to see if I can fix it. Otherwise, I'm posting the code I used to try to recreate the scenario, and you can see if there is some difference between my code and yours, or maybe a difference in the results you're trying to achieve and my understanding of it.

    Video of the results:


    Code: (I just copied the cube in the 3D demo scene, deleted the TooltipTrigger on it, and added this PopupTooltipOnObjectClick script)
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using Random = UnityEngine.Random;
    4.  
    5. namespace ModelShark
    6. {
    7.     public class PopupTooltipOnObjectClick : MonoBehaviour
    8.     {
    9.         public void OnMouseDown()
    10.         {
    11.             PopupTooltip(gameObject, "This is some tooltip text.\nRandom integer: " + Random.Range(1000,9999), "Continue");
    12.         }
    13.  
    14.         /// <summary>Triggers a tooltip immediately on the game object specified.</summary>
    15.         /// <param name="onObject">The game object to pop a tooltip over.</param>
    16.         public void PopupTooltip(GameObject onObject, string bodyText, string buttonText)
    17.         {
    18.             // Add the TooltipTrigger component to the object we want to pop a tooltip up for.
    19.             TooltipTrigger tooltipTrigger = onObject.GetComponent<TooltipTrigger>();
    20.  
    21.             if (tooltipTrigger == null)
    22.                 tooltipTrigger = onObject.AddComponent<TooltipTrigger>();
    23.  
    24.             TooltipStyle tooltipStyle = Resources.Load<TooltipStyle>("CleanSimpleCloseButton");
    25.             tooltipTrigger.tooltipStyle = tooltipStyle;
    26.  
    27.             // Set the tooltip text and properties.
    28.             tooltipTrigger.SetText("BodyText", bodyText);
    29.             tooltipTrigger.SetText("ButtonText", String.IsNullOrEmpty(buttonText) ? "Continue" : buttonText);
    30.             tooltipTrigger.tipPosition = TipPosition.TopRightCorner;
    31.             tooltipTrigger.maxTextWidth = 300;
    32.             tooltipTrigger.staysOpen = true; // make this a tooltip that stays open...
    33.             tooltipTrigger.isBlocking = true; // ...and is blocking (no other tooltips allowed while this one is active).
    34.             tooltipTrigger.isRemotelyActivated = true;
    35.  
    36.             // Popup the tooltip and give it the object that triggered it (the Canvas in this case).
    37.             tooltipTrigger.Popup(8f, gameObject);
    38.         }
    39.     }
    40. }
    As far as how to control the tooltip disappearing, I would use TooltipManager.Instance.HideAll(). That's what the buttons that close the tooltips use. If you need to close a specific tooltip but leave others open (only works if they use different ToolTip prefabs), then you can call ForceHideTooltip() on each tooltip trigger who's tooltip you want to hide. This is essentially what HideAll() is doing, just for all tooltips that are active. Hope that helps!
     
  44. JeBuSBrian

    JeBuSBrian

    Joined:
    Mar 3, 2013
    Posts:
    15
    Thanks for the tip on the TooltipManager.Instance.HideAll(). Somehow, I missed that. It does seem to work fine when I use that method. What do you think the best way would be to close a specific tooltip, if it uses the same prefab as others? Let's say I have 3 item description tooltips open at once. How can I close item 1, while leaving 2 and 3 open?
     
  45. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    I don't think you would be able to have multiple tooltips of the same prefab open at the same time without modifying the code. ProTips was designed to only use one tooltip instance per prefab, for performance. However, the code could be modified so it creates a tooltip instance parented to the Tooltip Container for each tooltip trigger. There would probably be a small performance hit, and the draw calls would likely increase because of the use of fade-in/fade-out alpha transparency on multiple layered canvas renderers, but it might be worth it to get the effect you're looking for.

    A quick hack way to do this would be to create multiple prefabs of the same tooltip template so ProTips thinks each one is different, and would therefore allow the multiple tooltips (that all look the same) to be open at the same time.

    So anyway, to answer your question about how to close a specific tooltip when multiple ones are open: I would get a reference to the tooltip trigger you want to close, and then call ForceHideTooltip() on it. This will close only that specific tooltip.

    Example:
    Code (CSharp):
    1. // Get a reference to the tooltip trigger we want to close...
    2. TooltipTrigger tooltipTrigger = gameObject.GetComponent<TooltipTrigger>();
    3. // ...and close it.
    4. tooltipTrigger.ForceHideTooltip();
     
    Duffer123 likes this.
  46. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
  47. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Duffer123,

    No, there is still no support at this time for scrollable areas for tooltips. I had some limited success using this video to create a tooltip that has scrollable text in it, but ProTips expects a layout element which defines the dynamic text preferred size so it can resize the tooltip appropriately based on the actual text size. But for a scrollable tooltip, you would not want to resize the tooltip based on the size of the text, otherwise it would defeat the purpose of the scroll area. You would probably want a statically-sized tooltip with a defined scrollable area, and the text container would be the rect transform that would get resized.

    At this point, I haven't been able to determine how to retrofit ProTips code to handle this feature in addition to the regular tooltip resizing and repositioning (ie canvas overflow protection) features.
     
    Duffer123 likes this.
  48. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    Oh well, still hoping for it in future release...
     
  49. almaris

    almaris

    Joined:
    Jan 15, 2016
    Posts:
    4
    @zangad I have recently purchased your asset, and find that all styling is lost for the edges/corner when a TooltipTrigger is inside of a nested prefab, do you have a fix for this?

    For the record, this is Unity 2018.3.3f1.

    Thank you!
     
    Last edited: Mar 27, 2019
  50. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @almaris, thanks for reaching out to us and providing details on the issue you're experiencing.

    I tried to reproduce the issue by setting my Unity version to 2018.3.3f1 and nesting a prefab containing a tooltip trigger inside another prefab, but I was unable to reproduce it. I made a video of the processed I used to nest the prefabs. I'm creating them by simply dragging the game objects from the Hierarchy window to the Project window.



    The Unity 2018.3 release had some major changes for prefabs, so I wouldn't be surprised if there was an issue there somewhere. I'm just not able to reproduce the scenario that causes the issue you're seeing. If you can take a look at the video and see any differences in how I'm creating my nested prefabs and what you're doing, that would help narrow it down. Or if you can send us a link to your project so we can take a look at it, that would also help. Thanks!
     
    Duffer123 likes this.