Search Unity

Problems accessing CanvasGroup alpha method

Discussion in 'Immediate Mode GUI (IMGUI)' started by DDD-ARM, Sep 15, 2014.

  1. DDD-ARM

    DDD-ARM

    Joined:
    Sep 15, 2014
    Posts:
    2
    Hi,

    I would like to fade a group of UI elements so I grouped in a CanvasGroup to be able to use the Alpha property. It works as expected when using the editor but when accessing it through the script I'm not able to get the alpha method at runtime (i get a MissingMethod exception).

    My code is simply:

    void Start()
    {
    _mainGUICanvasGroup = _mainGUI.GetComponent<CanvasGroup>();
    }

    void Update()
    {
    //Get new alpha
    _mainGUICanvasGroup.alpha = alpha;
    }

    Did someone else had the same problem and can suggest how to solve it?

    DDD
     
  2. DDD-ARM

    DDD-ARM

    Joined:
    Sep 15, 2014
    Posts:
    2
    Quick update. Setting the alpha in the animator works correctly. A workaround I've implemented for now is to have an array of CanvasRenderer to contain all the elements that needs to be faded and use the SetAlpha property for each of them when updating the alpha.
     
  3. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    Got the same issue; currently using Unity 5 b5.

    Also, I've got this error in the inspector:
    MissingMethodException: Cannot find the requested method.
    UnityEngine.UI.Selectable.OnCanvasGroupChanged () (at C:/buildslave/unity/build/Extensions/guisystem/guisystem/UI/Core/Selectable.cs:133)
    UnityEditor.DockArea:OnGUI()
     
  4. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    Did Unity ever address this problem? It's still ongoing for me in 5.2 .... changing CanvasGroup.alpha from code during runtime doesn't do anything
     
  5. xDavidLeon

    xDavidLeon

    Joined:
    Jun 9, 2014
    Posts:
    123
    I think it got fixed some months ago.. but I haven't updated to 5.2 (still using 5.1.3), as I've read plenty of threads about UI bugs in 5.2.