Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

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,340
    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!