Hey guys,
I’m more familiar with JS… I can’t get and enable/disable Script component in C#
This works (happy ), and CharacterController is switching On/Off as expected…
public GameObject mouselooking; // attached gameObject > FPSController in Inspector
public bool isShowing;
void Update() {
if (Input.GetKeyDown("escape")) {
isShowing = !isShowing;
menu.SetActive(isShowing);
if(isShowing==true) mouselooking.GetComponent<CharacterController>().enabled = false;
if(isShowing==false) mouselooking.GetComponent<CharacterController>().enabled = true;
}
}
BUT how can I target another Component on the same GameObject, which is script First Person Controller (Script) in Inspector? I’m mad of this… this must be so easy and I can’t manage that O.O Not even with google and my humble logic Thanx guys.
EDIT:
So… I somehow did it! BUT BY RANDOM TRYING WHOLE DAY and it not answered my question whatsoever!
This is solution for FPScontroller > First Person Controller script => Universal MouseLook locking in Unity 5
public Behaviour FPSget; // attached gameObject > FPSController
FPSget.enabled = false; // is switching Mouselook on-off
BUT it did not solve my question:
How can I disable / enable ANY script component under same GameObject in Unity5? For example Crosshair.js? How I call its name and disable it?