UnassignedReferenceException即使使用空条件运算符 [英] UnassignedReferenceException even though using the null-conditional operator
本文介绍了UnassignedReferenceException即使使用空条件运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
即使我正在使用 我的代码:
// […]
myTarget.Preset?.ApplyTo(myTarget);
我还注意到它提到了_Preset
而不是Preset
(我觉得很奇怪).
I'm also noticing that it mentions _Preset
instead of Preset
(which I find odd).
Foo.cs
中的代码:
Code in Foo.cs
:
[CreateAssetMenu()]
public class Foo : ScriptableObject
{
[SerializeField] private Preset _Preset = null;
public Preset Preset
{
get { return _Preset; }
protected set { _Preset = value; }
}
}
我做错了什么?这不是运营商的目的吗?
What am I doing wrong? Isn't it what the operator is for?
Google搜索无济于事.
Google searches didn't help.
推荐答案
查看全文