Search Unity

Activate/Deactivate Image Effect

Discussion in 'Scripting' started by GLucasDev2, Jan 25, 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.

    Code (csharp):
    1. public var myEffect : PP_SobelOutlineV3;
    2.  
    3.  
    4. function Start ()
    5. {
    6.     myLight = GetComponent(PP_SobelOutlineV3);
    7. }
    8.  
    9.  
    10. function Update ()
    11. {
    12.     if(Input.GetKeyUp(KeyCode.Space))
    13.     {
    14.         myLight.enabled = !myLight.enabled;
    15.     }
    16. }
     
  2. TheShane

    TheShane

    Joined:
    May 26, 2013
    Posts:
    136
    What's the error? It's probably just a syntax thing but I never use unityscript so I don't see anything obviously wrong.
     
  3. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    This is it

    Code (csharp):
    1. Assets/Deactivate.js(1,23): BCE0018: The name 'PP_SobelOutlineV3' does not denote a valid type ('not found').
    But this is exactly what its called.
     
  4. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Any help is appreciated.
     
  5. Prophet54

    Prophet54

    Joined:
    Apr 18, 2013
    Posts:
    8
    #pragma strict

    //public var myLight : PP_SobelOutlineV3;


    function Start ()
    {
    // myLight = GetComponent
    }


    function Update ()
    {
    if(Input.GetKeyUp(KeyCode.Space))
    {
    GetComponent(PP_SobelOutlineV3).enabled = false;
    }
    }
     
    Last edited: Feb 27, 2014