Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom post processing effects gets deleted randomly from profile. Null Error in TextureParameter

Discussion in 'Image Effects' started by InkaTorque, Feb 20, 2019.

  1. InkaTorque

    InkaTorque

    Joined:
    Sep 4, 2014
    Posts:
    22
    Hey guys !!!

    I´ve been writting some custo post processing effects lately and I have just hit a big roadblock : The ones that use an extra texture dissapear from their profiles randomly , making my tuning progress dissapear and its really frustrating .

    Every time I add the custom effect , an "Argument Cannot be Null" error shows up and points to what I think is my Texture , so maybe I´m declaring it wrong? Here is my code.

    Code (CSharp):
    1. public sealed class PostProcessingEffect_TextureOverlay : PostProcessEffectSettings
    2. {
    3.     [Tooltip("Texture To Apply")]
    4.     public TextureParameter overlayTexture = new TextureParameter();
    5.     [Range(0f, 1f), Tooltip("Effect Opacity")]
    6.     public FloatParameter opacity = new FloatParameter { value = 0.5f };
    7.     [Range(0f, 1f), Tooltip("Original Pixel Blending")]
    8.     public FloatParameter blending = new FloatParameter { value = 0.0f };
    9.     [Tooltip("Texture Rows ")]
    10.     public IntParameter rows = new IntParameter { value = 1 };
    11.     [Tooltip("Texture Colums ")]
    12.     public IntParameter colums = new IntParameter { value = 1 };
    13.     [Range(0.0f,60.0f), Tooltip("Animation Speed ")]
    14.     public FloatParameter AnimationSpeed = new FloatParameter { value = 1.0f };
    15.     [ Tooltip("Uses Negate Effect Texture ")]
    16.     public BoolParameter usesNegateTexture = new BoolParameter { value = false };
    17.     [Tooltip("Negate Effect Texture")]
    18.     public TextureParameter negateEffectTexture = new TextureParameter();
    19.     [Range(0f, 1f), Tooltip("Negate Texture Alpha Cutout")]
    20.     public FloatParameter alphaCutout = new FloatParameter { value = 0.0f };
    21.     [Range(0f, 1f), Tooltip("Negate Texture Blend")]
    22.     public FloatParameter negateBlend = new FloatParameter { value = 0.0f };
    23.  
    24.     public override bool IsEnabledAndSupported(PostProcessRenderContext context)
    25.     {
    26.         return enabled.value && (overlayTexture != null) && (opacity>0);
    27.     }
    28. }
    29.  
    Looking forward to your help.
     
  2. InkaTorque

    InkaTorque

    Joined:
    Sep 4, 2014
    Posts:
    22
    I just updated the IsEnabledAndSupported function to be a bit more precise but it keeps giving me errors , please help !!!
    Code (CSharp):
    1.  
    2.     public override bool IsEnabledAndSupported(PostProcessRenderContext context)
    3.     {
    4.         return enabled.value && (overlayTexture != null) && (opacity > 0) &&
    5.             (
    6.             (usesNegateTexture == true && negateEffectTexture != null)
    7.             ||
    8.             (usesNegateTexture==false && negateEffectTexture==null)
    9.             );
    10.     }