Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Jordan Miller 2 · May 07, 2010 at 01:31 AM · disableenable

Script Not staying disabled

Has anyone else come across this? A script that I disable with the code below disables for an instant, then doesn't stay disabled any longer (I know this by debugging).

GameObject.Find("Terrain").GetComponent("TerrainScript").enabled=false;

I don't have it being enabled anywhere in my code and I can't figure out why it becomes enabled again. TerrainScript does have a Update function but I can't imagine that making a difference.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Cyclops · May 21, 2010 at 02:38 PM

For debugging purposes, one thing I like to do is break down any multiple-step statements, and check that every step worked. For instance, you could do:

var foo = GameObject.Find("Terrain");
if (foo == null) {
    Debug.Log("wups");
}
// then get Component next, etc...

It's possible that something is breaking somewhere (maybe mispelling/typo), and it's not obvious.

Also - what do you mean by not disabled? I can't find the Answer again, but I remember Duck posting somewhere, that disabling a script only disables certain functions, like Update(), etc. Some things - specifically OnMouseUp(), for instance, stay enabled, and so the script will respond to mouse clicks.

Is that what's happening?

Comment
Add comment · Show 2 · 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 GODLIKE · May 21, 2010 at 03:32 PM 0
Share

Uhm, this is interesting... but I can't understand why. If somebody wants to stop a script why it's not possible to do that completely?

avatar image Cyclops · May 21, 2010 at 03:48 PM 0
Share

@GODLI$$anonymous$$E, as @Duck pointed out to me (wish I could find it again), it enables the script to be re-enabled by mouse-click. If the script stopped responding to everything, and you wanted it re-enabled, then some other Object would have to read mouse-clicks, find the script, and enable it. Way too complex.

avatar image
0

Answer by Lucas Meijer 1 · May 07, 2010 at 11:25 AM

The only thing I could think of is that your code somewhere is in fact enabling it again, without you realizing it. Try putting the terrain and this script in a seperate scene, and see if it still happens.

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

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

No one has followed this question yet.

Related Questions

Disable SCRIPT HELP!!!! 1 Answer

How do I disable a wind zone through script? 2 Answers

Turn Off/on culling mask by script? 2 Answers

disable/enable mouselook not working? 1 Answer

Enable/Disable GameObject Button script 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