diff --git a/Assets/FactManager.cs b/Assets/FactManager.cs index 7e388e76513d89504678a3fc0b3d5e6e5278ea2c..ad5ff06c3d9ba47ce2f6503b310e39463fd66037 100644 --- a/Assets/FactManager.cs +++ b/Assets/FactManager.cs @@ -51,6 +51,13 @@ LineFact AddLineFact(int pid1, int pid2, int id) return Facts.Find(x => x.Id == id) as LineFact; } + RayFact AddRayFact(int pid1, int pid2, int id) + { + Facts.Insert(id, new RayFact(id, pid1, pid2)); + + return Facts.Find(x => x.Id == id) as RayFact; + } + AngleFact AddAngleFact(int pid1, int pid2, int pid3, int id) { @@ -292,7 +299,11 @@ public void OnHit(RaycastHit hit) //Create LineFact //Check if exactle the same line/distance already exists if(!factAlreadyExists(new int[] { this.lineModeFirstPointSelected.Id, tempFact.Id })) - CommunicationEvents.AddFactEvent.Invoke(this.AddLineFact(this.lineModeFirstPointSelected.Id, tempFact.Id, this.GetFirstEmptyID())); + if(ActiveToolMode==ToolMode.CreateLineMode) + CommunicationEvents.AddFactEvent.Invoke(this.AddLineFact(this.lineModeFirstPointSelected.Id, tempFact.Id, this.GetFirstEmptyID())); + else + CommunicationEvents.AddFactEvent.Invoke(this.AddRayFact(this.lineModeFirstPointSelected.Id, tempFact.Id, this.GetFirstEmptyID())); + this.lineModeIsFirstPointSelected = false; this.lineModeFirstPointSelected = null; } diff --git a/Assets/InteractionEngine/FactSpawner.cs b/Assets/InteractionEngine/FactSpawner.cs index 9dd2ca5c98e3a89dd050e2846519cbd504db4aa9..5797a46665344c40acf32bdd800c06cb5e8112d9 100644 --- a/Assets/InteractionEngine/FactSpawner.cs +++ b/Assets/InteractionEngine/FactSpawner.cs @@ -124,6 +124,7 @@ public void SpawnRay(RayFact lineFact) //Get the Line-GameObject as the first Child of the Line-Prefab -> That's the Collider var v3T = line.transform.GetChild(0).localScale; v3T.x = (point2 - point1).magnitude; + Debug.Log(v3T.x); //For every Coordinate x,y,z we have to devide it by the LocalScale of the Child, //because actually the Child should be of this length and not the parent, which is only the Collider v3T.x = v3T.x / line.transform.GetChild(0).GetChild(0).localScale.x; @@ -134,10 +135,9 @@ public void SpawnRay(RayFact 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; - 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"; + string letter = ((Char)(64 + lineFact.Id + 1)).ToString(); + line.GetComponentInChildren<TextMeshPro>().text = letter; + 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/InventoryStuff/DisplayFacts.cs b/Assets/InventoryStuff/DisplayFacts.cs index ef5e9c4555e034a59c3343b16183e9be3a3d8b7c..c683ecd8ffb354bbbc8554ec7c94597dedcf7d8e 100644 --- a/Assets/InventoryStuff/DisplayFacts.cs +++ b/Assets/InventoryStuff/DisplayFacts.cs @@ -63,6 +63,14 @@ private GameObject CreateDisplay(Transform transform, Fact fact) obj.GetComponent<FactWrapper>().fact = f; return obj; } + case RayFact f: + { + var obj = Instantiate(prefab_Distance, Vector3.zero, Quaternion.identity, transform); + obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid1].Id); + obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid2].Id); + obj.GetComponent<FactWrapper>().fact = f; + return obj; + } case AngleFact f: { @@ -86,6 +94,7 @@ private GameObject CreateDisplay(Transform transform, Fact fact) var obj = Instantiate(prefab_Default, Vector3.zero, Quaternion.identity, transform); return obj; } + } } diff --git a/Assets/TreeWorld.unity b/Assets/TreeWorld.unity index 3837c442ad76f80044022b4db211a5f137a79f7c..4e29164a5c48dd8e56de1d90699cb746c571aa94 100644 --- a/Assets/TreeWorld.unity +++ b/Assets/TreeWorld.unity @@ -2089,7 +2089,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 606.5377, y: 469.0689} + m_AnchoredPosition: {x: 74, y: 514} m_SizeDelta: {x: 250, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1143784615