void RemoveHeldUnit() { StopAllCoroutines(); if (previewObject != null) { Destroy(previewObject); } heldUnit = null; }
public void CreateAndHold(UnPurchasedUnit unitToHold) { RemoveHeldUnit(); heldUnit = unitToHold; // instantiate a preview of the unit with no logic in it previewObject = Instantiate(unitToHold.previewableUnit, Vector3.one * 1000, Quaternion.identity); // get the preview to follow your cursor StartCoroutine(DragUnit()); StartCoroutine(CheckInputs()); }