Skip to content

Font Material and Font Texture became empty when modifying font asset #370

@roundRekt

Description

@roundRekt

Code

for obj in env.objects:
    if obj.type.name == "Font":
        data = obj.parse_as_object()
        data.m_FontData = f.read()
        data.save()

or

for obj in env.objects:
    if obj.type.name == "Font":
        data = obj.parse_as_dict()
        data["m_FontData"] = f.read()
        obj.patch(data)

Error
N/A

Bug
When I use the above code to modify a font, everything appears to work correctly. However, during testing, all fonts fail to render properly. After inspecting the asset file, I found that the Font Material and Font Texture became empty. Then I added the following code at the end and reran my script, then the modified font works fine:

else:
    obj.set_raw_data(obj.get_raw_data())

I’m not sure why it fixed the issue. Did I do something wrong, or is this some kind of bug?

To Reproduce
Just run the code attached to modify a font asset.

  • Environment:
    • Python 3.14.4
    • UnityPy 1.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions