Search Unity

Bug PolybrushNullReferenceException

Discussion in 'Editor & General Support' started by SunnyValleyStudio, Apr 30, 2020.

  1. SunnyValleyStudio

    SunnyValleyStudio

    Joined:
    Mar 24, 2017
    Posts:
    67
    Hi I have just imported Polybrush 1.0.1 into my project UPT, Unity 2019.3.10f1 with Cinemachine package installed and I get:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Polybrush.OverlayRenderer.OnRenderObject () (at Library/PackageCache/com.unity.polybrush@1.0.1/Runtime/Scripts/MonoBehaviour/OverlayRenderer.cs:202)
    3. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    Which points to the:
    Code (CSharp):
    1. if((Camera.current.gameObject.hideFlags & SceneCameraHideFlags) != SceneCameraHideFlags || Camera.current.name != "SceneCamera" )
    2.                 return;
    and Camera.current when logged shows every nth time that it is null.

    The only way i have found to prevent it was to delete whole if statement. The tool works but on every click it throws this error. Is this a bug?

    Thanks!
     
  2. lsozke

    lsozke

    Joined:
    Jul 3, 2017
    Posts:
    3
    I got the same exception in 2019.4.0f1 too.
    My workaround is to add a null checking on Camera.current right before the problematic "if" statement.

    if(Camera.current == null)
    return;
    if((Camera.current.gameObject.hideFlags & SceneCameraHideFlags) != SceneCameraHideFlags || Camera.current.name != "SceneCamera" )
    return;
     
  3. wechat_os_Qy0-oYKeV6wZfxG0kKfimUFsg

    wechat_os_Qy0-oYKeV6wZfxG0kKfimUFsg

    Joined:
    Feb 9, 2021
    Posts:
    1
    thanks!I have the same problem but i don't know how to solute...
     
  4. erraineon

    erraineon

    Joined:
    Dec 21, 2018
    Posts:
    1
    for anyone who runs into this: with unity 2020.3.12f1 i noticed that the issue was only happening when i had the game panel undocked from the editor, for example on another monitor

    when i placed the game panel back into the main window, the error stopped happening
     
  5. Anipen

    Anipen

    Joined:
    Oct 15, 2014
    Posts:
    12
    My Solution
    1. Copy PolyBrush Folder in .\Library\PackageCache\YourVersion
    2. Delete PolyBrush in PackageManager
    3. Copy Temp Folder to .\Packages
    4. Fix OverlayRender.cs 202 line

    if (Camera.current != null)
    {
    if ((Camera.current.gameObject.hideFlags & SceneCameraHideFlags) != SceneCameraHideFlags || Camera.current.name != "SceneCamera")
    return;
    }
     
  6. HelloSoup

    HelloSoup

    Joined:
    Dec 11, 2013
    Posts:
    2

    Wow - docking to the main menu actually works, thanks for the tip
     
  7. st10083010

    st10083010

    Joined:
    Jan 16, 2022
    Posts:
    1
    thanks, it's can works
     
  8. ertbaran

    ertbaran

    Joined:
    Feb 22, 2019
    Posts:
    11
    Thanks :)

    This was my fully solution:
    I closed then replaced Game panel behind to Scene panel as a tab. Then i pressed start. Selected Game View and resolved.