Search Unity

#if SHADERGRAPH_PREVIEW no longer works in 2020.2 custom functions?

Discussion in 'Editor & General Support' started by Saturn1004, Dec 23, 2020.

  1. Saturn1004

    Saturn1004

    Joined:
    Nov 14, 2014
    Posts:
    42
    After upgrading from 2020.1 to 2020.2 all my shader graphs work fine in play mode but now throw tons of errors when viewed in the editor...
    after further inspection it appears that the check "#if SHADERGRAPH_PREVIEW" no longer works in 2020.2 / Shader Graph 10.2.2.
    Is its removal intended? I don't understand why this would be removed...
    If so what's the new method of making custom functions behave differently in preview mode vs play mode?

    #Edit: I found a really buried thing where unity devs said they changed #if to #ifdef for some reason...
    This thread can be deleted I guess. However I don't see the option to delete it.
     
    Last edited: Dec 23, 2020
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The mods on purpose don't let you delete the thread, because someone else will hit the same issue, google it, find your thread, and benefit from your helpful information you've provided to the community on this issue.
     
    SirGhoul and LuGar like this.
  3. sabint

    sabint

    Joined:
    Apr 19, 2014
    Posts:
    26
    @SaturnCO do you have more info on "changing #if to #ifdef"? I think I ran into this same issue and would love to know more.
     
    dev-borisov-alexey likes this.
  4. kaan0550

    kaan0550

    Joined:
    Jun 2, 2019
    Posts:
    10
    RESOLUTION NOTE:

    The definition was changed to use "#ifdef" instead to match other keywords used by each Render Pipeline. This will be noted in the upgrade document when the next version is verified released.
     
    courtneybreid and lucasjohansson like this.
  5. unity_1F95765637BCBE00CD9B

    unity_1F95765637BCBE00CD9B

    Joined:
    Feb 6, 2024
    Posts:
    1
    Is this broken again in 2022.3.21f1?

    This doesn't seem to work...

    Code (CSharp):
    1. #ifdef SHADERGRAPH_PREVIEW
    2. Time = _Time.x * PreviewSpeed;
    3. #else
    4. Time = In;
    5. #endif