示例#1
0
        void TooltipTest()
        {
            // Get custom struct from manager
            var data = m_PopUpManager.GetTooltipData();

            // Modify the struct
            // The tooltip has an icon and an arrow that points the coordinate you put in data.worldPosition
            data.text = "This tool helps you";

            bool hasIcon = (Random.value > 0.5f && m_Icons != null && m_Icons.Length > 0);
            var  icon    = hasIcon ? m_Icons[Mathf.FloorToInt(Random.value * 10e3f) % m_Icons.Length] : null;

            data.icon = icon;

            // Sets position to the pointer
            RectTransformUtility.ScreenPointToWorldPointInRectangle(
                m_RectPopUp, Mouse.current.position.ReadValue(), null, out var worldposition);
            data.worldPosition = worldposition;

            // Send back the modified struct
            m_PopUpManager.DisplayTooltip(data);
        }