Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by dsgsgsg · Oct 28, 2013 at 01:07 PM ·

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
8

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;
     }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Toby - Zhou · Jul 16, 2014 at 03:30 AM 0
Share

Thank you! It works for me :)

avatar image shotgun_master · Aug 21, 2015 at 02:56 PM 0
Share

you are a god man this is awesome

avatar image K0ndor · Dec 15, 2015 at 04:53 PM 0
Share

$$anonymous$$arvelous! Everybody is like "you cannot normally mix js and c#" and you prove them wrong, showing simple and elegant solution.

avatar image Dave-Carlile K0ndor · Dec 15, 2015 at 05:29 PM 0
Share

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#.

avatar image
0

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;
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dsgsgsg · Oct 28, 2013 at 01:17 PM 0
Share

not working........

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Shutting a function when another function calling. 1 Answer

Colliders with JS only 2 Answers

What means "as Unity.Object" on JS-Unity syntax? 1 Answer

(JS) Best way to make it so that a player can only issue a "move click" once? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges