Here is my code
private SelectionItems SI;
private List<GameObject> _selectedList;
private List<GameObject> _lastSelectedList;
private bool _needChange;
void Start () {
_needChange = true;
SI = GetComponent<SelectionItems>();
}
void Update () {
// Get selected objects via a list
_selectedList = SI.GetSelectedList();
// Check if both lists have the same length
if (_selectedList.Count == _lastSelectedList.Count) { _needChange = false; }
else { _needChange = true; }
// Change the second list AFTER the if
_lastSelectedList = _selectedList;
}
I want to understand why, _needChange
is always equal to false
, even when i change my selection in game.
I mean, indeed the length changes depending on my selection, but both lists always have the same length. When _selectedList.Count
changes, _lastSelectedList.Count
also changes BUT BEFORE THE IF and I don’t know why
Thanks for help