I can suggest making an event system.
Say, you have 100 triggers (they are from the same prefab, right?) all of which are the same. Trigger prefab has a “MyLittleTrigger” tag so you can easily access it at the beginning of the game. Now, you’ll need a Delegate definition, and an event. You also need to dispatch this event and listen to it somewhere. The point is - you have lots of scripts that dispatch this event, but only one place in code where you process it. You’ll need two scripts: one for a trigger prefab and one for a global event handler (your game controller)
Trigger script will look something like this
using UnityEngine;
using System.Collections;
// Delegate definition, so we can use it as an event
public delegate void TriggerEventDelegate();
public class TriggerEventSystem : MonoBehaviour
{
// Local event
public event TriggerEventDelegate triggerEvent;
void OnTriggerEnter()
{
// Check if someone is listening to our event
if(triggerEvent != null)
{
// If so, trigger the event
triggerEvent();
}
}
}
While controller script will look something like this
using UnityEngine;
using System.Collections;
public class TriggerControllerSystem : MonoBehaviour
{
void Awake()
{
if(triggerEvent != null)
{
// For every trigger object in the scene, subscribe to it's trigger event
foreach (GameObject trigger in GameObject.FindGameObjectsWithTag("MyLittleTrigger"))
{
TriggerEventSystem triggerScript = trigger.GetComponent<TriggerEventSystem>();
// Subscribing
triggerScript += TriggerEventHandler;
}
}
}
// Event handler has to be of the given delegate type (Our delegate is of type TriggerEventDelegate)
void TriggerEventHandler()
{
// Process the triggering here
}
}
So you still have to check for a trigger on all the objects, but you can process this information outside the triggers