From a87a13b64e4f9a1b5b846c0774fc8deb85728bdf Mon Sep 17 00:00:00 2001 From: unknown <john.schihada@hotmail.com> Date: Mon, 3 Feb 2020 21:10:13 +0100 Subject: [PATCH] Adjusted Text on Distance-Fact --- Assets/InteractionEngine/FactSpawner.cs | 13 ++++++++----- Assets/Resources/Prefabs/Line.prefab | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Assets/InteractionEngine/FactSpawner.cs b/Assets/InteractionEngine/FactSpawner.cs index 58b91125..dc1c0425 100644 --- a/Assets/InteractionEngine/FactSpawner.cs +++ b/Assets/InteractionEngine/FactSpawner.cs @@ -63,9 +63,10 @@ public void SpawnPoint(PointFact fact) public void SpawnLine(LineFact lineFact) { - - Vector3 point1 = (Facts[lineFact.Pid1] as PointFact).Point; - Vector3 point2 = (Facts[lineFact.Pid2] as PointFact).Point; + PointFact pointFact1 = (Facts[lineFact.Pid1] as PointFact); + PointFact pointFact2 = (Facts[lineFact.Pid2] as PointFact); + Vector3 point1 = pointFact1.Point; + Vector3 point2 = pointFact2.Point; //Change FactRepresentation to Line this.FactRepresentation = (GameObject)Resources.Load("Prefabs/Line", typeof(GameObject)); GameObject line = GameObject.Instantiate(FactRepresentation); @@ -85,8 +86,10 @@ public void SpawnLine(LineFact lineFact) line.transform.GetChild(0).localScale = v3T; line.transform.GetChild(0).rotation = Quaternion.FromToRotation(Vector3.right, point2 - point1); - string letter = ((Char)(64 + lineFact.Id + 1)).ToString(); - line.GetComponentInChildren<TextMeshPro>().text = letter; + //string letter = ((Char)(64 + lineFact.Id + 1)).ToString(); + //line.GetComponentInChildren<TextMeshPro>().text = letter; + line.GetComponentInChildren<TextMeshPro>().text = ((Char)(64 + pointFact1.Id + 1)).ToString() + ((Char)(64 + pointFact2.Id + 1)).ToString(); + line.GetComponentInChildren<TextMeshPro>().text += " = " + Math.Round((point1-point2).magnitude, 2).ToString() + " m"; line.GetComponentInChildren<FactObject>().Id = lineFact.Id; //If a new Line was spawned -> We are in CreateLineMode -> Then we want the collider to be disabled if (CommunicationEvents.ActiveToolMode != ToolMode.ExtraMode) diff --git a/Assets/Resources/Prefabs/Line.prefab b/Assets/Resources/Prefabs/Line.prefab index ac7c2bca..b33f0479 100644 --- a/Assets/Resources/Prefabs/Line.prefab +++ b/Assets/Resources/Prefabs/Line.prefab @@ -70,7 +70,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 0.7} - m_SizeDelta: {x: 2, y: 0.5} + m_SizeDelta: {x: 4, y: 0.5} m_Pivot: {x: 0.5, y: 0.5} --- !u!23 &2096909858734684758 MeshRenderer: -- GitLab