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

카테고리

분류 전체보기 (2737)
Unity3D (817)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (70)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (11)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
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-28 00:03

플랫폼 대응을 위해 유니티 버전을 2018.3.5f1에서 2018.4.2f1로 버전업을 하였는데 그 뒤로 비주얼스튜디오를 유니티에 붙이면 멈춤 현상이 일어났다. 당연히 브레이크 포인트에 걸리지 않은 상태였고 Attach를 해제하면 정상작동을 하였다.

원인은 유니티의 오래된 버그라고한다.

해결방법은 비주얼스튜디오에 남아있는 모든 중단점을 삭제한 후 다시 Attach하게되면 정상작동하게된다. 이 후 브레이크포인트를 걸고 작업 후 다시 Attach를 해도 문제없이 작동한다.

출처 : https://forum.unity.com/threads/unity-freeze-when-connecting-vs-debugger.529863/

 

 

[출처] https://puzi.tistory.com/19

 

[비주얼 스튜디오] 디버그를 위해 Unity에 Attach할 시 Freeze현상

플랫폼 대응을 위해 유니티 버전을 2018.3.5f1에서 2018.4.2f1로 버전업을 하였는데 그 뒤로 비주얼스튜디오를 유니티에 붙이면 멈춤 현상이 일어났다. 당연히 브레이크 포인트에 걸리지 않은 상태였고 Attach를..

puzi.tistory.com

 

반응형
Posted by blueasa
, |

 

[링크] https://github.com/Over17/UnityAndroidNotchSupport

 

Over17/UnityAndroidNotchSupport

Support for Android Notch (Cutout) in Unity 2017.4 and earlier - Over17/UnityAndroidNotchSupport

github.com

UnityAndroidNotchSupport

Android devices with a notch (display cutout) have recently become quite common. However, if you make a Unity application and deploy it to such device, by default Android OS will letter-box your app so that it the notch doesn't interfere with your UI.

If you want to make use of the whole display surface area and render in the area "behind" the notch, you need to add code to your application. Fortunately, since Unity 2018.3 there is a special option in the Player settings called "Render outside safe area" which does exactly this. If you want to have the same option in earlier versions of Unity - this plugin was made for you!

One advantage of this plugin over the built-in Unity solution is that it allows changing the setting in runtime if needed, by calling public void SetRenderBehindNotch(bool enabled) in RenderBehindNotchSupport.

If you are planning to make use of "rendering behind the notch" feature, you'll also need another feature which returns you the area of the screen which is outside of the notch area (and is safe to render to). The API is equivalent to what Screen.safeArea API does in newer Unity versions, and returns a Rect.

This plugin is targeted towards Unity 2017.4, however I see no reasons why it shouldn't work with earlier versions too.

System Requirements

  • Tested on Unity 2017.4.28f1. Should work on any Unity version out there, but make sure your target API is set to 28 or higher. There is no point in using this plugin in Unity 2018.3 or later because these versions have notch support out of the box.
  • An Android device with Android 9 Pie or later. Some devices with earlier Android versions have notch/cutout, but Google has added a corresponding API only in Android 9. Feel free to add other vendor-specific bits of code to add support on earlier Androids at your own risk.

Usage

  1. Copy the contents of Assets directory to your project
  2. Attach the Assets/Scripts/RenderBehindNotchSupport.cs script to a game object of your choice in your first scene to make sure the plugin is loaded as early as possible
  3. The script has a public boolean property so that you can tick/untick the checkbox to enable or disable rendering behind the notch with a single click
  4. If you want to change the setting in runtime, call public void SetRenderBehindNotch(bool enabled) in RenderBehindNotchSupport class.
  5. Attach the Assets/Scripts/AndroidSafeArea.cs script to a game object of your choice if you need the safe area API. The property AndroidSafeArea.safeArea is returning a Rect, use it to layout your UI.
  6. Enjoy

Alternative solution

Instead of using the script (or if you want to apply the "render behind the notch" flag as early as possible), you could modify the theme used by Unity. To do so, please create a file at the path Assets/Plugins/Android/res/values-v28/styles.xml with the following contents:

Unity 2017.4 or newer

<?xml version="1.0" encoding="utf-8"?> <resources> <style name="BaseUnityTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen"> <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> </style> </resources>

Before 2017.4 (ie. 5.6)

<?xml version="1.0" encoding="utf-8"?> <resources> <style name="UnityThemeSelector" parent="android:Theme.Material.Light.NoActionBar.Fullscreen"> <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> </style> </resources>

There is no need to add the script to your project in this case. You may also need to tweak the snippet above if you are using a custom theme.

I recommend using the default approach with the script unless you have good reasons to do otherwise.

Useful Links

License

Licensed under MIT license.

반응형
Posted by blueasa
, |

우선, NGUI의 UIAnchor 대해 SafeAreas 대응 할 수 있기 때문에 참고.

이외에도 SafeAreas으로 다음의 대응이 필요하지만,이 기사에서는 UIAnchor의 대처 방법을 설명합니다.

필요할 수 :

· UIRect의 Anchor

· UIScrollView의 표시 범위 조정 (Anchor의 기준이 변화하기 때문에 UI 조정해야 할)




Contents [ hide ]

전제 조건 :

이 문서는 다음을 전제로 이야기를 진행합니다.

· Unity5.6.6를 사용하여 개발하고 있습니다.

· iOSSafeAreasPlugin을 다운로드하여 가져올 수 있음

Plugin 다운로드 사이트

https://bitbucket.org/p12tic/iossafeareasplugin/src

· OS는 iOS만을 고려하고 있습니다.

소스 코드

우선 소스 코드에서 공개합니다.

안전 영역의 취득

SafeAreaScreen.cs

이 소스 코드는 주로 안전 영역의 취득을 담당하고 있습니다.

Unity 편집기에서 화면 크기를 iPhoneX와 같은 크기 (1125 × 2436)로 설정하면 Unity Player에서 디버그 할 수도 있습니다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;

public class SafeAreaScreen  {

#if UNITY_IOS
    [DllImport("__Internal")]
    private extern static void GetSafeAreaImpl(out float x, out float y, out float w, out float h);
#endif

    static public Rect GetSafeArea()
    {
        float x, y, w, h;

        //初期値設定
        x = 0;
        y = 0;
        w = Screen.width;
        h = Screen.height;

#if UNITY_IOS && !UNITY_EDITOR
        //iOSSafeAreasPluginを呼び出す
        GetSafeAreaImpl(out x, out y, out w, out h);

#elif UNITY_ANDROID && !UNITY_EDITOR
        //Androidの縦長端末対応が必要になったときのために

#else


        //UnityエディタでiPhoneXのテストできるように値を設定する
        if(Screen.width == 1125 && Screen.height == 2436 ){
            y = 102;
            h = 2202;
        }

#endif
        return new Rect(x, y, w, h);
    }

    static public int GetTopOffsetY(){
        int offset = 0;

        //画面の高さとセーフエリアの高さの差分
        Rect screenSize = GetSafeArea();

        if (Screen.height != screenSize.height) {
            offset = Screen.height - (int)screenSize.height - (int)screenSize.y;
        }

        return offset;
    }

    static public int GetBottomOffsetY(){
        int offset = 0;

        //セーフエリアのyの位置取得
        Rect screenSize = GetSafeArea();

        if (Screen.height != screenSize.height) {
            offset = (int)screenSize.y;
        }

        return offset;
    }

}

NGUI의 SafeArea

NguiSafeAreaPatch.cs

SafeAreaScreen.cs에서 얻은 안전 영역을 바탕으로 Anchor의 위치를 ​​조정합니다.

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

public class NguiSafeAreaPatch : MonoBehaviour {

    void Awake()
    {
        // UIAnchorを使ってAnchorを設定している場合
        UIAnchor anchor = gameObject.GetComponent();
        if(anchor != null){

            //offsetの値を取得する
            SetUIAnchorOffset(anchor);

            return;
        }

        // UIRectをAnchorを使っている場合
        UIRect rect = gameObject.GetComponent();
        if (rect != null) {
            //現在,NGUIのソースコードを解析中
            //完成しだい公開予定
            return;
        }
    }

    private void SetUIAnchorOffset(UIAnchor anchor){

        //現在のoffsetを取得する
        Vector2 nowOffset = anchor.pixelOffset;

        //TOP側の補正値取得
        int topCorrectionOffset = SafeAreaScreen.GetTopOffsetY ();

        //Bottom側の補正値取得
        int bottomCorrectionOffset = SafeAreaScreen.GetBottomOffsetY ();

        switch (anchor.side) {

            case UIAnchor.Side.Top:
            case UIAnchor.Side.TopLeft:
            case UIAnchor.Side.TopRight:
                anchor.pixelOffset.Set(nowOffset.x, nowOffset.y - topCorrectionOffset);

            break;

            case UIAnchor.Side.Bottom:
            case UIAnchor.Side.BottomLeft:
            case UIAnchor.Side.BottomRight:
                anchor.pixelOffset.Set(nowOffset.x, nowOffset.y + bottomCorrectionOffset);			
            break;


        }
        
    }



}

 

사용법은이 소스 코드를 UIAnchor가 부착되어있는 게임 객체에 첨부 할뿐.

소스에서 무슨 일을하는지는 동작 환경이 iPhoneX 판정되면 스크린과 안전 영역의 높이의 차이를 계산하여 차등 분 게임 오브젝트를 낮 춥니 다.

델타 값은 UIAnchor의 "Pixel Offset"에 할당됩니다.

소스 코드를 반영한 ​​결과

NguiSafeAreaPatch.cs을 UIAnchor에 연결시킨 결과를 기재합니다.

■ 반영 전

■ 반영 후

그 결과 안전 영역을 기준으로 할 수있었습니다.

이것으로 UIAnchor 대해서는 SafeArea의 대처가되었습니다.

그러나, 그 밖에도 「UIRect의 Anchor '에 대해서도 SafeAreas 대응이 있습니다. 대응이 끝나는대로 수시 문서에 추가하는 것입니다.

 

 

[출처] https://dream-target.jp/2018/10/01/post-470/

 

UnityにてiPhoneX対応・NGUIのUIAnchorにSafeAreaの補正処理を入れてみた

とりあえず、NGUIのUIAnchorについてSafeAreas対応ができたのでメモ。 実行環境がiPhoneXと判定したら、スクリーンとセーフエリアの高さの差分を計算して、差分だけゲームオブジェクト(UIAnchorがアタッチされていること)を下げます。

dream-target.jp

 

반응형
Posted by blueasa
, |

Unity Script에서 UIApplicationExitsOnSuspend Key 제거(with PostProcessBuild)

----

 

using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using System.IO;
using UnityEditor.iOS.Xcode;
#endif
 
public class BuildProcessor
{
   [PostProcessBuild(1)]
   public static void OnPostprocessBuild(BuildTarget buildTarget, string pathToBuiltProject)
   {
#if UNITY_IOS
      // Get plist
      string plistPath = pathToBuiltProject + "/Info.plist";
      PlistDocument plist = new PlistDocument();
      plist.ReadFromString(File.ReadAllText(plistPath));
 
      // Get root
      PlistElementDict rootDict = plist.root;
 
      // Set encryption usage boolean
      string encryptKey = "ITSAppUsesNonExemptEncryption";
        rootDict.SetBoolean(encryptKey, false);
 
      // remove exit on suspend if it exists.
      string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
      if(rootDict.values.ContainsKey(exitsOnSuspendKey))
      {
         rootDict.values.Remove(exitsOnSuspendKey);
      }
 
      // Write to file
      File.WriteAllText(plistPath, plist.WriteToString());
#endif
   }
}

 

[출처] https://forum.unity.com/threads/the-info-plist-contains-a-key-uiapplicationexitsonsuspend.689200/

 

The Info.plist contains a key 'UIApplicationExitsOnSuspend

I have this error after updated my inapp module. Using unity 2018.3.13f1 ITMS-90339: Deprecated Info.plist Key - The Info.plist contains a key...

forum.unity.com

 

 

[참조] https://blog.naver.com/yoohee2018/221566174487

 

[Unity] Deprecated Info.plist Key - The Info.plist contains a key 'UIApplicationExitsOnSuspend'

Unity 2019.1.4.1f​[19.06.19 기준 에러발생]유니티 iOS 빌드하여 Xcode에서 Archive 제출 시 다음과...

blog.naver.com

 

반응형
Posted by blueasa
, |

[링크] https://jwidaegi.blogspot.com/2019/07/unity-notch-ui.html

 

Unity Notch(노치) 단말기 UI 설정

상단의 프레임 아래쪽으로 툭 튀어나와 있는 H/W 영역인 Notch의 처리를 위해 체크해야 하는 항목을 정리해 둔다. 빌드 세팅 Player Setting > Android > Resolution and Presentation 내부 설정 확인 ...

jwidaegi.blogspot.com

 

반응형
Posted by blueasa
, |

1. 이슈

어제, 지금 만드는 게임의 배포국가가 추가되었다.

기존 뉴질랜드, 싱가폴, 필리핀에서 + 캐나다.

 

이에 따라, 캐나다에 웹서버를 한대 더 두기로 결정을 했는데 클라이언트에서는 지역에 따라 A 서버와 B 서버를 구분해서 접속을 시도해야하는 기능을 구현해야 한다.

 

 

2. 방법 모색 & 문제점

- SIM 정보를 가져와서 처리

-> SIM 정보를 얻어 올 수 없는 경우가 많다. (타블렛등)

 

- 핸드폰의 언어 정보를 가져와서 처리

-> 한국인인데 영어를 쓰는 경우 생각보다 많다.

 

- 지금 사용중인 akamai에서 area 정보를 받아서 처리

-> 정보를 알려줄 방법이 없다고 한다..

 

3. Geo IP

ip 찾는 사이트 보면 내가 접속한 지역을 찍어주는 기능이 있는데, 이걸 우리도 쓸 수 있지 않을까 해서 찾아봤다. Geo IP 라는 기능이 있다고 한다.

http://php.net/manual/kr/book.geoip.php

 

설치하고 셋팅해줘야 한다고 한다.

일단 지금은 셋팅 할 시간도 없고 해서

 

4.http://www.telize.com/

구글링 검색은 "how to find ip address region json data"

GeoIP를 rest API로 내려주는 사이트 몇몇개가 있는데 telize.com으로 선택

이유는

-> 무료

-> 콜 수 제한 없음

 

나중에 우리서버에 구축을 해야하나..? 란 생각이 들었는데 이건 알아서 업데이트 해줄거 같으니 그때 가서 생각하기로.

기부를 받고 있으니 감사하게 생각하시면 기부를.

서버 개발자의 하루 일당 정도를 줘도 괜찮지 않을까.

 

5. 사용법

매우 씸플하다.

유니티의 WWW 클래스에 담아서 리스폰스 메시지를 json으로 파싱.

private IEnumerator getGeoIP()
{
    WWW www = new WWW("http://www.telize.com/geoip");
 
    while (!www.isDone)
    {
        yield return new WaitForSeconds(0.1f);
    }
 
    SimpleJSON.JSONNode node = SimpleJSON.JSONNode.Parse(www.text);
 
    Debug.Log(node);
}

 

{"dma_code":"0","ip":"x.xx.xxx.xxx","asn":"AS3786","city":"Seoul","latitude":37.5985,"country_code":"KR","offset":"9","country":"Korea, Republic of","region_code":"11","isp":"안알랴쥼ㅋ","timezone":"Asia\/Seoul","area_code":"0","continent_code":"AS","longitude":126.9783,"region":"Seoul-t'ukpyolsi","country_code3":"KOR"}

 

 

우리에게 필요한건 country_code (국가코드)랑 continent_code(대륙코드)

대륙코드의 값은 PHP 레퍼런스에서 확인 할 수 있다.

http://php.net/manual/kr/function.geoip-continent-code-by-name.php

 

북미+남미 / 아시아 에 따라 주소만 다르게 넣어주면 끝.

 

끝!

 

[출처] https://180bpm.tistory.com/105

 

클라이언트의 접속지역 정보를 Rest API로 받아오기.

1. 이슈 어제, 지금 만드는 게임의 배포국가가 추가되었다. 기존 뉴질랜드, 싱가폴, 필리핀에서 + 캐나다. 이에 따라, 캐나다에 웹서버를 한대 더 두기로 결정을 했는데 클라이언트에서는 지역에 따라 A 서버와 B..

180bpm.tistory.com

 

반응형
Posted by blueasa
, |

배포시 가장 큰 골치덩어리중 하나는 AndroidManifest.xml 파일 수정문제일 것이다.
Android Plugin을 만들어서 넣자니 짜증나고... 그럴때 간단하게 AndroidManifest.xml 파일을 수정할 수 있는 방법을 공개한다.

프로젝트 Root폴더에 보면 "Temp" 폴더가 생성되어 있을텐데 거길 가만히 보면 "StagingArea"라는 폴더가 보인다.
여기로 들어가면 다음과 같이 폴더가 구성되어 있다.

빌드에서 사용될 각종 Resource 파일들이 보일텐데 이중에 필요한건 
AndroidManifest.xml 파일과 res 폴더 두개이다. 이 2개를 선택해서 CTRL+C 해서 복사하고 
유니티로 돌아와서 "Plugins" 폴더를 만든다음 다시 "Android"폴더를 만들고 거기에 복사해 넣자.

이제 복사한 AndroidManifest.xml 파일을 열어서 마음대로 주무르면 됨. 끝!

 

[출처] http://www.wolfpack.pe.kr/872

 

Unity3D AndroidManifest.xml 파일 Custom으로 수정하고자 할때

트랙백 주소 :: 이 글에는 트랙백을 보낼 수 없습니다

www.wolfpack.pe.kr

 

반응형
Posted by blueasa
, |

오라클의 유료화 이슈로 OpenJDK를 설치하려는데

현재 버전(Unity v5.6.6f2)에서 좀 편하게 설치할 방법이 없을까 하다가 꼼수로 해놓은 방법 간단 정리해 놓습니다.



[유니티 버전] v5.6.6f2


[OpenJDK 간단(?) 설치 방법]

1. Unity2018.3 이상 버전을 설치


2. Unity2018.3의 Preferences에 보면 아래와 같이 기본 내장 OpenJDK가 설정 돼 있다.


3. Unity2018.3이 설치 된 곳에 가보면 위에 설명된 (AndroidPlayer/Tools/OpenJDK)를 찾을 수 있는데 정확한 경로는 아래와 같다.

   2018.3 설치 위치를 찾아서 아래 경로대로 찾아가자.

  [Unity2018설치경로] ...\2018.3.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\OpenJDK


4. 3번의 위치까지 찾아가면 아래와 같이 OS별 폴더가 보인다.


5. 유니티 5.6.6의 Preferences에서 JDK를 아래처럼 해당 OS 폴더까지 패스로 골라준다.


나의 경우 Unity Hub를 깔아서 전체 경로는 아래와 같다.


[전체경로]

C:\Program Files\Unity\Hub\Editor\2018.3.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\OpenJDK\Windows



[추가]

Unity Hub를 쓰면 버전별로 설치가 계속 돼서 Path가 바뀌는 문제 때문에 OpenJDK 폴더를 통째로 복사해서 다른 곳에 옮겨 두고 쓰기로 했다.

(예: C:\OpenJDK)


반응형
Posted by blueasa
, |


[링크]

https://orcacode.tistory.com/entry/Unity%EC%97%90%EC%84%9C-iPhone-X%EB%A5%BC-%EB%8C%80%EC%9D%91%ED%95%98%EB%8A%94-%EA%B0%84%ED%8E%B8%ED%95%9C-%EB%B0%A9%EB%B2%95


[플러그인]

https://github.com/rlatkdgus500/UnitySafeAreaController


반응형
Posted by blueasa
, |

컬링(Culling)

  • 최종 화면에 영향을 미치지 않는 물체를 파악하고 이를 렌더링 대상에서 제외시켜 필요한 물체만 그리는 기법
  • 프러스텀 컬림(Frustum Culling)
    • 가장 기본적이면서도 효과가 좋은 방법
    • 카메라 영역내의 공간 정보만 살려두고 영역 외부에 설정된 정보는 모두 버림
    • 카메라에 프로젝트에 설정된 레이어별로 차단 거리(Per-Layer Cull Distances)를 지정하면 이 값을 사용해 레이어에 속한 게임 오브젝트들을 컬링함
  • 오클루젼 컬링(Occlusion Culling)
    • 기존의 절두체를 이용한 컬링 기법의 한계를 보완하고 효율적으로 공간 정보를 관리해 빠르게 렌더링을 수행할 수 있게 도와주는 기법
    • Unity의 Windows => Occlusion Culling 메뉴를 통해 설정
    • 오클루젼 컬링 제작방법
      1. 오클루젼 영역 설정
      2. 오클루젼 컬링 데이터 제작
      3. 최종 결과 시뮬레이션
    • 오클루젼 포털(Occlusion Portal)
      • 오클루젼 영역을 스크립트로 조절하는 기능

드로우 콜 배칭(Draw Call Batching)

  • 텍스쳐 아틀라스(Texture Atlas)를 사용하여 콜수를 줄임
  • 성질이 동일한 물체들을 하나의 메시와 재질을 사용하게 통합
    • 여러 게임 오브젝트의 메시를 하나의 메시로 통합해주는 CombineChildren 컴포넌트를 제공
    • 최상위 게임 오브젝트에 이 컴포넌트를 사용하면 자식 오브젝트들이 갖는 메시들을 분석한 후 재질별로 메시를 통합해 재가공함
    • 컴바인 메시(Combined Mesh)를 통한 작업시 주의할 점
      • 게임 오브젝트들을 통합하면 게임 오브젝트별로 움직일 수 없게 됨
      • 관련된 빛의 계산이 통합된 모든 메시를 대상으로 수행됨
    • 메터리얼(Materials)
      • 다른 텍스쳐에 있는 두개의 독립적인 메터리얼을 하나의 큰 텍스쳐로 결합 할 수 있음(텍스처 아틀라스)
      • 일단 텍스처를 동일한 아틀라스로 묶으면 단일 메터리얼로 사용할 수 있게 됨
    • 배칭(Batching)
      • 현재 씬의 상황을 판단해 자동으로 드로우 콜을 줄이게 최적화하는 기능

      • 정적 배칭 Static Batching (Pro required)

        • Static 옵션이 설정된 게임 오브젝트에서 동일한 재질을 사용하는 물체가 있는 경우 유니티는 이들을 자동으로 하나의 메시로 통합 관리함
        • 움직이지 않는 물체에 대해 지정만 하면 자동으로 수행
      • 동적 배칭 Dynamic Batching

        • 움직이는 물체를 대상으로 동일한 재질을 사용하는 경우 이를 판단해 자동으로 메시를 통합해 드로우 콜을 줄여주는 기능
        • 총 정점의 데이터 수가 900개 미만인 메시를 지닌 게임 오브젝트만을 대상으로 수행됨
        • 메시 데이터가 위치 외에도 노멀, UV, 라이트맵 UV 등 총 3개의 속성을 갖고 있는 경우 정점의 수가 225개를 넘으면 동적 배칭이 적용되지 않음

최적의 퍼포먼스를 위한 캐릭터 모델링(Modeling Characters for Optimal Performance)

  • 싱글 스킨 메쉬 렌더러 사용

    • 각 캐릭터에 스킨 메쉬 렌더러(class-SkinnedMeshRenderer)는 하나여야 합니다.
    • Unity는 시야 컬링 및 경계 볼륨의 업데이트를 사용하여 애니메이션을 최적화하고, 이러한 최적화는 하나의 애니메이션 컴포넌트 및 하나의 스킨 메쉬 렌더러를 사용하는 경우에만 활성화됩니다.
    • 모델의 렌더링 시간은 두개의 스킨 메쉬를 사용할때 하나의 스킨 메쉬를 사용 할 때보다 대략 2배 정도 이며, 여러개의 메쉬를 사용하여 실질적인 메리트가 있는 일은 드뭅니다.
  • 가능한 메터리얼을 적게 사용

    • 각 메쉬의 메테리얼의 수를 최대한 적게 해야 합니다.
    • 여러 메테리얼을 캐릭터에서 사용하는 이유는, 다른 부분에서 다른 쉐이더가 필요한 경우 뿐 입니다(예를 들면 눈 부분은 특수 쉐이더).
    • 그러나 캐릭터에서 두 개 또는 세 개의 메테리얼로 거의 모든 케이스에 충분 합니다.
  • 가능한 한 본(Bones)를 적게 사용

    • 전형적인 데스크톱 게임의 본 계층은 15개에서 60개 사이의 본을 사용합니다.
    • 본의 수가 적을수록 퍼포먼스가 좋아집니다.
    • 30개 정도의 본으로 데스크톱 플랫폼에서는 아주 좋은 품질을 얻을 수 있고, 모바일 플랫폼에서도 비교적 좋은 품질을 얻을 수 있습니다.
    • 이상적으로는 모바일 장치에서는 30개보다 적게 하고, 데스크톱 게임에서도 30개를 크게 초과하지 않도록 합니다.
  • 폴리곤 갯수를 적게 사용

    • 폴리곤 수는 필요한 품질 및 대상 플랫폼에 의존합니다.
    • 모바일 장치는 메쉬 당 300에서 1500 폴리곤으로 좋은 결과를 얻을 수 있으며, 데스크톱 플랫폼에서의 이상적인 범위는 1500에서 4000 정도입니다.
    • 반면, 게임에 많은 캐릭터가 있을 때 메쉬 당 폴리곤의 수를 줄일 필요가 있을 것 입니다.
    • 예를 들어, Half Life 2는 캐릭터에 2500 - 5000 삼각형 수였습니다.
    • 현재 PS3와 XBox 360의 최고 랭크 게임은 보통 캐릭터에 5000에서 7000 삼각형 수입니다.
  • 포워드 및 역운동학을 분리

    • 애니메이션이 임포트 될 때, 모델의 역운동학(IK) 노드는 포워드 운동학(FK)에 베이크(baked)된 결과로 Unity는 IK 노드가 전혀 필요 없습니다.
    • 그러나 모델에 남아있으면 애니메이션에 영향을 미치지 않음에도 불구하고 CPU 오버 헤드가 발생합니다.
    • 선호에 따라 Unity 또는 모델링 도구, 어느 것이든 중복 IK 노드를 제거할 수 있습니다.
    • 이상적으로는 IK 및 FK 계층을 모델링 시에 별도로 보관하여 필요할 때 IK 노드를 쉽게 제거할 수 있도록 해야 합니다.

렌더링 통계 창(Rendering Statistics Window) 확인

  • Time per frame and FPS
    • 하나의 게임 프레임을 처리 및 렌더링하는데 걸린 시간(프레임/초)
    • 이 숫자는 프레임 업데이트 및 게임 뷰의 렌더링에 걸린 시간만 포함되는 것에 유의
    • 에디터가 씬 뷰 인스펙터의 그리기 및 에디터 전용 작업을 수행하는데 걸린 시간은 포함되지 않음
  • Batches
    • “Batching” is where the engine attempts to combine the rendering of multiple objects into a chunk of memory in order to reduce CPU overhead due to resources switching.
  • Saved by batching
    • Number of batches that was combined. To ensure good batching, you should share materials between different objects as often as possible.
    • Changing rendering states will break up batches into groups with the same states.
  • Tris and Verts 그려진 삼각형과 정점의 수. 이것은 optimizing for low-end hardware에서 중요합니다.
  • Screen 화면 크기, 안티 앨리어싱 레벨 및 메모리 사용량.
  • SetPass 렌더링 패스의 수. 각 패스에 대해서 유니티 런타임은 CPU 오버헤드를 가져올 수 있는 새로운 쉐이더를 바인딩한다.
  • Visible Skinned Meshes 렌더링된 스킨 메쉬 수
  • Animations 재생 에니메이션 수

프레임 디버거(Frame Debugger)

  • 메뉴: Window > Frame Debugger
  • 매 프레임마다 그리는 오브젝트 정보를 보여줌

쉐이더 로딩타임 최적화(Optimizing Shader Load Time)

항상 포함하는 쉐이더와 미리 로딩해야 하는 쉐이더 집합을 설정하여 쉐이더 로딩시간을 효율적으로 관리해 줌

  • 항상 포함하는 쉐이더(Always Included Shaders)

    • Project Settings > Graphics > Always Included Shaders
  • 미리 로딩하는 여러가지 쉐이더 집합(Preloaded Shader Variant Collection)

    • 쉐이더 집합 생성

    • Assets > Create > Shader Variant Collection

    • 쉐이더 집합 미리 로딩 목록에 추가

    • Project Settings > Graphics > Preloaded Shaders

텍스처 캐시(Texture Cache)

  • 모바일의 경우 GPU 제조사에서 권장하는 텍스처 포멧을 사용하면 캐시 적중률이 높아져 속도의 향상을 얻게 되며, 특히 GPU의 성능이 약한 스마트폰 기기에서는 이러한 부분의차이가 큼
  • 플랫폼별 권장 텍스처 포멧
  • 안드로이드 텍스처 압축 지원
    • http://stackoverflow.com/questions/9148795/android-opengl-texture-compression/9514396#9514396
    • ETC1 (Ericsson texture compression)
      • This format is supported by all? Android phones.
      • But, It doesn't support an alpha channel, so can only be used for opaque textures.
    • PVRTC (PowerVR texture compression)
      • Supported by devices with PowerVR GPUs (Nexus S, Kindle fire ...)
    • ATITC (ATI texture compression)
      • Used in devices with Adreno GPU from Qaulcomm (Nexus One ...)
    • S3TC (S3 texture compression)
      • This texture compression is used in the NVIDIA chipset integrated devices (Motorola Xoom ...)
  • 안드로이드 Developer에 정의된 내용
    • https://developer.android.com/guide/topics/graphics/opengl.html#textures
    • ATITC (ATC) - ATI texture compression
      • GL_AMD_compressed_ATC_texture
      • GL_ATI_texture_compression_atitc
    • PVRTC - PowerVR texture compression
      • GL_IMG_texture_compression_pvrtc
    • S3TC (DXTn/DXTC) - S3 texture compression
      • GL_OES_texture_compression_S3TC
      • GL_EXT_texture_compression_s3tc
      • GL_EXT_texture_compression_dxt1
      • GL_EXT_texture_compression_dxt3
      • GL_EXT_texture_compression_dxt5
    • 3DC - 3DC texture compression
      • GL_AMD_compressed_3DC_texture
// Texture compression supported on Android
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
  Strings = gl.glGetString(GL10.GL_EXTENSIONS);
 
  if (s.contains("GL_IMG_texture_compression_pvrtc")) {
    // Use PVRTC compressed textures
  } else if (s.contains("GL_AMD_compressed_ATC_texture") ||
             s.contains("GL_ATI_texture_compression_atitc")) {
    // Use ATITC compressed textures
  } else if (s.contains("GL_OES_texture_compression_S3TC") ||
             s.contains("GL_EXT_texture_compression_s3tc")) {
    // Use DTX Textures
  } else {
    // Handle no texture compression founded
  }
}

텍스처 설정

  • Texture
  • Normal map
  • Editor GUI and Legacy GUI
  • Sprite (2D and UI)
  • Cursor
  • Reflection
  • Cookie
  • Lightmap
  • Advanced

텍스처 포멧지원 확인

텍스처 생성팁

오버드로우(Overdraw)

  • 물체가 겹쳐서 뒤에 있는 물체를 그린후에 앞에 있는 물체를 다시 그리면 겹치는 부분만큼 픽셀을 계산해서 그려야 함
  • 이렇게 특정 영역의 픽셀을 다시 그리는 것을 오버드로우라고 함
  • 불투명한 물체의 오버드로우를 줄이는 좋은 방법은 가장 큰 영역을 차지하는 물체를 먼저 그리게 설정하는 것

유용한 에셋





[출처] https://github.com/zzragida/UnityDocs/wiki/Graphics-Optimization

반응형
Posted by blueasa
, |