﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlaneGetSideExample : MonoBehaviour
{
    public Vector3[] positions = new Vector3[0];

    [ContextMenu("Random Points")]
    void RandomPoints()
    {
        positions = new Vector3[20];

        for (int i = 0; i < positions.Length; i++)
            positions[i] = new Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0);
    }

    private void OnDrawGizmos()
    {
        Plane plane = new Plane(transform.up, transform.position);

        foreach (var pos in positions)
        {
            //if the point is above the Up plane defined by transform.up, turn it green.
            if (plane.GetSide(pos))
                Gizmos.color = Color.green;
            else
                Gizmos.color = Color.red;

            //draw the point
            Gizmos.DrawWireSphere(pos, 0.25f);
        }
    }
}
