OnLevelWasLoad

I try to deactivate object after load a scene. I’m using a script, but no result.
Somebody help?

#pragma strict

var scene : int;
var OBJ : GameObject;
var Active : boolean = true;
var Recursive : boolean = true;

function Start () {
}

function Update () {
}

function OnLevelWasLoaded (level : int) {
    if (level == scene) {
        PlayActive();
    }
}

function PlayActive () {
if (Active){
if (Recursive){
OBJ.SetActiveRecursively(true);
}
else 
OBJ.active = true;
}

if (!Active){
if (Recursive){
OBJ.SetActiveRecursively(false);
}
else 
OBJ.active = false;
}
}

Well before you go on I can see an issue with you “function OnLevelIWasLoaded”
You set the var of scene as a int but never gave it a value then never declared a value of it after wards, by asking it to call it forward its calling it and finding nothing.

Also you set both booleans as true to start then called it as “if both are true”, this will always be the case as you only change the the active to false at the end.