Maintenance - We're currently working on things and you might experience some issues. Should be wrapped up soon!

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Cryptic ArgumentNullException in _unity_self when entering play mode while an SO is being viewed in the inspector
Post Body

This has been bugging me for a long time and I can't figure out what is causing this.

I'm having an error similar to this: Null exception in _unity_self - Unity Forum

When I start Play mode while a ScriptableObject is opened in the inspector, a cryptic Null Pointer Exception is logged on the console. Like this:

ArgumentNullException: Value cannot be null.

Parameter name: \_unity\_self

UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at <4911eca47f294e18a7b3306f02701303>:0)

UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <ddc34215cb194bc6b42a1ae3b66800fe>:0)

UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <ddc34215cb194bc6b42a1ae3b66800fe>:0)

UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <ddc34215cb194bc6b42a1ae3b66800fe>:0)

UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <ddc34215cb194bc6b42a1ae3b66800fe>:0)

UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at <73c3b9fa4da644c9a21a8a16d8e2909f>:0)

UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <73c3b9fa4da644c9a21a8a16d8e2909f>:0)

UnityEngine.UIElements.Panel.UpdateBindings () (at <73c3b9fa4da644c9a21a8a16d8e2909f>:0)

UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <73c3b9fa4da644c9a21a8a16d8e2909f>:0)

UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <73c3b9fa4da644c9a21a8a16d8e2909f>:0)

UnityEditor.RetainedMode.UpdateSchedulers () (at <ddc34215cb194bc6b42a1ae3b66800fe>:0)

It happens every time on specific ScriptableObjects. Here's one simple SO that causes this:

using System;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Architecture/Localized String")]
public class LocalizedString : ScriptableObject
{
    [SerializeField] List<Localization> localizedStrings;

    public string Get(Language language)
    {
        string value = null;

        foreach (Localization loc in localizedStrings)
        {
            if (language == loc.language)
            {
                value = loc.value;
            }
        }

        if (value == null)
        {
            Debug.LogError($"{this.name} has no value for {language}; using name instead");
            return this.name;
        }

        return value;
    }

    [Serializable]
    private class Localization
    {
        public Language language;
        public string value;
    }
}

Language is just a simple enum with only English as its only possible value.

The issue happens all the time in all instances of this SO. This issue also happens to other SOs I implemented but this is the simplest one.

I'm tempted to think that this is an editor-only issue and this will not affect any build, but I just want to be sure. Any ideas about what is causing this?

PS. I'm using Version 2022.3.0f1

Author
Account Strength
100%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
9,815
Link Karma
6,596
Comment Karma
2,264
Profile updated: 2 hours ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
11 months ago