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; }
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; }
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; }
private void InitializeNodesPool(int desiredPoolSize) { ChildButtons = new List <GameObject>(); for (int i = 0; i < desiredPoolSize; i++) { GameObject newChildObj = Instantiate(childPrefab); RectTransform childRectTransf = newChildObj.GetOrAddComponent <RectTransform>(); childRectTransf.SetParent(this.transform, false); newChildObj.name = "ChildNode_" + (i + 1); ChildButtons.Add(newChildObj); newChildObj.SetActive(false); } RootButton = Instantiate(rootPrefab); RectTransform rootRectTransf = RootButton.GetOrAddComponent <RectTransform>(); rootRectTransf.SetParent(this.transform, false); RootButton.name = "RootNode"; RootButton.SetActive(false); ParentButton = Instantiate(rootPrefab); RectTransform parentRectTransf = ParentButton.GetOrAddComponent <RectTransform>(); parentRectTransf.SetParent(this.transform, false); ParentButton.name = "ParentNode"; float scaleFactor = ChildButtons[0].GetComponent <RectTransform>().sizeDelta.x / rootRectTransf.sizeDelta.x; Vector3 newScale = ChildButtons[0].transform.localScale * scaleFactor; ParentButton.transform.localScale = newScale; ParentButton.SetActive(false); }
public GameObject GetRootButton() { RootButton.GetComponent <Button>().interactable = true; RootButton.SetActive(true); return(RootButton); }