Advertisement
caLLowCreation

Show Tooltip on Start

Jul 31st, 2015
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. #region Author
  2. /*
  3.      Mobile Tooltip Systems is required for this component, it can be found
  4.      on Unity's Asset Store at https://www.assetstore.unity3d.com/en/#!/content/36304
  5.  
  6.      Jones St. Lewis Cropper (caLLow)
  7.      
  8.      Another caLLowCreation
  9.      
  10.      Visit us on Google+ and other social media outlets @caLLowCreation
  11.      
  12.      Thanks for using our product.
  13.      
  14.      Send questions/comments/concerns/requests to
  15.       e-mail: caLLowCreation@gmail.com
  16.       subject: Mobile Tooltip Systems    
  17.      
  18. */
  19. #endregion
  20.  
  21. using TooltipSystems.Scripts;
  22. using UnityEngine;
  23. using UnityEngine.EventSystems;
  24.  
  25. namespace TooltipSystems
  26. {
  27.     /// <summary>
  28.     /// Requires a class derived from TooltipCoreUI
  29.     /// <para>TooltipCoreUI is where TooltipCoreCanvas will look up text for the tooltip.</para>
  30.     /// </summary>
  31.     [AddComponentMenu("TooltipSystems/AddOns/ShowTooltipOnStart", 1)]
  32.     [RequireComponent(typeof(TooltipBaseUI))]
  33.     public class ShowTooltipOnStart : MonoBehaviour
  34.     {
  35.         [SerializeField]
  36.         [Tooltip("Position pivot 0,0 is bottom left.")]
  37.         Vector2 m_ShowPosition = new Vector2(10, 10);
  38.  
  39.         TooltipBaseUI m_Tooltip;
  40.  
  41.         //Awake is called when the script instance is being loaded.
  42.         void Awake()
  43.         {
  44.             //Get the attached tooltip UI component
  45.             m_Tooltip = GetComponent<TooltipBaseUI>();
  46.         }
  47.  
  48.         //Start is called on the frame when a script is enabled just before any
  49.         //of the Update methods is called the first time.
  50.         void Start()
  51.         {
  52.             //Create a new pointer current event systen
  53.             var pointerData = new PointerEventData(EventSystem.current);
  54.             //Set the poistion for the tooltip
  55.             //NOTE: Position pivot 0,0 is bottom left
  56.             pointerData.position = m_ShowPosition;
  57.             //Create a new tooltip event from Unity's pointer event
  58.             var eventData = TooltipUIEventData.NotSet(pointerData);
  59.             //Show the tooltipUI reference
  60.             TooltipBaseCanvas.ShowTooltip(m_Tooltip, eventData);
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement