Search Unity

Can't disable raycasting on TMP SubMesh?

Discussion in 'UGUI & TextMesh Pro' started by awmcclain, Aug 30, 2018.

  1. awmcclain

    awmcclain

    Joined:
    Dec 24, 2013
    Posts:
    12
    I have a TMP Object that is marked Raycast Target? false -- however, when it creates a submesh (if I have italic and regular text, for example), that submesh still receives raycasts.

    Unity 2018.1.6f1
    TMP 1.0.55.56.0b11
     
    x4000 likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The Raycast Target should inherit the settings of the parent text object.

    I'll try to double check the behavior on my end later today or tomorrow.
     
  3. awmcclain

    awmcclain

    Joined:
    Dec 24, 2013
    Posts:
    12
    Any luck?
     
  4. awmcclain

    awmcclain

    Joined:
    Dec 24, 2013
    Posts:
    12
    hey there! Just wanted to bump this!
     
  5. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    This is still a thing, for sure.
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That should be addressed in the next release which is almost ready.
     
    x4000 likes this.
  7. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    Is there a code snippet I could get that I can just make in my local copy? This is impacting my players in a fairly substantial way. I was trying to figure out how to fix it myself, but I imagine it's only a line or two of code from what I've seen thus far.

    Thanks!
     
  8. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    Note to anyone else looking for this:

    https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Graphic-raycastTarget.html

    The answer is in the fact that TMP_SubMeshUI inherits from MaskableGraphic.

    If you want NONE of your submeshes to ever react to mouse input (as was the case in my case), then you can simply say:

    subMesh.raycastTarget = false;

    right after:

    TMP_SubMeshUI subMesh = go.AddComponent<TMP_SubMeshUI>();

    inside:

    public static TMP_SubMeshUI AddSubTextObject(TextMeshProUGUI textComponent, MaterialReference materialReference)

    That gets the job done, anyhow.
     
  9. obuga

    obuga

    Joined:
    Sep 3, 2019
    Posts:
    3
    Thanks for the post, it will do until Unity will add the toggle.
     
    x4000 likes this.
  10. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    353
    No problem!
     
  11. issac8a

    issac8a

    Joined:
    Aug 29, 2017
    Posts:
    2
    Hi! if anyone is still being bothered by this, if you add this line to the AddSubTextObject function in the TMP_SubMeshUI.cs after the component is created, it will work properly.

    subMesh.raycastTarget = textComponent.raycastTarget;

    Anyways I added the modified script to only replace it in the TextMesh Pro Folder in the packages folder, it is located in:
    Packages->TextMeshPro->Scripts->Runtime
     

    Attached Files:

  12. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This issue should have been resolved in the latest release of the TMP package. See the following entry in the ChangeLog

    - Added synchronization of the RaycastTarget property of the parent &lt;TextMeshProUGUI&gt; with potential child sub text objects. Case #1240784

    Please be sure to use the latest release of the TMP package.
     
  13. connorslyers

    connorslyers

    Joined:
    Aug 8, 2018
    Posts:
    3
    If you're experiencing your TMP blocking other raycasts. Add a canvas component to the TMP you want to disable raycasting on and that will bring it to a new sub canvas that doesn't have the Graphic Raycaster component. Hope this helps you as it did for me :)
     
  14. mateuszwallace

    mateuszwallace

    Joined:
    Dec 13, 2019
    Posts:
    17
    Just go to ExtraSettings in your TextMeshPro-Text component and uncheck RaycastTarget
     
    DavidLTP and Doranna like this.