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 /
This question was closed Dec 20, 2014 at 05:58 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
5
Question by sfkx · Jul 26, 2012 at 06:29 PM · componentmouselookremovecharactermotor

Remove Component

my script menu.js ; i want user prefabs in mouselook and charactermotor script remove || enabled false;

example code ; GetComponent(MouseLook).active = false; or enabled = false; not working.

how to make this ?

Thank you. Best regards.

Comment
Add comment · Show 2
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 Piflik · Jul 26, 2012 at 06:47 PM 3
Share

What?!

Can you rephrase this? I have a bit of a problem deciphering this...

avatar image MoliCat · Dec 20, 2014 at 05:39 PM 5
Share

its simply worked check unity official
http://docs.unity3d.com/ScriptReference/Object.Destroy.html

1 Reply

  • Sort: 
avatar image
10
Best Answer

Answer by whydoidoit · Jul 26, 2012 at 06:38 PM

To remove a component you destroy it:

      Destroy( GetComponent<MouseLook>() );

But I'm not sure why your enabled = false is not working - it would imply that the script you have posted is not on the same object as the MouseLook. If it is on a parent you could use GetComponentInChildren<MouseLook>()

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 sfkx · Jul 26, 2012 at 07:13 PM 0
Share

Thank you $$anonymous$$r. $$anonymous$$ike. And question how to add last component ? example : $$anonymous$$ouseLook or Character$$anonymous$$otor.

Thank you again :)

avatar image whydoidoit · Jul 26, 2012 at 07:16 PM 0
Share

Oh you can add any component you like this:

    var mouseLook = gameObjectOrComponent.AddComponent($$anonymous$$ouseLook);

or in a mono behaviour and you don't care about accessing it immediately:

   AddComponent($$anonymous$$ouseLook);

Follow this Question

Answers Answers and Comments

8 People are following this question.

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

Related Questions

How to remove a word from string 0 Answers

Character rotation instead of movement when using arrow-keys 0 Answers

How to disable script in other object 1 Answer

Cloud recognition in Vuforia 0 Answers

How can I access values from a component script in another object 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