/** * <summary> * On change button clicked * </summary> * * <returns> * void * </returns> */ protected override void OnChangeButtonClicked() { GameObject helicopterGameObject = UnitsManager.ActiveUnit; Helicopter helicopter = helicopterGameObject.GetComponent <Helicopter>(); // Remove / destroy the old body frame helicopter.RemoveBody(); // Get the new reference weapon GameObject selectedBodyItemUI = BodyItemsManager.SelectedBodyItemUI; BodyItemUI bodyItemUI = selectedBodyItemUI.GetComponent <BodyItemUI>(); GameObject referenceBody = bodyItemUI.GetReferencePrefab(); // Add / create a new weapon // Creating a new weapon by the reference and set its parent to the helicopter helicopter.CreateAndSetBodyPart(referenceBody); }