Skip to content
Snippets Groups Projects
Commit fcabc55f authored by Richard Marcus's avatar Richard Marcus
Browse files

fixed ray line prototype

parent 87b9d9ec
No related branches found
No related tags found
No related merge requests found
......@@ -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 }))
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;
}
......
......@@ -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)
......
......@@ -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;
}
}
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment