Here’s the syntax error I get:
Assets/ScriptsNEW/PlayerController.cs(41,42):
error CS1061: Type
UnityEngine.MonoBehaviour' does not contain a definition for
deActivate’
and no extension methoddeActivate' of type
UnityEngine.MonoBehaviour’
could be found (are you missing a
using directive or an assembly
reference?)
Here’s some of the code:
`
private MonoBehaviour[] modes = new MonoBehaviour[3];
void Start()
{
modes[0] = (ModeA)this.GetComponent("ModeA");
modes[1] = (ModeB)this.GetComponent("ModeB");
modes[1].enabled = false;
modes[2] = (ModeC)this.GetComponent("ModeC");
modes[2].enabled = false;
}
void setMode(int s)
{
if(currMode==s){return;}
for(int i=0; i<modes.Length; i++)
{
if(modes*.enabled == true)*
-
{*
_ modes*.deActivate();_
_ modes.enabled = false;
}
}
modes~~.enabled = true; currMode = s;
}
`~~
Basically, what I want this to do is when it calls setMode, it deActivates all the other scripts. Because each script is a class all its own, I have to store them in an array of MonoBehaviour. Each script has the deActivate function but it won’t work because its not default to MonoBehaviour. Do I have to make a new class of scripts called like, “Mode”, or something and give them this deActivate function and then inherit from that for all these mode scripts. Is there a better way I’m missing?*_