void OnDrawGizmos() { if (ShowGizmoOutline) { if (PlatformPrefab != null) { var rectangleMeshBuildScript = PlatformPrefab.GetComponent <RectangleMeshBuildScript>(); if (rectangleMeshBuildScript != null) { switch (rectangleMeshBuildScript.Anchor) { case TextAnchor.MiddleCenter: _gizmoCenter = Vector3.zero; _gizmoExtents = new Vector3(rectangleMeshBuildScript.Width / 2, rectangleMeshBuildScript.Height / 2); break; case TextAnchor.LowerLeft: _gizmoCenter = new Vector3(rectangleMeshBuildScript.Width / 2, rectangleMeshBuildScript.Height / 2); _gizmoExtents = new Vector3(rectangleMeshBuildScript.Width / 2, rectangleMeshBuildScript.Height / 2); break; default: throw new ArgumentException("rectangleMeshBuildScript anchor " + rectangleMeshBuildScript.Anchor + " not supported."); } } else { var boxCollider = PlatformPrefab.GetComponent <BoxCollider2D>(); if (boxCollider != null) { _gizmoCenter = boxCollider.offset; _gizmoExtents = boxCollider.bounds.extents; } } } for (var i = 0; i < PlatformPositions.Count; i++) { GizmoUtility.DrawBoundingBox( transform.TransformPoint(PlatformPositions[i] + _gizmoCenter), _gizmoExtents, OutlineGizmoColor); } } }
public override async Task Execute() { var physics = Entity.Get <RigidbodyComponent>(); while (Game.IsRunning) { await physics.CollisionEnded(); var entity = PlatformPrefab.Instantiate()[0]; RandomPlatform(out var length, out var position); entity.Transform.Position = new Vector3(0, -PlatformDistance, position); entity.Transform.Scale.Z = length; Entity.Scene.Entities.Add(entity); } }
void OnDrawGizmos() { if (ShowGizmoOutline) { if (PlatformPrefab != null) { var boxCollider = PlatformPrefab.GetComponent <BoxCollider2D>(); if (boxCollider != null) { _gizmoCenter = boxCollider.offset; _gizmoExtents = boxCollider.size / 2; } } GizmoUtility.DrawBoundingBox(transform.TransformPoint(_gizmoCenter), _gizmoExtents, OutlineGizmoColor); } }