首页 > 解决方案 > NullReferenceException:对象引用未设置为 lin 25 的对象 Item..ctor(ItemObject 项)的实例

问题描述

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

public enum ItemType
{
    Stone,
    Default
}
public class ItemObject : ScriptableObject
{
    public int Id;
    public Sprite uiDisplay;
    public ItemType type;
    [TextArea(15,20)]
}
[System.Serializable]
public class Item
{
    public string Name;
    public int Id;
    public Item(ItemObject item)
    {
        Name = item.name;
        Id = item.Id;
    }
}

在这里一次又一次地将对象引用设置为对象的实例似乎无法修复它。请帮助解决这个问题。先感谢您!

标签: c#unity3d

解决方案


推荐阅读