Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question TMP DropDown generating a 'Blocker' Object that is hanging game.

Discussion in 'UGUI & TextMesh Pro' started by longshotgames, Jul 18, 2022.

  1. longshotgames

    longshotgames

    Joined:
    Nov 16, 2014
    Posts:
    8
    I have a scene with a 2D screen on it. The screen has a Text Mesh Pro DropDown object on it. It's been working as expected for over a year. I recently updated the FB SDK unity package and rebuilt the game. Was going through a regression test and discovered that the dropdown isn't working and causes the game to softlock and I can't figure out why.

    As soon as I click the dropdown object it creates the dropdown list and starts rendering the list but TMP Pro is also adding a gameobject called 'Blocker' 3 levels up in the scene from the dropdown object in the scene heirarchy (as a child of the object that contains the canvas for the screen). The Blocker object has a Canvas component.

    This object is generating the following error on every frame:

    Code (CSharp):
    1. MissingComponentException: There is no 'CanvasRenderer' attached to the "Blocker" game object, but a script is trying to access it.
    2.     You probably need to add a CanvasRenderer to the game object "Blocker". Or your script needs to check if the component is attached before using it.
    It also prohibits all input to the screen as well, softlocking the game.

    I've reverted my changes for the FB SDK upgrade and I'm still getting this error so I'm a bit at a loss. I'm using TPM Pro version 3.0.6. Unity version 2020.2.3f1.

    I saw on another post that there's a setting on the TMP Pro DropDown component for 'Raycast Target' that causes the blocking of input so that it can render. I've tried turning that off but I get the same behavior either way.

    I'm not sure where this object is coming from. I've tried all the usual unity 'reset' options. Re-importing assets, Checked the package manager for any updates, etc. I can't seem to figure out how to get this working. Any ideas on what else to try to debug this?

    Here's the full stacktrace of the error message if this is useful:

    Code (CSharp):
    1. MissingComponentException: There is no 'CanvasRenderer' attached to the "Blocker" game object, but a script is trying to access it.
    2. You probably need to add a CanvasRenderer to the game object "Blocker". Or your script needs to check if the component is attached before using it.
    3. UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.Canvas canvas, UnityEngine.Camera eventCamera, UnityEngine.Vector2 pointerPosition, System.Collections.Generic.IList`1[T] foundGraphics, System.Collections.Generic.List`1[T] results) (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/GraphicRaycaster.cs:329)
    4. UnityEngine.UI.GraphicRaycaster.Raycast (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] resultAppendList) (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/GraphicRaycaster.cs:230)
    5. UnityEngine.EventSystems.EventSystem.RaycastAll (UnityEngine.EventSystems.PointerEventData eventData, System.Collections.Generic.List`1[T] raycastResults) (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:262)
    6. UnityEngine.EventSystems.PointerInputModule.GetMousePointerEventData (System.Int32 id) (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/PointerInputModule.cs:280)
    7. UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:542)
    8. UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:528)
    9. UnityEngine.EventSystems.StandaloneInputModule.Process () (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:282)
    10. UnityEngine.EventSystems.EventSystem.Update () (at /Applications/Unity/Hub/Editor/2020.2.3f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
     
  2. DarkSealer

    DarkSealer

    Joined:
    Nov 24, 2015
    Posts:
    10
    I have the same exact problem with UI Dropdown. Last night it worked perfectly and now I get that missing component exception too. Any solutions yet?
     
  3. StarKRE97

    StarKRE97

    Joined:
    May 5, 2019
    Posts:
    1
    Make a custom dropdown and blocker prefab

    Code (CSharp):
    1.  public class CustomDropdown : TMP_Dropdown
    2.     {
    3.         [SerializeField]
    4.         private GameObject blocker;
    5.        
    6.         protected override GameObject CreateBlocker(Canvas rootCanvas)
    7.         {
    8.             var blocker = Instantiate(this.blocker, rootCanvas.transform);
    9.             return blocker;
    10.         }
    11.     }

    Code (CSharp):
    1.  [CustomEditor(typeof(CustomDropdown))]
    2.     public class CustomDropdownEditor : TMPro.EditorUtilities.DropdownEditor
    3.     {
    4.         SerializedProperty blocker;
    5.  
    6.         protected override void OnEnable()
    7.         {
    8.             base.OnEnable();
    9.             this.blocker = serializedObject.FindProperty("blocker");
    10.         }
    11.  
    12.         public override void OnInspectorGUI()
    13.         {
    14.             base.OnInspectorGUI();
    15.             EditorGUILayout.PropertyField(blocker);
    16.             serializedObject.ApplyModifiedProperties();
    17.         }
    18.     }
     

    Attached Files:

  4. DarkSealer

    DarkSealer

    Joined:
    Nov 24, 2015
    Posts:
    10
    reinstalling Unity solved my problem. It was not just an isolated problem. Every UI element in every project had the same problem. After I reinstalled it the problem was solved.
     
  5. longshotgames

    longshotgames

    Joined:
    Nov 16, 2014
    Posts:
    8
    I tried re-installing but that didn't work. I upgraded my project to Unity 2021.3.5f1 and the problem went away.
     
    DarkSealer likes this.