Search Unity

Activate/Deactivate Image Effect via KeyPress

Discussion in 'Scripting' started by GLucasDev2, Jan 26, 2014.

  1. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    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"?

    Code (csharp):
    1.     public var myEffect : PP_SobelOutlineV3;
    2.    
    3.     function Start ()
    4.        
    5.         {
    6.        
    7.             myLight = GetComponent(PP_SobelOutlineV3);
    8.        
    9.         }
    10.        
    11.          
    12.        
    13.          
    14.        
    15.         function Update ()
    16.        
    17.         {
    18.        
    19.             if(Input.GetKeyUp(KeyCode.Space))
    20.        
    21.             {
    22.        
    23.                 myLight.enabled = !myLight.enabled;
    24.        
    25.             }
    26.        
    27.         }
    Heres the error code:

    Code (csharp):
    1.     Assets/Deactivate.js(1,23): BCE0018: The name 'PP_SobelOutlineV3' does not denote a valid type ('not found').
     
  2. Deleted User

    Deleted User

    Guest

  3. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
  4. Deleted User

    Deleted User

    Guest

    There is nothing wrong with the script itself.

    your script "PP_SobelOutlineV3" is probably a c# script. It needs to be compiled befor your script! To achieve this, you should put your PP_SobelOutlineV3.cs inside the Standard Assets, Pro Standard Assets or Plugins folder.
     
  5. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    I had a feeling the folder structure was the problem because i saw some people having to put things like "Assets/Folder/Effect" instead of just the effect name.

    Thank you