//
private static List<(int index, T items)> GetEvents<T>(
IList<T> items, Func<T, bool> predicate)
{
var results = new List<(int, T)>();
for (int i = 0; i < items.Count; i++)
{
if (predicate(items[i]))
{
results.Add((i, items[i]));
}
}
return results;
}
public class TestScript : MonoBehaviour
{
[SerializeField] private List<TestEvent> _testEvents;
private int a = 3;
void Start()
{
var events = _testEvents
.Where(item => item.B == a)
.Select((index, item)=> (index, item))
.ToArray();
foreach (var (index, testEvent) in events)
{
// Что-то делаем
}
}
}
public class TestScript : MonoBehaviour
{
[SerializeField] private List<TestEvent> _testEvents;
private int a = 3;
void Start()
{
var events = GetEvents(_testEvents, item => item.B == a);
foreach (var (index, testEvent) in events)
{
// Что-то делаем
}
}
private static List<(int index, TestEvent events)> GetEvents(
IList<TestEvent> testEvents, Func<TestEvent, bool> predicate)
{
var results = new List<(int, TestEvent)>();
for (int i = 0; i < testEvents.Count; i++)
{
if (predicate(testEvents[i]))
{
results.Add((i, testEvents[i]));
}
}
return results;
}
}
// счетчик очков команды
private short _teamCounter;
public short TeamCounter
{
get => _teamCounter;
set => Set(ref _teamCounter, value);
}
OnPropertyChanged(nameof(TeamCounter));
GameObj = (Sprite)Resources.Load("3");