public void OpenEdgePanel(PlotEdge edge, Vector3 hitPos) { CloseAllPanels(); //get an unused edge panel, lock it on and play anim GameObject go = Dequeue(edgePanelPool); go.SetActive(true); var lockon = go.GetComponent <SimpleLockOnto>(); lockon.referenceTransform = edge.transform; lockon.localOffset = Quaternion.Inverse(edge.transform.rotation) * (hitPos - edge.transform.position); lockon.Apply(); //necessary for SnapToDesiredRotation to work go.GetComponent <SimpleBillboardDampened>().referenceTransform = cameraAnchor; //set initial pos/rot go.transform.position = edge.transform.position; go.GetComponent <SimpleBillboardDampened>().SnapToDesiredRotation(); go.transform.GetChild(0).GetComponent <Animation>().Play("RelationWorldCanvasOpen"); go.transform.Find("CANVAS/MASK/NAME1").GetComponent <Text>().text = Dataset.GetName(edge.symbol1); go.transform.Find("CANVAS/MASK/NAME2").GetComponent <Text>().text = Dataset.GetName(edge.symbol2); float val = edge.value; go.transform.Find("CANVAS/MASK/TEXTNEG").gameObject.SetActive(val <= 0); go.transform.Find("CANVAS/MASK/TEXTPOS").gameObject.SetActive(val > 0); go.transform.Find("CANVAS/MASK/PERCENTAGE").GetComponent <Text>().text = Mathf.Abs(val * 100).ToString("0.0") + "%"; edgePanelsInUse.Add(edge, go); }
public void CloseEdgePanel(PlotEdge edge) { edgePanelsInUse[edge].transform.GetChild(0).GetComponent <Animation>().Play("RelationWorldCanvasClose"); edgePanelPool.Add(edgePanelsInUse[edge]); edgePanelsInUse.Remove(edge); }