- Home /
Disable js from c# unity
I have been looking for a way to disable a js script from c# scripts. The code I am using:
GetComponent<Touch>().enable = false;
But this only works if the "Touch" script is c#. Is there any solution?
Answer by ArkaneX · Oct 28, 2013 at 01:18 PM
You can put Touch script into Assets\\Plugins folder. This way it will be visible to C# script. For more details please read this help page.
Answer by Recluse · Mar 21, 2014 at 12:04 PM
You can do this
private GameObject someObject;
public MonoBehaviour someJS;
void Awake () {
someObject = GameObject.Find ("Name of object with JS script you want to enable / disable");
someJS=someObject.GetComponent("Name of script you want to disable / enable") as MonoBehaviour;
}
void Start () {
someJS.enabled = true;
}
$$anonymous$$arvelous! Everybody is like "you cannot normally mix js and c#" and you prove them wrong, showing simple and elegant solution.
To be fair, this isn't mixing JS and C#. At this point it's just finding a component and accessing a property on the component, all in C#.
Answer by JamieSinn · Oct 28, 2013 at 01:09 PM
I personally dont use JS much, but this is likely the way I would do it:
WhateverScript.enabled = false;
Your answer
![](https://koobas.hobune.stream/wayback/20220613120806im_/https://answers.unity.com/themes/thub/images/avi.jpg)