Draw 4 points around object

Hi all,

I want to draw 4 points around my object. I use these point as destination of my nav mesh agent.

I use this script to draw them (with Gizmos):

    private void InitWaypionts()
    {
        Vector3 size = this.gameObject.GetComponent<Renderer>().bounds.size;
        Vector3 position = this.transform.position;

        actionPoints = new Vector3[4];

        actionPoints[0] = new Vector3(position.x - (size.x / 2) - 0.2f, position.y, position.z);
        actionPoints[1] = new Vector3(position.x + (size.x / 2) + 0.2f, position.y, position.z);
        actionPoints[2] = new Vector3(position.x, position.y, position.z - (size.z / 2) - 0.2f);
        actionPoints[3] = new Vector3(position.x, position.y, position.z + (size.z / 2) + 0.2f);
    }

    void OnDrawGizmos()
    {
        if (actionPoints != null && actionPoints.Length > 1)
        {
            Gizmos.color = Color.yellow;
            Gizmos.DrawSphere(actionPoints[0], 0.1f);
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(actionPoints[1], 0.1f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(actionPoints[2], 0.1f);
            Gizmos.color = Color.green;
            Gizmos.DrawSphere(actionPoints[3], 0.1f);
        }
    }

The result is:
151458-screenshot-2020-01-17-at-235948.png

I have a problem if the object has a rotation, in this case the points are drawn in wrong position:
151459-screenshot-2020-01-18-at-000535.png

How I can apply the rotation of these points, to draw them correctly?

Use your transform’s direction vectors → transform.forward and transform.right
**
Also be careful using renderer.bounds. The size will vary as you rotate your object. You probably want to use mesh bounds instead.

 private void InitWaypionts()
     {
         Vector3 size = this.gameObject.GetComponent<MeshFilter>().sharedMesh.bounds.size;
         Vector3 position = this.transform.position;
 
         actionPoints = new Vector3[4];
 
         actionPoints[0] = position + transform.right * ((size.x/2) + 0.2f);
         actionPoints[1] = position + -1*transform.right * ((size.x/2) + 0.2f);
         actionPoints[2] = position + transform.forward * ((size.x/2) + 0.2f);
         actionPoints[3] = position + -1*transform.forward * ((size.x/2) + 0.2f);
     }

Edited to change mesh to sharedMesh