블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-20 00:00

'Texture Size'에 해당되는 글 2건

  1. 2022.11.30 [NGUI] UILabel-Dynamic Font 글자 깨지는 현상 대응
  2. 2013.06.14 Max Texture Size of iOS Devices

Unity 2021.3.14f1

NGUI 2022.06.08

 

NGUI의 UILabel에 있는 Dynamic Font 글자 사용시 가끔 글자가 깨졌다가 돌아오는 현상이 있어서 수정함.

 

UILabel에서 글자가 깨지는 이유는 Dynamic Font Texture 사이즈가 256x256을 기본으로 쓰다가,

텍스쳐 사이즈가 모자라면 512x512로 늘리는데 사이즈가 변경되는 시점에 잠시 글자가 깨졌다가 보이게 된다고 한다.

그래서 사이즈 변경할 필요 없게 사용하는 폰트의 글자를 모두 로드해 버리기로 했다.

(아래 첨부된 txt 파일의 글자를 로드하니 2048x2048이 나온다. 처음부터 로드하고 써버리기로 함.)

 

아래 [참조]링크의 소스를 참조해서 정리해서 아래와 같이 FontManager에 적용했다.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FontManagerSGT : MonoSingleton<FontManagerSGT>
{
    public delegate void OnChangeFontDelegate(eLanguage _eLanguage);
    public static event OnChangeFontDelegate OnChangeFontEvent;

    public NGUIFont m_nguiFontMain_Dynamic;
    public Font m_fontMain_GO;  // Global
    public Font m_fontMain_JA;  // Japan

    private eLanguage m_eLanguage_Prev = eLanguage.None;
    private eLanguage m_eLanguage_Current = eLanguage.None;

    private string m_strReferenceTxt_GO = null;
    private string m_strReferenceTxt_JA = null;
    private Texture m_textureFontMainTexture = null;
    private TextAsset m_textReferenceTxt = null;


    void Start()
    {
        SetDontDestroy();
    }

    void OnEnable()
    {

    }

    void OnDisable()
    {

    }

    public void SetFont(eLanguage _eLanguage)
    {
        // 폰트매니저용 언어로 변경(JA 외는 GO(글로벌)로 변환)
        m_eLanguage_Current = GetLanguageForFont(_eLanguage);

        ChangeFont(m_eLanguage_Current);
        m_eLanguage_Prev = m_eLanguage_Current;
    }

    public eLanguage GetLanguageForFont(eLanguage _eLanguage)
    {
        switch (_eLanguage)
        {
            // Japan
            case eLanguage.JA:
                return eLanguage.JA;

            // Global(Less)
            default:
                return eLanguage.GO;
        }
    }

    void ChangeFont(eLanguage _eLanguage)
    {
        Debug.LogFormat("[eLanguage] [Prev] {0} [Current] {1}", m_eLanguage_Prev, _eLanguage);

        // 같은 폰트면 Pass
        if (m_eLanguage_Prev == _eLanguage)
            return;

        Debug.Assert(null != m_nguiFontMain_Dynamic);
        Debug.Assert(null != m_fontMain_GO);
        Debug.Assert(null != m_fontMain_JA);

        switch (_eLanguage)
        {
            // Japan
            case eLanguage.JA:
                {
                    m_nguiFontMain_Dynamic.dynamicFont = m_fontMain_JA;
                    FixBrokenWord_JA();
                }
                break;

            // Global(Less)
            default:
                {
                    m_nguiFontMain_Dynamic.dynamicFont = m_fontMain_GO;
                    FixBrokenWord_GO();
                }
                break;
        }

        OnChangeFontEvent?.Invoke(_eLanguage);
    }

    void FixBrokenWord_JA()
    {
        if (m_strReferenceTxt_JA == null)
        {
            m_textReferenceTxt = Resources.Load("ReferenceTxt/ja") as TextAsset;
            if (null != m_textReferenceTxt)
            {
                m_strReferenceTxt_JA = m_textReferenceTxt.ToString();
            }
        }

        if (null != m_strReferenceTxt_JA)
        {
            m_fontMain_JA.RequestCharactersInTexture(m_strReferenceTxt_JA);
            m_textureFontMainTexture = m_fontMain_JA.material.mainTexture; // Font 내부 텍스쳐
            Debug.LogWarning(string.Format("[m_strReferenceTxt_JA] texture : {0}x{1}", m_textureFontMainTexture.width, m_textureFontMainTexture.height)); // 텍스쳐 크기
        }
        else
        {
            Debug.LogWarning("m_strReferenceTxt_JA is null");
        }
    }

    void FixBrokenWord_GO()
    {
        if (m_strReferenceTxt_GO == null)
        {
            m_textReferenceTxt = Resources.Load("ReferenceTxt/go") as TextAsset;
            if (null != m_textReferenceTxt)
            {
                m_strReferenceTxt_GO = m_textReferenceTxt.ToString();
            }
        }

        if (null != m_strReferenceTxt_GO)
        {
            m_fontMain_GO.RequestCharactersInTexture(m_strReferenceTxt_GO);
            m_textureFontMainTexture = m_fontMain_GO.material.mainTexture; // Font 내부 텍스쳐
            Debug.LogWarning(string.Format("[m_fontMain_GO] texture : {0}x{1}", m_textureFontMainTexture.width, m_textureFontMainTexture.height)); // 텍스쳐 크기
        }
        else
        {
            Debug.LogWarning("m_strReferenceTxt_GO is null");
        }
    }
}

 

GO(Global)는 JA(일본어)를 제외한 모든 폰트를 합친 글로벌용 폰트이다.

일본어 한자가 중국어(번체)(대만)와 ASCII 코드가 겹치는 문제로 폰트 자체를 분리했다.

 

소스상에서 Resources.Load 하고 있는 go.txt와 ja.txt는 아래 올려둔다.

폰트를 2개로 분리해놔서 해당 폰트 사용 시, 맞는 txt를 로드하기 위해 Load 파일도 2개이다.

 

첨부된 파일은 폰트 병합 할 때 쓰는 참조용 데이터이기 때문에 모두 로드하면 폰트에 있는 모든 글자를 쓰게 되므로 이걸 로드해서 쓰게되면 더이상 텍스쳐가 커질일은 없을거라 예상된다.

 

 

[폰트 텍스쳐 확장을 위한 참조용 txt 파일]

go.txt
0.03MB
ja.txt
0.01MB

 

 

[참조] https://blueasa.tistory.com/2688

 

[펌] Unity 동적 글꼴 텍스트 깨짐 솔루션(Dynamic Font Broken)

Unity의 동적 글꼴을 사용하여 텍스트를 그릴 때 두 개의 UI 인터페이스가 열리면 그 뒤에 있는 텍스트가 깨집니다(완전히 엉망이 됨). 내가 사용하는 UI 플러그인은 Daikon Forge입니다. 라벨 업데이

blueasa.tistory.com

[참조2] https://blueasa.tistory.com/2664

 

[펌] NGUI - Dynamic Font 글자 깨짐? 사라짐? 현상

게임도중 핸드폰에서 Home 키를 눌러 배경화면으로 이동 후 Server와 끊기기를 기다리고 다시 Server와 리커넥팅 되도록 해서 팝업 떴는데.. Font가 깨졌다. 뭐지.. .... UILabel 에서 DynamicFont 가 이상한

blueasa.tistory.com

 

반응형
Posted by blueasa
, |

Max Texture Size of iOS Devices

When loading OpenGL textures (or sprites, sprite sheets in Cocos2d), the max size for

1024 x 10242048 x 20484096 x 4096
iPhone 2g
iPhone 3g
iPhone 3gs
iPhone 4
iPad
iPhone 4s
iPad 2
iPad 3









출처 : http://gamedev.stackexchange.com/questions/49963/max-texture-size-android-which-settings-for-2048x2048

반응형

'Unity3D > Tips' 카테고리의 다른 글

유니티 메모리 최적화  (0) 2013.07.03
iOS 디바이스 별 메모리 사용 한계치  (0) 2013.07.02
게임 중 일시정지 하기  (0) 2013.05.30
Random.Range(min, max) 함수의 max값에 대해..  (0) 2013.05.21
유니티 소소한 TIP  (0) 2013.04.05
Posted by blueasa
, |