Search Unity

[SOLVED] Not sure what instance to set to an object.

Discussion in 'Shaders' started by TheSinglePringle, Apr 13, 2017.

  1. TheSinglePringle

    TheSinglePringle

    Joined:
    Apr 6, 2017
    Posts:
    5
    I know the formating is potato, I couldn't figure out how to get it in here properly, sorry. I attached the script, just in case there was more info needed.

    I'm getting an "NullReferenceException: object reference not set to an instance of an object" error on line 498. I don't have a targetCamera game object or camera, but I have tried the other cameras with no luck. For reference I am trying to implement volumetric clouds by having them on the layer Clouds and having a second camera only see those clouds so they don't appear in front of other objects on screen. everything is working as far as I can see crepuscular rays coming from the sun and moving with the clouds, but the clouds aren't rendering in, just those rays. I am fairly new at c# and Unity so I am probably derping over an easy fix and I probably left out information that you guys might need so let me know. Any ideas? Thanks :D



    495......void CreateFullscreenQuad()
    ................ {
    ...................int Clouds = 8;
    498......................._fullScreenQuad.targetCamera = targetCamera;
    ................_fullScreenQuad.gameObject.layer = Clouds;

    .................if (Application.isPlaying && _fullScreenQuad == null)
    .................{
    ...................... GameObject quadGO = new GameObject("CloudsFullscreenQuad", typeof(FullScreenQuad));
    ....................... quadGO.hideFlags = HideFlags.HideAndDontSave;
    ....................... _fullScreenQuad = quadGO.GetComponent<FullScreenQuad>();
    ....................... _fullScreenQuad.material = _cloudBlenderMaterial;
    ........................ _fullScreenQuad.renderWhenPlaying = true;
    ................. }
    509 .... }
     

    Attached Files: