U
U
Uncle Bogdan2021-07-12 07:52:03
OOP
Uncle Bogdan, 2021-07-12 07:52:03

Why is there an interface?

Like you can do without them.

class AssetItem : IItem
{
public string Name => _name
public Sprite UIIcon => _uiIcon;

[SerializeField] private string _name;
[SerializeField] private Sprite _uiIcon;

}

interface IItem
{
public string Name { get; }
public Sprite UIIcon;
}

Можно просто так:

 public string Name;
 public Sprite UiIcon;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2021-07-12
@GavriKos

Well, most likely some other Item is supposed, except for AssetItem

V
Vasily Bannikov, 2021-07-12
@vabka

Like you can do without them.

If many types of Items are expected, then an interface is indispensable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question