From 57840c6ad1233491acfd27ea1f5e476c162dd859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Sch=C3=B6ner?= <tobias.stonehead@gmail.com> Date: Thu, 12 Jan 2023 22:46:56 +0100 Subject: [PATCH] fix: WorldFactInteraction now uses CanvasGoup alpha instead of Image alpha CanvasGroup alpha also affects child GameObjects alpha, whereas Image alpha only affects the Image itself --- Assets/Scripts/InteractionEngine/WorldFactInteraction.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs b/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs index 64d70e57..da67c757 100644 --- a/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs +++ b/Assets/Scripts/InteractionEngine/WorldFactInteraction.cs @@ -20,7 +20,7 @@ void LateUpdate() if (currentDisplay != null && currentDisplay.GetComponent<DragHandling>().dragged) { // currently dragging -> remove transparency to indicate dragging and let DragHandling.cs take over - ChangeImageAlpha(currentDisplay.GetComponent<Image>(), 1); + currentDisplay.GetComponent<CanvasGroup>().alpha = 1; return; } @@ -56,7 +56,7 @@ private void UpdateDisplay() } currentDisplay.transform.position = Input.mousePosition; // move currentDisplay to mousePosition - ChangeImageAlpha(currentDisplay.GetComponent<Image>(), 0.5f); // ensure that image alpha is correct, since it could have changed due to dragging + currentDisplay.GetComponent<CanvasGroup>().alpha = 0.5f; // ensure that image alpha is correct, since it could have changed due to dragging lastHit = hit.transform; } @@ -71,11 +71,6 @@ private void InstantiateNewDisplay(FactObject factObj) } #region Helper - private static void ChangeImageAlpha(Image img, float alpha) - { - img.color = new Color(img.color.r, img.color.g, img.color.b, alpha); - } - /// <summary> /// Returns true if any UI other than currentDisplay was hit /// </summary> -- GitLab