Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Feedback Camera.onPostRender and others have confusing examples

Discussion in 'Documentation' started by joshcamas, Jul 3, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    This is a nitpick, but the examples in Camera.onPostRender and Camera.onPreRender are a bit strange, which can result in confusion:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine;
    4. public class ExampleClass : MonoBehaviour
    5. {
    6.    // callback to be called before any camera starts rendering
    7.    public void MyPreRender(Camera cam)
    8.    {
    9.        Debug.Log("PreRender " + gameObject.name + " from camera " + cam.gameObject.name);
    10.    }
    11.  
    12.     public void OnEnable()
    13.    {
    14.        // register the callback when enabling object
    15.        Camera.onPreRender += MyPreRender;
    16.    }
    17.  
    18.     public void OnDisable()
    19.    {
    20.        // remove the callback when disabling object
    21.        Camera.onPreRender -= MyPreRender;
    22.    }
    23. }
    24.  
    To someone who doesn't know, since the debug log logs the game objects name, it feels as if the docs is pointing to the fact that the event triggers when the gameobject is being pre/post rendered. I feel like changing the log to
    Debug.Log("PreRender from camera " + cam.gameObject.name);
    would be better. Definitely a nitpick, but I think it's still important.
     
    Xarbrough likes this.