Assigning plane script to game object plane

if you create a plane using this
planeA.Set3Points(Vector1, Vector2, Vector3);
How can you assign it to a gameobject so you can see it?

If you talk about Unity’s Plane struct you got something completely wrong. It represents an infinite mathematical plane. This has nothing to do with a visual plane or Mesh. The plane can be used to calculate intersections with rays, test if a point is on the front or backside of the plane and to project a point onto the plane.

Since you haven’t said what you actually want to achieve I can’t suggest anything else.

@bunny83
Yes i’m looking for a way to visually see the plane im creating using plane struct

I was looking for a way to visualize a Plane in Unity and came across this question and was disappointed there was no answer. So I had to figure it out myself and here’s what I came up with. This took me awhile cause I have a learning disability when it comes to Quaternions :wink:

// Construct your plane using your values
Vector3 normal, point;
Plane plane = new Plane(normal, point);

GameObject planeGO = GameObject.CreatePrimitive(PrimitiveType.Plane);
planeGO.transform.localScale = new Vector3(1000, 1000, 1000);    // A plane is infinitely large, so use any scaling values here which make sense for you

// For Unity's default plane GameObject the Y axis is the plane's normal.  So we need a perpendicular to the plane's normal.
Vector3 perpendicular;
if (Vector3.Angle(plane.normal, Vector3.up) > 5)
{
    perpendicular = Vector3.Cross(plane.normal, Vector3.up);
}
else
{
    perpendicular = Vector3.Cross(plane.normal, Vector3.right);
}

Quaternion planeRotation = new Quaternion();
planeRotation.SetLookRotation(perpendicular, plane.normal);
planeGO.transform.rotation = planeRotation;

// If you have the point used to construct the Plane, just use that as the GO's position.  If you don't, then any point in the plane will do.
if (haveAccessToPlanePoint)
{
    planeGO.transform.position = point;
}
else
{
    Vector3 planePoint = plane.ClosestPointOnPlane(Vector3.zero);
    planeGO.transform.position = planePoint;
}