Triggers causes scene to lag

Hi, My name is Dave. I have been working on a Unity based Horror for quite sometime now and all is well so far i have received good feedback however recently decided that some room doors would be shut and you would walk into them (they have trigger colliders) and my script that’s attached to each door would play the audio (door opening sound), fade out the current scene and load the Scene declared in the scripts variable. And then ultimately fade in the next scene and so on you get the idea. Many doors have these triggers placed closely on front of them. but since i have put them there my scene lags alot. Even with occlusion culling throughout it. and static batching. I have tested this theory by simply disabling all triggers and then playing. The triggers go, the lag goes… simple…

here’s a copy of my script:

public var fadeOutTexture : Texture2D;
public var fadeSpeed = 2.0;
var drawDepth = -1000;
var alphaWait : boolean = true;

public var levelName ="SceneName";
var delayTime : float = 1.5;
private var alpha = 1.0;
private var fadeDir = -1;

function OnTriggerEnter(other : Collider)

	function OnGUI(){
   if(alphaWait == false) {
    alpha += fadeDir * fadeSpeed * Time.deltaTime;
    alpha = Mathf.Clamp01(alpha);    
    GUI.color.a = alpha;  
    GUI.depth = drawDepth;  
    GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
function fadeIn(){
    yield WaitForSeconds(2);
    alphaWait = false;
    fadeDir = -1;  
function fadeOut(){
    fadeDir = 1;  
function Start(){      

Not sure, but it might be that OnGUI causes the lagging since OnGUI causes performance costs at my knowledge. How about making the screen fade effect by using UI canvas and coroutines?

Yeah duh. They’re really lag. Try finding ways to not use them. For example, if your making like a stealth-game use a navmesh agent. Or Invoke the trigger;