Greetings.
I have to check if the given point is within any of the 2d box colliders attached to objects contained in an array.

So, in short, I do:

public GameObject[] turretAllowedZones;
public Vector2 targetPoint; //some Vector2 here, not important

    void Start () {
    		turretAllowedZones = GameObject.FindGameObjectsWithTag ("turretAllowedZone");
    	}

So now basically I have an array that consists of all the empty objects that have “turretAllowedZone” tag. Those empties, shattered in many places on the map, have 2D Box Colliders attached.

I’ve been thinking about using “foreach” and the Bounds.Contains() function… So every objects gets checked one by one.

Any solutions please?
Thank you in advance.

Okay I’ve solved it myself…

using UnityEngine;
using System.Collections;

public class turretBuilder : MonoBehaviour {

	public GameObject testturret;
	public GameObject[] turretAllowedZones;

	void Start () {
		turretAllowedZones = GameObject.FindGameObjectsWithTag ("turretAllowedZone");
	}

	void FixedUpdate () {
	if (Input.GetKeyDown ("space")) {
						// basic turret construction func | enter building mode
						Vector3 cmouse = Camera.main.ScreenToWorldPoint (Input.mousePosition);
						cmouse.x = Mathf.Round (cmouse.x);
						cmouse.y = Mathf.Round (cmouse.y);
						cmouse.z = 0.0F;
						//print (cmouse);
						foreach (GameObject turretAllowedZone in turretAllowedZones)
						{
								if (turretAllowedZone.collider2D.bounds.Contains (cmouse) == true) {
										Instantiate (testturret, cmouse, Quaternion.identity);
								}
						}
				}
}