Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

CanvasGroup loses settings after GameObject disabled/enabled

Discussion in 'UGUI & TextMesh Pro' started by hamstar, Nov 15, 2014.

  1. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    All the boolean settings, such as Interactable, seem to be reset/lost when the GameObject is disabled and re-enabled at runtime. Seems to be a new issue for rc1 or rc2.

    Anyone know if this issue is reported already? Any workarounds?

    Thanks
     
    hadesfury and Jason-Nash like this.
  2. Jason-Nash

    Jason-Nash

    Joined:
    Apr 30, 2014
    Posts:
    20
    I have the same problem!

    UPDATE!
     
  3. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Wait... so they haven't fixed it in RC2? (it already existed in RC1 and was confirmed). Well, at least there's no reason to upgrade then. I'll probably wait for the final release, which hopefully comes after.
     
  4. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    Yup, I'm having this issue with RC2.
     
    hadesfury likes this.
  5. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    When looking at their microscopic RC2 release notes... let me guess, they spare this fix for the "GREAT FINAL RELEASE". Oh, come on Unity...:rolleyes:
     
  6. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    This seems to work for the time being:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class CanvasGroupSettingsFix : MonoBehaviour {
    6.     private CanvasGroup canvasGroup = null;
    7.     private bool interactable = false;
    8.     private bool blocksRaycasts = false;
    9.     private bool ignoreParentGroups = false;
    10.  
    11.     void Awake() {
    12.         canvasGroup = GetComponent<CanvasGroup>();
    13.         if (canvasGroup != null) {
    14.             interactable = canvasGroup.interactable;
    15.             blocksRaycasts = canvasGroup.blocksRaycasts;
    16.             ignoreParentGroups = canvasGroup.ignoreParentGroups;
    17.         }
    18.     }
    19.  
    20.     void OnEnable() {
    21.         if (canvasGroup != null) {
    22.             canvasGroup.interactable = interactable;
    23.             canvasGroup.blocksRaycasts = blocksRaycasts;
    24.             canvasGroup.ignoreParentGroups = ignoreParentGroups;
    25.         }
    26.     }
    27. }
     
  7. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    218
    Yep, reported it a couple weeks ago (#646565). Just checked and it's still happening in RC3. Makes CanvasGroup basically unusable for now.
     
    hamstar likes this.
  8. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    OK. Thank you for letting us know.
     
  9. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    Hi, we will have received the bug and will be fixing
     
  10. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    I hope it will fixed in the next RC. Had to return to pre-RC beta as this bug breaks tons of things.
     
  11. TheDelhiDuck

    TheDelhiDuck

    Joined:
    Aug 29, 2014
    Posts:
    34
    This is still occurring in 4.6.0f3...
     
  12. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    Apparently it has been fixed for 4.6.0p1 out next Thursday.