您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

38 行
1.0 KiB

using System;
using System.Collections.Generic;
using UnityEngine;
namespace Unity.Multiplayer.Samples.BossRoom
{
/// <summary>
/// ScriptableObject class that contains a list of a given type. The instance of this ScriptableObject can be
/// referenced by components, without a hard reference between systems.
/// </summary>
/// <typeparam name="T"></typeparam>
public abstract class RuntimeCollection<T> : ScriptableObject
{
public List<T> Items = new List<T>();
public event Action<T> ItemAdded;
public event Action<T> ItemRemoved;
public void Add(T item)
{
if (!Items.Contains(item))
{
Items.Add(item);
ItemAdded?.Invoke(item);
}
}
public void Remove(T item)
{
if (Items.Contains(item))
{
Items.Remove(item);
ItemRemoved?.Invoke(item);
}
}
}
}