/** * <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 weapon helicopter.RemoveWeapon(); // Get the new reference weapon GameObject selectedWeaponItemUI = WeaponItemsManager.SelectedWeaponItemUI; WeaponItemUI weaponItemUI = selectedWeaponItemUI.GetComponent <WeaponItemUI>(); GameObject referenceWeapon = weaponItemUI.GetReferencePrefab(); // Add / create a new weapon // Creating a new weapon by the reference and set its parent to the helicopter helicopter.CreateAndSetWeaponPart(referenceWeapon); }
// Update is called once per frame private void Update() { // On left button down if (Input.GetMouseButtonDown(0)) { // Make sure the mouse is not over the UI if (!EventSystem.current.IsPointerOverGameObject()) { if (UnitPartComponentsManager.SelectedPartComponentUI != null) { UnitPartComponentUI unitPartComponentUI = UnitPartComponentsManager.SelectedPartComponentUI .GetComponent <UnitPartComponentUI>(); unitPartComponentUI.SetSelect(false); } if (UnitPartEditorsManager.ActivePartEditorUI != null) { UnitPartEditorsManager.ActivePartEditorUI.SetActive(false); UnitPartEditorsManager.ActivePartEditorUI = null; } } // Disable selected body item UI to false if (BodyItemsManager.SelectedBodyItemUI != null) { BodyItemUI bodyItemUI = BodyItemsManager.SelectedBodyItemUI .GetComponent <BodyItemUI>(); bodyItemUI.SetSelect(false); } // Disable selected weapon item UI to false if (WeaponItemsManager.SelectedWeaponItemUI != null) { WeaponItemUI weaponItemUI = WeaponItemsManager.SelectedWeaponItemUI .GetComponent <WeaponItemUI>(); weaponItemUI.SetSelect(false); } } }