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
1
Question by GLucasDev2 · Jan 26, 2014 at 01:58 AM · componentimage effectskeypressdeactivate

How To Activate/Deactivate Image Effect On Keypress?

Hello. I currently am trying to implement a simple enable/disable mechanic for my main cameras image effects.

I have this script here but it gives me errors and i cannot test. All i am trying to do is be able to toggle the effect via pressing a key on the keyboard, kind of like in some games you press "N" for nightvision or whatever and can press it again to turn it off.

Any help is appreciated.

Also, this is part of Aubergines Post Process pack so maybe the folder location is causing the problem when i just try to put the name in the script? Do i need to put like "Assets/Aubergines/Effect/"the effect"?

 public var myEffect : PP_SobelOutlineV3;
 
 function Start ()
     
     {
     
         myLight = GetComponent(PP_SobelOutlineV3);
     
     }
     
      
     
      
     
     function Update ()
     
     {
     
         if(Input.GetKeyUp(KeyCode.Space))
     
         {
     
             myLight.enabled = !myLight.enabled;
     
         }
     
     }

Heres the error code:

 Assets/Deactivate.js(1,23): BCE0018: The name 'PP_SobelOutlineV3' does not denote a valid type ('not found').
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
0

Answer by Wach3D · Apr 20, 2016 at 06:56 AM

https://www.youtube.com/watch?v=3W472ZijzM0

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
0

Answer by Johat · Apr 20, 2016 at 07:11 AM

I'm not familiar with the Image Effects pack you're talking about. However, what language is that pack written in?

If it's written in C# and you're trying to access it in JavaScript, you won't be able to see it and will get the error you see.

A handy trick to get around this is to put the Image Effects pack inside the Standard Assets folder (if it doesn't exist, just create one Assets/Standard Assets/THE_PACKAGE).

Scripts in Standard Assets always get compiled first, so when it comes to compiling your regular scripts, they should be able to see them.

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
0

Answer by faizidp · Apr 20, 2016 at 09:07 AM

void Update(){
if(Input.GetKeyDown(KeyCode.A)){
this.GetComponent < ImageEffect >().enabled=false; } }
Attach this script to camera and change "ImageEffect" to the effect name you are using!

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

21 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 avatar image

Related Questions

How to activate/deactivate a component(Animator) when a specific game object was activated 0 Answers

Deactivate an object - and all scripts in that object deactivated? 1 Answer

activate object on key press only, otherwise always deactivated! 2 Answers

2D Animation does not start 1 Answer

Problems deactivating a 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