Special Thanks to Marrrrk for this example script:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class SelectionManager
{
public List<Unit> _selection = new List<Unit>();
public Action<Unit> UnitSelected;
public Action<Unit> UnitDeselected;
public void Select(Unit unit)
{
if (_selection.Contains(unit))
return;
_selection.Add(unit);
if (UnitSelected)
UnitDeselected(unit);
}
public void Deselect(Unit unit)
{
if (!_selection.Contains(unit))
return;
_selection.Remove(unit);
if (UnitSelected)
UnitSelected(unit);
}
public static SelectionManager Default = new SelectionManager();
}
There error is when the following line is called
if (UnitSelected)
UnitSelected(unit);
I’ve never used List’s of Action’s before, and I can’t quite figure this out, so thanks for any help.