Skip to content
Snippets Groups Projects
Commit a29d709d authored by Tobias Schöner's avatar Tobias Schöner
Browse files

Torus mesh collider shared mesh now set in TorusGenerator.cs

Moved setting of collider shared mesh from FactSpawner to TorusGenerator
Also adjusted position of Torus Text
parent c05b7de5
No related branches found
No related tags found
1 merge request!1feat: added visualisation for CircleFact; added Torus- and ConeGenerator
......@@ -35,8 +35,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 1}
m_SizeDelta: {x: 4, y: 1}
m_AnchoredPosition: {x: 0, y: 1.5}
m_SizeDelta: {x: 2, y: 0.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &154494299464322201
MeshRenderer:
......
......@@ -227,16 +227,12 @@ public Fact SpawnRing(Fact fact)
string text = $"○{middlePointFact.Label}";
tmpText.text = text;
//move TMP Text so it is on the edge of the circle
tmpText.rectTransform.position = tmpText.rectTransform.position - new Vector3(0, 0, -radius);
////move TMP Text so it is on the edge of the circle
//tmpText.rectTransform.position = tmpText.rectTransform.position - new Vector3(0, 0, -radius);
FactObj.URI = circleFact.Id;
circleFact.Representation = ring;
//update MeshCollider to fit torus
MeshCollider meshCol = ring.GetComponentInChildren<MeshCollider>();
meshCol.sharedMesh = meshCol.gameObject.GetComponent<MeshFilter>().sharedMesh;
return circleFact;
}
......
......@@ -25,6 +25,9 @@ protected override void GenerateShape()
if (torusMesh.sharedMesh != null)
torusMesh.sharedMesh.Clear();
torusMesh.mesh = CreateMesh(CreateTorus(torusRadius, ringRadius, ringSegmentCount, segmentSideCount));
if (torusMesh.transform.TryGetComponent(out MeshCollider meshCol))
meshCol.sharedMesh = torusMesh.sharedMesh;
}
private static (Vector3[] vertices, int[] triangles) CreateTorus(float torusRadius, float ringRadius, int ringSegmentCount, int segmentSideCount)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment