I have this hacked together in Unity 4, but I run into a bit of a problem in Unity 5...
I basiclly run through all objects in my scene and disable select components - whatever script I have dragged into my custom inspector. **Now I have this working in Unity 4** because of *deprecated methods/functions* and was wondering how to upgrade this over to Unity 5.
for (int zz = 0; zz < allObjects.Length; zz++)
{
var a = allObjects[zz].GetComponents(typeof(Component));
foreach (Component j in a)
{
if (j.GetType() == script.GetClass())
{
Debug.Log("You have " + j.name + "on component");
j.active = false;
}
}
}
Like I said, I kind of hacked it together. **j.active = false; is no longer is a useable solution.** Any idea's anyone? Oh and the script is typeof(MonoScript)... so I can grab any script... Also as someone mentioned before - *Component class by default does NOT have an enabled variable* so how else can I disable a component? How does Unity do it? Surely there is someway this can be done.
! Edit should be j.active = false;
↧