Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Unity 2018.1.0f2 Null Reference Crash

Discussion in 'Editor & General Support' started by Tryz, May 4, 2018.

  1. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    In a brand new Windows PC project, I add this bad code:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Dummy : MonoBehaviour
    4. {
    5.     public void OnGUI()
    6.     {
    7.         if (GUI.Button(new Rect(10f, 10f, 100f, 20f), "Create Error"))
    8.         {
    9.             GameObject X = null;
    10.             X.transform.position = Vector3.zero;
    11.         }
    12.     }
    13. }
    When the null reference exception occurs, Unity shows the message below and totally crashes.


    It happens with any null reference exception.

    I've turned off the Debug Analytics and other services thinking that might be it, but it didn't help. Anyone have a solution?

    Thanks!
     
  2. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,399
    Unity has confirmed this is a bug:

    "This is indeed a bug! It has been reproduced and sent out to our developers."
     
  3. SniperED007

    SniperED007

    Joined:
    Sep 29, 2013
    Posts:
    341
    Do you have a bug number for this?
    I'm still getting this issue, but only on Mac builds (not in the editor)
     
  4. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    319
    I have the exact same problem ONLY on my Mac Builds. On Editor or on any other platforms it does not happens.

    Is there some way to avoid this?
     
  5. sunwangshu

    sunwangshu

    Joined:
    Mar 2, 2017
    Posts:
    19
    I had similar problem whenever null error occurs it just crashed nowhere.
    Though it was some how solved after toggling off "Error Pause", which is near "Clear on Play" in the Console.