void UpdateRemoveStatus() { if (currentInteractor) { if (currentInteractor.block.CanRemove()) { // Remove the dependances on each connected block foreach (BlockInterface bi in currentInteractor.block.connectedBlocks) { bi.RemoveDependancy(currentInteractor.block); } Destroy(currentInteractor.transform.parent.gameObject); currentInteractor = null; } } else { Debug.Log("Remove the other connected blocks first"); } }
// Intercept the hover status and check if we can actually place it down void SendHoverStatus(ref RaycastInteractor interactor, bool hovered) { if (!hovered) { interactor.ChangeColor(defaultColor); } else { if (previewBI.IsOverlapping()) { interactor.ChangeColor(unplaceableColor); // Disable the preview previewGO.SetActive(false); } else { interactor.ChangeColor(placeableColor); previewGO.SetActive(true); } } }
void UpdateHoverStatus() { if (raycastHit) { currentInteractor = hit.collider.GetComponent <RaycastInteractor>(); if (!currentInteractor) { return; } currentInteractorTf = currentInteractor.transform; UpdatePreviewPosition(); // First Update if (lastInteractor == null && currentInteractor) { SendHoverStatus(ref currentInteractor, true); } // If the last interactor is different else if (lastInteractor && currentInteractor != lastInteractor) { // Disable the last one SendHoverStatus(ref lastInteractor, false); // Enable the new one SendHoverStatus(ref currentInteractor, true); } } else { if (currentInteractor) { SendHoverStatus(ref currentInteractor, false); currentInteractor = null; } previewGO.SetActive(false); } // Set the last interactor for the next frame lastInteractor = currentInteractor; }