예제 #1
0
    public void CloseView(Action <GameObject, Vector2> buttonsMoveAnimationFunc)
    {
        ChildButtons.ForEach(b => buttonsMoveAnimationFunc(b, Vector2.zero));
        RootButton.SetActive(false);
        ParentButton.SetActive(false);
        NodeToButton.Clear();

        GameObject rootObj = CreateRootButton(Tree.Root);

        rootObj.GetComponent <Button>().onClick.AddListener(OpenView);
        CurrentMiddleNode = Tree.Root;
    }
예제 #2
0
    private GameObject CreateNewButton(TreeNode <E> node)
    {
        GameObject button = GetChildButtonFromPool();

        NodeToButton.Add(node, button);

        RectTransform childRectTransf = button.GetOrAddComponent <RectTransform>();

        childRectTransf.anchoredPosition = Vector2.zero;
        Button centerButton = button.GetComponent <Button>();

        centerButton.GetComponentInChildren <Text>().text = GetDisplayName(node);
        centerButton.onClick.RemoveAllListeners();

        return(button);
    }
예제 #3
0
    public void ShowRoot(Action <GameObject, Vector2> buttonsMoveAnimationFunc)
    {
        ChildButtons.ForEach(b => b.SetActive(false));
        RootButton.SetActive(false);
        ParentButton.SetActive(false);
        NodeToButton.Clear();
        if (useSpringJoints)
        {
            ChildButtons.ForEach(b => b.GetComponent <TargetJoint2D>().enabled = false);
        }

        ArrangeNodes(Tree.Root.Children, radius, 0, 330, buttonsMoveAnimationFunc);

        GameObject centerNodeGO = CreateRootButton(Tree.Root);

        centerNodeGO.GetComponent <Button>().onClick.AddListener(() => OnRootNodeClick(Tree.Root));
        CurrentMiddleNode = Tree.Root;
    }
예제 #4
0
    private GameObject CreateRootButton(TreeNode <E> node)
    {
        GameObject button = GetRootButton();

        NodeToButton.Add(node, button);

        RectTransform rootRectTransf = button.GetOrAddComponent <RectTransform>();

        rootRectTransf.anchoredPosition = Vector2.zero;

        rootRectTransf.localScale = Vector3.one;

        Button rootButton = button.GetComponent <Button>();

        rootButton.GetComponentInChildren <Text>().text = GetDisplayName(node);
        rootButton.onClick.RemoveAllListeners();

        return(button);
    }
예제 #5
0
    private GameObject CreateParentButton(TreeNode <E> node)
    {
        GameObject button = GetParentButton();

        NodeToButton.Add(node, button);

        RectTransform rootRectTransf = button.GetOrAddComponent <RectTransform>();

        rootRectTransf.anchoredPosition = Vector2.zero;

        //Rescaling Parent Button to size of Child Button
        float   scaleFactor = ChildButtons[0].GetComponent <RectTransform>().sizeDelta.x / rootRectTransf.sizeDelta.x;
        Vector3 newScale    = ChildButtons[0].transform.localScale * scaleFactor;

        ParentButton.transform.localScale = newScale;

        Button rootButton = button.GetComponent <Button>();

        rootButton.GetComponentInChildren <Text>().text = GetDisplayName(node);
        rootButton.onClick.RemoveAllListeners();

        return(button);
    }
예제 #6
0
    public void ShowNode(TreeNode <E> centralNode, Action <GameObject, Vector2> buttonsMoveAnimationFunc)
    {
        ChildButtons.ForEach(b => b.SetActive(false));
        RootButton.SetActive(false);
        ParentButton.SetActive(false);
        NodeToButton.Clear();
        if (useSpringJoints)
        {
            ChildButtons.ForEach(b => b.GetComponent <TargetJoint2D>().enabled = false);
        }

        ArrangeNodes(centralNode.Children, radius, 0, 270);

        GameObject centerNodeGO = CreateRootButton(centralNode);

        centerNodeGO.GetComponent <Button>().onClick.AddListener(() => OnCenterNodeClick(centralNode));

        GameObject    parentNodeGO     = CreateParentButton(centralNode.Parent);
        RectTransform parentRectTransf = parentNodeGO.GetComponent <RectTransform>();

        parentRectTransf.anchoredPosition = ComputeAnchoredPosition(315, radius + parentRectTransf.sizeDelta.x / 2);
        parentNodeGO.GetComponent <Button>().onClick.AddListener(() => OnParentNodeClick(centralNode.Parent));
        CurrentMiddleNode = centralNode;
    }