YAPYAP

Details

Last Updated
2 months ago
First Uploaded
2 months ago
Downloads
664
Likes
1
Size
17KB
Dependency string
Jettcodey-YapYap_FontAPI-1.0.0
Dependants

Categories

Deprecated

FontAPI

A simple library to replace the YapYap game Font for the UI and 3DWorld.

Handles UI text (TextMeshProUGUI) and 3D World text (TextMeshPro) automatically.

How to use (For Modders)

  1. Reference the DLL: Add Jettcodey.FontAPI.dll as a reference in your C# project.
  2. Add Dependency: Add [BepInDependency("Jettcodey.FontAPI")] to your BaseUnityPlugin.
  3. Load & Set: Load your AssetBundle and pass the TMP Font Asset to the API.

Code Example

using BepInEx;
using UnityEngine;
using Jettcodey.FontAPI; 

[BepInPlugin("myname.coolfont", "My Cool Font", "1.0.0")]
[BepInDependency("Jettcodey.FontAPI")] 
public class MyFontMod : BaseUnityPlugin
{
    public static MyFontMod Instance { get; private set; }
    internal static new ManualLogSource? Logger { get; private set; }
    private Harmony _harmony;

    private void Awake()
    {
        Instance = this;
        _Logger = base.Logger;

        // 1. Load your AssetBundle
        string pluginDir = Path.GetDirectoryName(Info.Location);
        string path = Path.Combine(pluginDir, "myfontbundle");

        AssetBundle bundle = AssetBundle.LoadFromFile(path);

        if (bundle == null) 
        {
            Logger.LogError("Failed to load bundle!");
            return;
        }

        // 2. Register the font
        // IMPORTANT: Use the name of the "SDF" Asset, not the .ttf file
        FontAPI.LoadAndSet(bundle, "MyCoolFont SDF");
        
        Logger.LogInfo("Font replaced!");
    }
}

Creating the AssetBundle

The game cannot load raw .ttf files. You must create a TextMeshPro Font Asset in Unity.

  1. Unity Version: Use the same Unity version as the game (for YAPYAP, this is v6000.0.x).

  2. Import Font: Drag your .ttf or .otf into Unity.

  3. Create Asset: Right-click the font -> Create -> TextMeshPro -> Font Asset.

  4. Settings:

    • Character Set: Unicode Range (Hex)
    • Atlas Population Mode: Dynamic (Recommended)
    • Atlas Render Mode: SDF or SDFAA
  5. Build the Assetbundle: Assign the generated SDF Asset to an AssetBundle (e.g., myfontbundle) and build it.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.