Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feedback Can't save font asset in local package

Discussion in 'UGUI & TextMesh Pro' started by Baste, Apr 12, 2023.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224
    I'm trying to work on one of our internal packages. I want to have a TMP_Font inside the package, as the package has some prefabs with TMP text elements. I was trying to modify the font file in the package, but ran into a problem:

    I'm currently developing the package as we usually do, by embedding it directly from a local drive, so our manifest.json has this:

    "com.rain.thepackage": "file:C:/Blah",

    This is how we work on packages, as it allows us to edit the code and assets directly, while still seeing how the package behaves as a package (as opposed to what would happen if we had it in the Assets/ folder of a test project). But TMP doesn't support this, because the test for if you can click this button:

    upload_2023-4-12_12-59-4.png

    is this:

    Code (csharp):
    1. string dataPath = Application.dataPath;
    2.  
    3. if (filePath.IndexOf(dataPath, System.StringComparison.InvariantCultureIgnoreCase) == -1)
    4. {
    5.     Debug.LogError("You're saving the font asset in a directory outside of this project folder. This is not supported. Please select a directory under \"" + dataPath + "\"");
    6.     return;
    7. }
    There's probably some code inside Unity that decides if a path is immutable or not, as Unity complains if we try to change code/assets inside an immutable package, but allows us to modify a mutable one just fine. So you should probably be using that instead!