사용버전 : unity 2020.1.1

In Unity Profiler

    • Window-Analysis-Profiler(Standalone Process)
      - 별도의 Process를 할당한 Profiler로 Editor가 할당하는 부하를 프로젝트와 별개로 볼 수 있다.
    • Preferences-Analysis-Profiler
      - FrameCount 조절가능(최대 2000)
      - 크게 설정할 경우 메모리 사용량 증가
    • GPU도 Profiling할수 있음
      - 디테일은 떨어지니 참고용으로 사용
      - URP는 안됨, BuiltIn만 가능
      - 모바일에선 안됨
      - CPU 병목과 GPU병목을 확인가능하다.
    • Begin/End Profiling By Script

  • Flow Event
    - Job에 대한 Profiling가능

In Memory Profiler

  • Diff Two SnapShots
    - 메모리 leak 추적가능 (2개의 SnapShot을 찍어 Diff로 비교하여 메모리 변화에 대해 확인가능)
  • Show total Memory Usage
    - 기본적으로 Unity에서 추적하는 메모리는 메모리 할당시 사용하는 Native함수(malloc, new등)호출 시 Tag를 달아서 추적한다. 그렇다 보니 각 플랫폼별 메모리 특성이 달라 구체적인 정보를 제공하지 못한다.
    - 그래서 약간의 커스텀을 통해 전체 메모리 사용량을 구할 수 있다.
    - TreeMapPane.cs -> 

In Frame Debugger

  • Why this draw call cant be catched
    - 랜더링 사이의 batch가 깨졌는지(하나의 묶음으로 그리지 못했는지-드로우콜 증가) 이유 표시
  • Use RenderDoc
    - GPU의 Render 정보를 쉽게 볼수있는 오픈소스 프로그램
    - 유니티와 호환이 잘된다.
    - 셰이더 디버깅도 가능!

 

'게임개발 > 유니티' 카테고리의 다른 글

AssetBundle 관리  (0) 2020.04.13
(Unity)안드로이드 전화번호 가지고오기  (0) 2019.08.29
단발성 진동 알람 이벤트 처리  (0) 2019.04.24
unity google play games plugin 연동 문제  (0) 2018.08.17
베지어 곡선  (0) 2017.01.17
  • AssetBundleManifest
    - CRC : 해당 번들의 무결성을 체크할 수 있다.(Load 중 파일이 손상 될 경우를 체크하기 위해 사용)

    - Hash :  번들의 버전 고유값으로 파일이 변경됐는지 체크하는 용도
        (AssetBundlemanifest.GetAssetBundleHash()를 사용하면 해당 버전 Manifest의 bundle의 hash를 가져올수있다.)

    - Dependencies : 해당 번들의 종속관계에 있는 번들리스트

  • UnityWebRequestAssetBundle
    - UnityWebRequst를 통해 CND에서 GET방식으로 AssetBundle을 불러올 때 사용한다.
  • DownloadHandlerFile(저장 경로)
    - CDN에서 다운받은 파일을 로컬에 저장할 때 사용하면 좋다.
    (C#의 io를 이용하여 저장할 경우, 해당 파일들이 메모리에 할당되고 복사하기 위해 같은 크기만큼 메모리를 할당하여 파일 size*2의 메모리가 사용된다. 이 문제를 해결해 주는 클래스)
    - UnityWebRequest.downloadhandler에 넣어주면 된다.

  • AssetBundle.LoadFromFileAsync
    - AssetBundle을 받을 때 비동기로 받는다.
    - 주로 CRC를 이용한 Load를 할 때 사용한다.
    (CRC로드는 메모리 사용량도 있고, 속도가 느리기 때문, 대신 파일 무결성이 보장된다)

  • AssetBundle.LoadFromFile
    - AssetBundle을 받을 때 동기로 받는데.
    - 이걸로 CRC Load를 하게되면 받는 동안 Thread가 멈춰 다른일을 할 수 없게된다.
    (그래서 CRC Load는 비동기 처리하자) 

 

    AndroidJavaClass m_UnityPlayer;
    AndroidJavaObject m_CurrentActivity;
    AndroidJavaClass m_ContextCombat;
    
    // 생성자
    public PermissionManager()
    {
        // Unity Android의 부모역할을 하는 클래스
        m_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        // 현재 실행되고 있는 Android Activity를 가져온다
        m_CurrentActivity = m_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
        // 권한여부를 가져올 수 있는 클래스
        m_ContextCombat = new AndroidJavaClass("android.support.v4.content.ContextCompat");
    }
    
    /** GetAndroidPhoneNumber를 Android Code로 이해할 경우.
       public class CurrentActivity extends  UnityPlayerActivity
       {
           protected void GetPhoneNumber()
           {
               TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
               PhoneNumber = tm.getLine1Number();
           }
       }
    */
    public string GetAndroidPhoneNumber()
    {
        string str = "";

        if (m_CurrentActivity == null)
            return "";

        if (IsPermissionGranted(Permissions.READ_PHONE_STATE) == false)
            return "";

        // 액티비티에서 Android Navtive Method 인 "getSystemService"를 호출
        AndroidJavaObject pServiceObj = m_CurrentActivity.Call<AndroidJavaObject>("getSystemService", "phone");
        if (pServiceObj == null)
            return "";

        // 자바 클래스 가져옴
        AndroidJavaClass clazz = new AndroidJavaClass("java.lang.Class");
        if (clazz == null)
            return "";

        // 자바 클래스에 있는 TelephonyManager클래스 가져옴
        AndroidJavaObject pDest = clazz.CallStatic<AndroidJavaObject>("forName", "android.telephony.TelephonyManager");
        if (pDest == null)
            return "";

        //"getSystemService"로 가져온 SystemService Instance를 TelephonyManager로 캐스팅함
        AndroidJavaObject pTelephonyService = pDest.Call<AndroidJavaObject>("cast", pServiceObj);
        if (pTelephonyService == null)
            return "";

        //이로서 pTelephonyService은 TelephonyManager의 인스턴스로 사용가능
        str = pTelephonyService.Call<string>("getLine1Number");
        //Debug.Log("PhoneNumber1 : " + str);

        if (string.IsNullOrEmpty(str) == true)
            return "";

        if (str.Length > 0 && str[0] == '+')
        {
            str = "0" + str.Substring(3);
        }

        //Debug.Log("PhoneNumber2 : " + str);
        return str;
    }

'게임개발 > 유니티' 카테고리의 다른 글

[UniteSeoul 2020] Tips & Tricks For Using Profiler  (0) 2020.12.02
AssetBundle 관리  (0) 2020.04.13
단발성 진동 알람 이벤트 처리  (0) 2019.04.24
unity google play games plugin 연동 문제  (0) 2018.08.17
베지어 곡선  (0) 2017.01.17

필요 예) 게임을 Auto Mode로 설정 한 뒤 설정한 조건에 의해 Auto가 종료 될 경우 이것을 알려주기 위해 핸드폰을 단발적으로 진동 시킨다.

 

사용 - Handheld.Vibrate();

설명 - 디바이스를 1회 진동시킨다.

-문제-

  • Social.localUser.Authenticate 호출 시 App Crash(튕김) 현상 발생
  • Social.localUser.Authenticate에 보낸 콜백이 호출 되지 않음

-원인-

  • Google Play Games Plugin Setup시 입력한 ClientID가 AndroidManifest.xml에 저장된 ClientID와 동일하지 않을경우 발생
    (AndroidManifest.xml 경로 : ../Assets\GooglePlayGames\Plugins\Android\GooglePlayGamesManifest.plugin/AndroidManifest.xml)
  • 하지만, 확인결과 xml과 동일하게 들어가 있었음
  • Unity Build 시 AndroidManifest.xml병합 설명 : https://docs.unity3d.com/Manual/android-manifest.html

-해결-

  • Unity Android 빌드 시 AndroidManifest.xml 병합 과정에서 개행문자 오류로 인해 ClientID부분을 잘못 인식 하고 있었음
  • xml ClientID에 '\u003'문자 추가 후 해결
  • <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 232323232323" />
    -> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\u003232323232323" />
  • 참고자료 : https://github.com/playgameservices/play-games-plugin-for-unity/issues/2013


// 0.0 >= t <= 1.0 her be magic and dragons  
    public Vector3 GetPointAtTime(float t)
    {
        float u = 1f - t;
        float tt = t * t;
        float uu = u * u;
        float uuu = uu * u;
        float ttt = tt * t;

        Vector3 p = uuu * this.points[0].position; //first term  
        p += 3 * uu * t * this.points[1].position; //second term  
        p += 3 * u * tt * this.points[2].position; //third term  
        p += ttt * this.points[3].position; //fourth term  

        return p;
    }
t : 시간
point[0] : 시작지점
point[1] : 조절 지점 1
point[2] : 조절 지점 2
point[3] : 도착 지점

 

+ Recent posts