Assignment to null not necessary. All the same you next line overwrites this most null . Nothing wrong with that, just an extra operation.
Note that you do not copy the list at all, despite the name of the function. Since List<T> is a reference type, you simply write in the oldList link to the same list that comes to you in newList . If you really need a copy of the list, the easiest thing to do is:
public void CopyMyList( List<GameObject> newList) { if (oldList != null) // я сохраняю ту же логику oldList = newList.ToList(); }
As @ iluxa1810 correctly suggests in the comments, even with this, the list will still contain links to the same objects , from the changes in these objects in the newList list will be “visible” and in the oldList list. If this is not what you need, you will have to clone and objects. To do this, in the GameObject you need to implement the ICloneable interface, and instead of oldList = newList.ToList() write a more complex oldList = newList.Select(o => (GameObject)o.Clone).ToList() .