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

카테고리

분류 전체보기 (2815)
Unity3D (869)
Script (92)
Extensions (16)
Effect (3)
NGUI (81)
UGUI (9)
Physics (2)
Shader (37)
Math (1)
Design Pattern (2)
Xml (1)
Tips (202)
Link (23)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (81)
Trouble Shooting (70)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (12)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (18)
Ad (14)
Photon (2)
IAP (1)
Google (11)
URP (2)
Android (51)
iOS (46)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (236)
협업 (61)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (16)
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

 

[링크] https://mentum.tistory.com/376

 

유니티 프로모션용 영상/동영상 촬영

유니티에서 프로모션 영상을 제작할 때 1. 에디터에서 OBS 등으로 직접 영상 촬영 2. 디바이스에 넣은 상태로 영상촬영 정도로 프로모션 영상 소스를 제작하곤 했는데, iOS용 프로모션 동영상을 만들 때 문제가 되..

mentum.tistory.com

 

반응형
Posted by blueasa
, |

Unity Editor-Edit-Preferences-General에 보면 Script Changes While Playing 옵션이 있다.

 

기본이 위 스크린샷 처럼 'Recompile And Continue Playing'이라서, 플레이 중에 소스 수정하면 리컴파일 되고 에러가 열심히 난다

 

플레이 중엔 리컴파일 안되도록 막기 위해서 2번째인 'Recompile After Finished Playing'로 바꿨다.

 

 

[출처] 게임코디-핑크님

반응형
Posted by blueasa
, |

플랫폼 대응을 위해 유니티 버전을 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
, |