private static Vector3 CaculatePostionOffset(SceneObjectAnchor anchor, SceneObjectShape shape, Vector3 size) { Vector3 offset = new Vector3(0, 0, 0); switch (anchor) { case SceneObjectAnchor.BOTTOM: switch (shape) { case SceneObjectShape.Box: offset.y = size.y / 2; break; case SceneObjectShape.Capsule: offset.y = size.y / 2; break; case SceneObjectShape.Sphere: offset.y = size.x / 2; break; } break; case SceneObjectAnchor.TOP: switch (shape) { case SceneObjectShape.Box: case SceneObjectShape.Capsule: offset.y = -size.y; break; case SceneObjectShape.Sphere: offset.y = -size.x; break; } break; } return(offset); }
private static Collider CreateCollider(GameObject go, SceneObjectShape shape, Vector3 size) { Collider collider = null; switch (shape) { case SceneObjectShape.Box: var boxCollider = go.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(size.x, size.y, size.z); break; case SceneObjectShape.Sphere: var sphereCollider = go.AddComponent <SphereCollider>(); sphereCollider.radius = size.x / 2; break; case SceneObjectShape.Capsule: var capsuleCollider = go.AddComponent <CapsuleCollider>(); capsuleCollider.radius = size.x / 2; capsuleCollider.height = size.y; break; } return(collider); }