- Home /
how to disable/enable a script in c#?
im trying to do this script: GetComponent("script").enabled = false;
but the problem is its not in c#. Its in js. I do not want to have to convert my script to js. Is this possible?
Answer by DeusIgnis · Jan 15, 2018 at 04:17 AM
Take a look at this unity tutorial. It explains everything you need. https://unity3d.com/learn/tutorials/topics/scripting/enabling-and-disabling-components
Answer by spidermancy612 · Jan 15, 2018 at 04:28 AM
Unity wouldn't let me post the text so here's the picture of it
this is my code:`using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Pause$$anonymous$$enu : $$anonymous$$onoBehaviour {
public static bool GameIsPaused = false;
public GameObject pause$$anonymous$$enuUI;
[SerializeField] Transform target;
// Update is called once per frame
void Update () {
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume ()
{
pause$$anonymous$$enuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
Cursor.visible = false;
}
void Pause ()
{
pause$$anonymous$$enuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
Cursor.visible = true;
GetComponent<$$anonymous$$ouseLook>().enabled false;
}
} and i want the
void Pause () { pause$$anonymous$$enuUI.SetActive(true); Time.timeScale = 0f; GameIsPaused = true; Cursor.visible = true; GetComponent<$$anonymous$$ouseLook>().enabled false; } }` to have it there. But it doesnt work! i have "$$anonymous$$ouse Look" But for some reason it doesnt work please help
I need $$anonymous$$ouse Look to be tured off at GetComponent but it's attach to PLayer
Your answer
![](https://koobas.hobune.stream/wayback/20220612150519im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to access the interface from the last component in the inspector 2 Answers
Problem with getting component, help please? ^^' 2 Answers
Component name for raw image. 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers