Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Test (in script) if TMP is installed for a project?

Discussion in 'UGUI & TextMesh Pro' started by Seanba, Mar 8, 2018.

  1. Seanba

    Seanba

    Joined:
    Nov 17, 2012
    Posts:
    33
    It doesn't look like installing TMP from the package manager adds any Scripting Define Symbols to the Player. Is there a way to test in script for TMP being installed so that custom script classes/methods can be compiled out?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The TMP_PRESENT should be defined when the TMP package is present.
     
  3. Seanba

    Seanba

    Joined:
    Nov 17, 2012
    Posts:
    33
    Thanks for the reply.

    I'm currently on Unity 2018.1.0b6 with TextMeshPro 1.2.1 and there is no such define in either the player settings or my generated vs2017 solution file.

    I'm not up-to-speed on how the Package Manager but when I look at the code for TMP that would call
    SetScriptingDefineSymbolsForGroup
    it is commented out. Is that to be expected? Or does it even matter?

    C:\ProgramData\Unity\cache\packages\packages.unity.com\com.unity.textmeshpro@1.2.1\Scripts\Editor\TMP_ResourcesLoader.cs



    //static class TMP_ProjectSettings
    //{
    // [InitializeOnLoadMethod]
    // static void SetProjectDefineSymbols()
    // {
    // string currentBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);

    // //Check for and inject TMP_INSTALLED
    // if (!currentBuildSettings.Contains("TMP_PRESENT"))
    // {
    // PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currentBuildSettings + ";TMP_PRESENT");
    // }
    // }
    //}
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Looks like I need to re-implement this... forgot I had disabled it along the way.
     
    Seanba likes this.