Search code examples
stringfontsunity-game-enginemonodevelopunityscript

Font issue in unity 3d


Hi I imported a font and using it in GUISkin for buttons. But I am getting a warning

Font size and style overrides are only supported for dynamic fonts.
UnityEngine.GUI:Button(Rect, String)

How to escape from this?

Thanks in Advance


Solution

  • private float guiDiff;
    
    public GUIStyle scoreStyle;
    
    // in start function
    
    guiDiff = screenResolution.x / 480f;  (480 is my testing equipment width)
    
    scoreStyle.fontSize = Mathf.CeilToInt(15 * guiDiff);
    

    Its works fine for me in all device.