Search Unity

Can't disable raycasting on TMP SubMesh?

Discussion in 'Unity UI (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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,177
    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:
    298
    This is still a thing, for sure.
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

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

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    298
    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:
    298
    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.