Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TextMesh Pro Check if TextMesh Pro is present in project

Discussion in 'UGUI & TextMesh Pro' started by Johannski, Jul 1, 2018.

  1. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    706
    Is there a way to check if TMP is present in a project? The question is regarding to assets for the asset store that want to support TMP, but only if it is present.

    Is there a script define smybole, or should we check if a class exists and then establish our own script define?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,570
    I used to add the "TMP_PRESENT" to the global defines in OnInitializeOnLoad() but was never satisfied with that handling so I removed it.

    The ability to add global defines for package is something that is being looked into as it is a common request. I proper solution is in the works.
     
    Hosnkobf likes this.
  3. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    706
    Ah okay, so I do remeber this correctly. Thanks for the answer, I guess as of now it is best to just deal with an extra download to support TMP or just create an own script define. Thanks, looking forward to the streamlined solution.
     
  4. seizestudios

    seizestudios

    Joined:
    Oct 18, 2016
    Posts:
    24
    Hello guys!
    Are there any updates on this issue?
    I'm now searching for assemblies and adding my own compile condition. And that kind of sucks...
    A TMP native way would be great.
     
  5. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    94
  6. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,632
    Still no macro?
     
  7. Amoo0001

    Amoo0001

    Joined:
    Mar 7, 2019
    Posts:
    10
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,570
    You should be able to check for the presence of the TMP package via the Package Manager API.
     
  9. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,632
    Hello Stephan,
    Does the API work in a build or only in Editor?
    We need a compiler macro to ensure certain code TMP-dependant only compiles if TMP is present, otherwise it will throw errors.
    Do you have perhaps a short snippet we can use to detect TMP safely?
    Thanks
     
  10. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    627
  11. VrGamesDev

    VrGamesDev

    Joined:
    May 7, 2018
    Posts:
    26
  12. Siccity

    Siccity

    Joined:
    Dec 7, 2013
    Posts:
    245
    Any update on this?
     
  13. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    5,570
    Assuming you are using Assembly Definitions in Unity 2019.4 or newer, you can use the Version Defines feature to define in your own "define" for TMP.

    To do this, you would edit your assembly definition (.asmdef) which for this example is called "MyAssemblyDefinition".

    upload_2020-12-16_13-4-13.png

    Once this is done, you can then use that version define in any of the scripts in your assembly where if the "com.unity.textmeshpro" assembly is present it will be true. In this example, I used version 1.0.0 but you could revise this to check for a specific version of the TMP package such as 1.5.3-preview.0.

    Since TMP is included by default with the Editor, the package will pretty much always be present but that doesn't mean the user is using TMP or has imported the TMP Essential Resources. But for that you can simply check for the present of the "TextMesh Pro" folder in the project or if the TMP Settings are present in the project.

    Please let me know if this is a workable solution for your use case.
     
    Last edited: Dec 16, 2020
unityunity