From 55e13abd4b759ff015850d6df49425825d5ee742 Mon Sep 17 00:00:00 2001 From: Paul-Walcher <paulwalcher12@gmail.com> Date: Thu, 4 Jul 2024 16:55:40 +0200 Subject: [PATCH] Added Spawn Method for Cylinder --- .../FactHandling/FactSpawner.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs index 59e469d4..7a254df9 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactSpawner.cs @@ -25,7 +25,8 @@ public GameObject Sphere, ActualSphere, Cuboid, - TriangularPrism + TriangularPrism, + Cylinder ; private void OnEnable() @@ -79,6 +80,8 @@ public void SpawnFactRepresentation(Fact fact) SpawnCuboid(cuboidFact); break; case PrismFact prismFact: SpawnTriangularPrism(prismFact); break; + case CylinderFact cylinderFact: + SpawnCylinderFact(cylinderFact); break; default: break; }; } @@ -95,6 +98,18 @@ public void SpawnCuboid(CuboidFact fact){ cuboid.GetComponentInChildren<TextMeshPro>().text = fact.GetLabel(StageStatic.stage.factState) + " = " + System.Math.Round(fact.Volume, 2) + "m³"; } + + public void SpawnCylinderFact(CylinderFact fact){ + + GameObject cylinder = GameObject.Instantiate(Cylinder); + fact.WorldRepresentation = cylinder.GetComponent<FactObject3D>(); + fact.WorldRepresentation.Fact = fact; + + cylinder.transform.SetPositionAndRotation(fact.Position, fact.Rotation); + cylinder.transform.localScale = Vector3.Scale(cylinder.transform.localScale, fact.LocalScale); + + cylinder.GetComponentInChildren<TextMeshPro>().text = fact.GetLabel(StageStatic.stage.factState) + " = " + System.Math.Round(fact.Volume, 2) + "m³"; + } public void SpawnSphere(SphereFact fact){ GameObject sphere = GameObject.Instantiate(ActualSphere); -- GitLab