Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

changing Default Sprite Asset in TMP Settings at runtime?

Discussion in 'Unity UI & TextMesh Pro' started by Arkorim, Jul 6, 2018.

  1. Arkorim

    Arkorim

    Joined:
    Jan 22, 2014
    Posts:
    7
    Hi,

    I would like to automatically change the Default Sprite Asset located in TMP Settings depending on the target platform.

    Right now I change it manually when building to Switch, PC, Xbox One, etc (I have automated everything else except this). It's easy to forget and an error prone task, so I would like to know how to do it in a proper way.

    Thanks,
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,616
    You should be able to change the default sprite asset assigned to the TMP Setting via scripting. This could be done in a prebuild process. https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.OnPreprocessBuild.html
     
  3. Arkorim

    Arkorim

    Joined:
    Jan 22, 2014
    Posts:
    7
    Hi Stephan,

    I suppose you mean changing TMPro.TMP_Settings.defaultSpriteAsset, but it's read only.

    Am I missing something?

    Thanks,
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,616
    Oops!

    Assuming it was not ready-only, would that solution work for you?

    BTW: If you are using the package manager version of TMP? This version does include source code so you can make that change yourself. I'll take a look on my end and make this property along with others read-write.
     
  5. Arkorim

    Arkorim

    Joined:
    Jan 22, 2014
    Posts:
    7
    Yes, that would work.

    I'm using Unity 2017.4.4 (and I can't update it). And I'm using TMP Release 1.0.54 (December 2016).
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,616
    This release of TMP would be a source code version so, my suggestion is simply for you to modify the properties you need in the TMP_Settings.cs file.
     
  7. Arkorim

    Arkorim

    Joined:
    Jan 22, 2014
    Posts:
    7
    If I look in the Unity project for TMP_Settings I get a reference to this file "TextMeshPro-1.0.55.56.0b9.dll" but no TMP_Settings.cs file.

    Is there a TMP compatible version with Unity 2017.4.4 that includes source code so I can edit the file? or another solution?

    Thanks,
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,616
    As per the above, you are using the Free / dll-only version of TextMesh Pro which doesn't include source code.

    The versions of TextMesh Pro available via the package manager (2018.1) do include source code but those are for 2018.1 and up.

    The previous source code versions of TextMesh Pro use a different set of GUIDs and FileIDs but there was / is no utility to convert project between those two. There is such utility with the new 2018.1 versions of TMP.

    Is upgrading the project to 2018.1 possible for you?
     
  9. Arkorim

    Arkorim

    Joined:
    Jan 22, 2014
    Posts:
    7
    Hi! Thanks for the answer. I can't upgrade it now, but I will change them manually for this project and I will try to upgrade to 2018.1 or above for the next projects.
     
    Stephan_B likes this.