0
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;
    }
}

Getting Object reference not set to an instance of an object again and again over here cant seem to fix it. Kindly help with this issue. Thankyou in Advance!

  • 1
    Your `ItemObject` type doesn't have a `name` property. – DC_AC Sep 30 '21 at 12:20
  • 1
    @DC_AC https://docs.unity3d.com/ScriptReference/ScriptableObject.html it does. `ItemObject` inherits from `ScriptableObject` which does have a `name` property. That's not the problem, it would have been a different error and wouldn't have even compiled. – Philippe B. Sep 30 '21 at 12:33
  • Could you show more code? From your current code the issue is not reproducible since nothing ever happens .. you only showed us some types and a constructor but how is it used? – derHugo Sep 30 '21 at 12:41
  • Also why is there a `[TextArea(15,20)]` attribute without according `string` field? ^^ – derHugo Sep 30 '21 at 12:41
  • yes sure i can share – Burhan Ahmad Sep 30 '21 at 12:42

0 Answers0