Ejemplo n.º 1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        if (!Data.Removable)
        {
            return;
        }

        if (eventData.hovered.Any(x => x.GetComponentInParent <ChatWindow>()))
        {
            ChatWindow window = eventData.hovered.First(x => x.GetComponentInParent <ChatWindow>())
                                .GetComponentInParent <ChatWindow>(); // this line is ugly >:l
            window.AddTab(Data);
            Destroy(gameObject);
        }
        else
        {
            chatWindow.GetChatManager().CreateChatWindow(Data, null, Input.mousePosition);
            Destroy(gameObject);
        }

        Text.raycastTarget  = true;
        image.raycastTarget = true;

        if (originParent.childCount < 1)
        {
            Destroy(chatWindow.gameObject);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Creates a new chat window with the supplied tab data.
    /// Adds a tab to an existing window if an existing window is supplied.
    /// </summary>
    /// <param name="tabData">tab data that decides which channels the chat listens to</param>
    /// <param name="existingWindow">an existing windwo to add a chat tab to rather than create a new window</param>
    /// <param name="position">position for the new window (vector2.zero for default position)</param>
    public void CreateChatWindow(ChatTabData tabData, ChatWindow existingWindow, Vector2 position)
    {
        if (existingWindow)
        {
            existingWindow.AddTab(tabData);
        }
        else
        {
            chatWindow = Instantiate(chatWindowPrefab, transform);
            if (position != Vector2.zero)
            {
                chatWindow.transform.position = position;
            }

            chatWindow.Init(tabData, this, sender.GetComponent <ChatRegister>());
        }
    }