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

카테고리

분류 전체보기 (2843)
Unity3D (891)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (188)
협업 (64)
3DS Max (3)
Game (12)
Utility (140)
Etc (99)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (52)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

유니티 (Unity)에서 멀티 키 딕셔너리 (Multi Key Dictionary)를 사용하는 방법에 대해 검색 결과를 제공해드리겠습니다.

멀티 키 딕셔너리는 두 개 이상의 키로 값을 저장하고 검색할 수 있는 자료구조입니다. 유니티에서는 기본적으로 이러한 기능을 제공하지 않지만, 다음과 같은 방법을 사용하여 멀티 키 딕셔너리를 구현할 수 있습니다:

Tuple을 사용한 멀티 키 딕셔너리 구현: Tuple을 이용하여 여러 키를 하나의 키로 묶고, 해당 키에 대한 값을 딕셔너리에 저장하는 방식입니다. 이렇게 하면 여러 키로 값을 조회하거나 저장할 수 있습니다.

using System;
using System.Collections.Generic;

public class MultiKeyDictionary<TKeyTuple, TValue>
{
    private Dictionary<TKeyTuple, TValue> dictionary = new Dictionary<TKeyTuple, TValue>();

    public void Add(TKeyTuple keys, TValue value)
    {
        dictionary[keys] = value;
    }

    public bool TryGetValue(TKeyTuple keys, out TValue value)
    {
        return dictionary.TryGetValue(keys, out value);
    }
}

// 사용 예시
var multiKeyDict = new MultiKeyDictionary<(int, string), int>();
multiKeyDict.Add((1, "key1"), 100);
multiKeyDict.Add((2, "key2"), 200);

if (multiKeyDict.TryGetValue((1, "key1"), out int result))
{
    Debug.Log("Value found: " + result);
}


C# 9의 init-only 프로퍼티와 튜플 사용: C# 9부터 init-only 프로퍼티를 사용하여 딕셔너리의 값을 읽기 전용으로 설정하고, 튜플을 활용하여 멀티 키를 표현할 수 있습니다.

using System;
using System.Collections.Generic;

public class MultiKeyDictionary<TValue>
{
    private Dictionary<(int, string), TValue> dictionary = new Dictionary<(int, string), TValue>();

    public void Add(int key1, string key2, TValue value)
    {
        dictionary[(key1, key2)] = value;
    }

    public IReadOnlyDictionary<(int, string), TValue> Dictionary => dictionary;
}

// 사용 예시
var multiKeyDict = new MultiKeyDictionary<int>();
multiKeyDict.Add(1, "key1", 100);
multiKeyDict.Add(2, "key2", 200);

if (multiKeyDict.Dictionary.TryGetValue((1, "key1"), out int result))
{
    Debug.Log("Value found: " + result);
}

이렇게 유니티에서 멀티 키 딕셔너리를 구현할 수 있습니다. 코드는 예시일 뿐이며, 실제 프로젝트에서 적절한 방식으로 적용하셔야 합니다.

 

[출처] ChatGPT

 

[참조] https://stackoverflow.com/questions/1171812/multi-key-dictionary-in-c

 

Multi-key dictionary in c#?

I know there isn't one in the BCL but can anyone point me to a good opensource one? By Multi I mean 2 keys. ;-)

stackoverflow.com

 

 

반응형
Posted by blueasa
, |

[링크] https://github.com/agens-no/iMessageStickerUnity

 

GitHub - agens-no/iMessageStickerUnity: An iMessage Sticker plugin for Unity3d that adds a Sticker extension target to an xCode

An iMessage Sticker plugin for Unity3d that adds a Sticker extension target to an xCode project created by Unity3d - GitHub - agens-no/iMessageStickerUnity: An iMessage Sticker plugin for Unity3d t...

github.com

 

 

반응형
Posted by blueasa
, |

[링크] https://hanamoni.tistory.com/31

 

Unity - Dictionary 를 Inspector 에 간단하게..

유니티에서 사용하는 Dictionary 는 Inspector 에서 보이지 않아서 데이터 확인해야 할때 불편하다. 그래서 이미 사용하고 있는 Dictionary 데이터들을 간단하게 인스펙터에 표시하기 위해서 만든 클래

hanamoni.tistory.com

 

 

반응형
Posted by blueasa
, |

[파일]

Transparent - Cutout ChromakeyShader.shader
0.00MB

 

[링크] https://seokiki0413.tistory.com/1

 

[Unity] Chromakey 동영상 투명하게 플레이 하는 Tip

유니티에서 동영상 배경을 투명하게 처리하는 방법은 Shader를 이용해서 합니다.Shader란 정의를 찾아보았으나 없었고,제가 생각하기에 Shader란 자바스크립트 계열의 일종으로 보입니다.(제 생각)

seokiki0413.tistory.com

 

 

반응형
Posted by blueasa
, |



반응형
Posted by blueasa
, |

 [링크] http://lancekun.com/blog/?p=599

 

안드로이드 Gradle / IL2CPP 환경에서 프로세스 남는 현상 – 랜스군의 게임공작소

유니티2018.3.12 에서gradle로 빌드시에 Application.Quit 으로 종료이후 다시 재실행시 UnityIAP 초기화가 실패하는 경우가 있습니다. 대략적으로 Inventory를 갱신시켜준후 Java프록시 호출이 실패하는 이슈(

lancekun.com

 

반응형
Posted by blueasa
, |

[추가]

아래 방법은 Mono 전용으로IL2CPP에서는 런타임 오류가 난다.

IL2CPP 빌드로 바껴서 현재는 사용 못할 것 같다.

-----------------------------------------------------------------

 

System.Diagnostics.ProcessThreadCollection pt = System.Diagnostics.Process.GetCurrentProcess().Threads;
foreach (System.Diagnostics.ProcessThread p in pt)
{
    p.Dispose();
}
System.Diagnostics.Process.GetCurrentProcess().Kill();

 

[링크] https://chopchops.tistory.com/17

 

[Unity] 게임 재실행시 튕기는 오류

게임을 재시작했을때 게임이 갑자기 꺼지는 기이한 현상 해결 1 ) 게임이 종료될때 모든 Thread가 종료되지 않아서 발생하는 문제라는 의견 -> 게임종료시 모든 스레드 종료 1 2 3 4 5 6 7 8 9 10 11 privat

chopchops.tistory.com

 

[참조1] https://202psj.tistory.com/1341

 

[Unity] 유니티 종료,Quit, Exit 관련

================================= ================================= ================================= 출처: https://hyunity3d.tistory.com/386 using UnityEngine; using System.Collections; public class CsGameManager : MonoBehaviour { // Use this for initia

202psj.tistory.com

[참조2] https://blog.naver.com/captainj/221103098214

 

Application.Quit으로 앱종료시 오류 메시지가 뜰때

종종 유니티에서 Application.Quit() 함수로 앱을 종료하는 경우, 앱은 정상적으로 종료는 되지만 오류 ...

blog.naver.com

 

반응형
Posted by blueasa
, |

Unity 2021.3.41f1

----

 

[추가4] 2024-08-06

Play Asset Delivery v1.9.1이 업데이트 돼있어서 적용함.

 

[추가3] 2024-03-27

Play Asset Delivery v1.9.0(2024-03-27 기준 최신)이 업데이트 됐다.

1.9.0은 최소 Unity 버전이 2017.4로 표기돼있다.(버전별 문제를 해결한건가..?)

 

[추가2]

AssetDelivery 1.7.0으로 iOS 빌드 하면서 ./GooglePlayPlugins/com.google.play.assetdelivery/Samples 폴더 관련 소스에서 에러가 나서 삭제 함.

 

[추가]

aab파일 150mb 초과해서 구글스토어 올리려고 알아보고

아래 [링크]의 내용대로 진행해서  Play Asset Delivery v1.8.2(2023-04-25 기준 최신)를 설치해서 빌드해보니,

빌드는 잘 되지만 실행하면 크래시 나면서 앱이 죽는다.

버전 정보를 보면 Play Asset Delivery v1.8.0 이상부터는 Unity 최소 버전이 2023.1.0 (베타)이다.

(1.8.0이상은 2023.1.0 이상이라고 돼있지만 2022.2.18f1에서 정상동작 하는걸 확인했다.)

 

[참조] https://github.com/google/play-unity-plugins/issues/187

 

Crash at Android 12 · Issue #187 · google/play-unity-plugins

Hello I'm now experiencing crash on android devices with Android 12 only. thread.cc:2372] Throwing new exception 'No interface method getPackStates(Ljava/util/List;)Lcom/google/android/play/core/ta...

github.com

 

크래시 내용을 찾아보니 위[참조]와 같은 내용이 있다.

Firebase와 PAD(Play Asset Delevery)와 호환성 문제가 있는 것 같다.

 

참조 링크의 내용대로면 현재 Play Asset Delivery v1.8.x 버전은 제대로 안되고, Play Asset Delivery v1.7.0을 사용해서 성공했다고 한다.

 

[Github:Play Unity Plugins v1.7.0] https://github.com/google/play-unity-plugins/releases/tag/v1.7.0

 

Release v1.7.0 · google/play-unity-plugins

com.google.play.integrity (v1.0.0) New Features Initial release Unchanged Packages com.google.android.appbundle (v1.7.0) com.google.play.appupdate (v1.7.0) com.google.play.assetdelivery (v1.7.0)...

github.com

[Google Play:Play Asset Delivery] https://developers.google.com/unity/archive?hl=ko#play_asset_delivery

 

Unity용 Google 패키지 다운로드  |  Google Developers

이 페이지는 Cloud Translation API를 통해 번역되었습니다. Switch to English Unity용 Google 패키지 다운로드 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 이 보관 파

developers.google.com

 

위 Play Asset Delivery 링크에서 1.7.0버전 UnityPackage를 다운로드해서 Import하고,

정상 빌드 되는 것을 확인했다.

 

[결론]

Unity 2021 이하 Play Asset Delivery 1.7.0을 사용하고,

Unity 2022 이상은 Play Asset Delivery 1.8.2(2023-05-12 기준 최신)을 사용하자.

(Unity 2021에서도 gradle 4.2.0을 적용하면 Play Asset Delivery 1.8.2 이상을 사용할 수 있다.

  2024-03-27 기준 1.9.0이 나와있으니 1.9.0을 사용하자.)

 

 

--------------------------------------------------------------------------------------------------------------------------------------------

 

[링크] https://devgod.tistory.com/49

 

[Unity] Unity Play Asset Delivery 앱 빌드, Unity 대용량 앱 빌드

2021년 8월부터 Google Play Store에선 obb를 이용한 대용량 앱 업로드가 사라지고, 무조건 Play Asset Delivery(PAD)를 통해 앱을 업로드 해야합니다. 제발 정책좀 그만 변경했으면 좋겠습니다. 먼저 제가 궁

devgod.tistory.com

반응형
Posted by blueasa
, |

Android 13에서 Runtime에 android.permission.POST_NOTIFICATIONS Permission 요청하기.

----

 

1. Android Target API 33으로 셋팅

 

2. AndroidManifest.xml에 POST_NOTIFICATIONS Permission 추가

<manifest ...>
    <application ...>
        ...
    </application>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
</manifest>

 

3. 권한 요청 원하는 시점에 아래 함수 호출(함수 호출하면 Android 13이상 폰에서는 알림 권한 허용 요청 팝업이 뜸)

void CheckPermission_PostNotifications_Android13()
{
    // 디바이스의 안드로이드 api level 얻기
    // ex) Prints "Android OS API-33" on Android 13.0
    // https://docs.unity3d.com/ScriptReference/SystemInfo-operatingSystem.html
    string androidInfo = SystemInfo.operatingSystem;
    Debug.Log("androidInfo: " + androidInfo);
    
    int apiLevel = int.Parse(androidInfo.Substring(androidInfo.IndexOf("-") + 1, 3), System.Globalization.CultureInfo.InvariantCulture);
    Debug.Log("apiLevel: " + apiLevel);

    // 디바이스의 api level이 33 이상이라면 퍼미션 요청
    if (33 <= apiLevel 
        && !UnityEngine.Android.Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS"))
    {
        UnityEngine.Android.Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS");
    }
}

 

 

-----------------------------------------------------------------------------------------

[참고]

안드로이드 알림은 api level 26 과 33 에서 변경점이 있다. 내 앱이 대상으로 삼은 Sdk Version 범위에 이 버전이 포함되어 있다면 버전에 따라 분기 처리를 해주는 편이 좋다.
API level 26 (Android 8.0 Oreo) 이상 변경점
API level 33 (Android 13 Tiramisu) 이상 변경점

public void InitializeAndroidLocalPush()
{
	// 디바이스의 안드로이드 api level 얻기
	string androidInfo = SystemInfo.operatingSystem;
	Debug.Log("androidInfo: " + androidInfo);
	apiLevel = int.Parse(androidInfo.Substring(androidInfo.IndexOf("-") + 1, 2));
	Debug.Log("apiLevel: " + apiLevel);

	// 디바이스의 api level이 33 이상이라면 퍼미션 요청
	if (apiLevel >= 33 &&
		!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS"))
	{
		Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS");
	}

	// 디바이스의 api level이 26 이상이라면 알림 채널 설정
	if (apiLevel >= 26)
	{
		var channel = new AndroidNotificationChannel()
		{
			Id = CHANNEL_ID,
			Name = "pubSdk",
			Importance = Importance.High,
			Description = "for test",
		};
		AndroidNotificationCenter.RegisterNotificationChannel(channel);
	}
}

api level 얻기 코드 출처

 

 

[참고 내용 출처]

https://velog.io/@maratangsoft/%EC%9C%A0%EB%8B%88%ED%8B%B0-%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C-%EC%95%B1%EC%97%90%EC%84%9C-FCM-%EC%84%9C%EB%B2%84-%ED%91%B8%EC%8B%9C-%EB%B0%9B%EA%B8%B0

 

유니티 안드로이드 앱에서 FCM 서버 푸시 받기

유니티 모바일 앱 개발시 안드로이드 앱은 Firebase Cloud Messaging(이하 FCM) 서비스, iOS 앱은 Apple Push Notification 서비스를 이용해서 (FCM으로도 가능) 푸시를 수신할 수 있다. 그 중 FCM을 이용한 안드로

velog.io

 

[참고]

https://android-developer.tistory.com/entry/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C13%EC%97%90%EC%84%9C-Notification-%ED%97%88%EA%B0%80-%EB%B0%9B%EA%B8%B0-%EB%B0%A9%EB%B2%95-%EB%B0%8F-%EB%B3%80%EA%B2%BD%EC%A0%90

 

안드로이드13에서 Notification 허가 받기 방법 및 변경점

안드로이드13에서 Notification에 대해 바뀐점 POST_NOTIFICATIONS (Notification Permission) 은 Target SDK API 33 이상부터 추가 가능 Target SDK API 32 이하의 앱이 Android 13 디바이스에 설치되면 Notification Channel을 등록

android-developer.tistory.com

반응형
Posted by blueasa
, |

어쩌다보니 유니티 어필리에이트 참여하게 돼서 가입하고 보니 레퍼럴 링크 개념인 것 같다.

아래 링크들로 구매 or 구독하면 나에게 일정의 수수료를 주는 듯..

 

손해볼 건 없으니 참여했는데.. 내가 내 레퍼럴 링크로 사도 되나..?? 라는 궁금증이 생김.

 

 

Promote Unity Subscription Products:
To promote Unity subscription products, use these links:

Unity Plus:
https://prf.hn/click/camref:1011lvKwd/destination:https://store.unity.com/products/unity-plus

 

Easy 2D, 3D, VR, & AR software for cross-platform development of games and mobile apps. - Unity Store

Have a 2D, 3D, VR, or AR project that needs cross-platform functionality? We can help. Take a look at the easy-to-use Unity Plus real-time dev platform!

store.unity.com

Unity Pro:
https://prf.hn/click/camref:1011lvKwd/destination:https://store.unity.com/products/unity-pro

 

Unity Pro

The complete solutions for professionals to create and operate.

unity.com

Unity Learn Premium:
https://prf.hn/click/camref:1011lvKwd/destination:https://unity.com/learn-premium

 

Unity Learn

Advance your Unity skills with live sessions and over 750 hours of on-demand learning content designed for creators at every skill level.

unity.com

Unity Partner Courses:
https://prf.hn/click/camref:1011lvKwd/destination:https://unity.com/learn/partner-courses

 

Learn

Online and in-person Unity courses and training in 2D, 3D, AR, and VR development.

unity.com

 

 

반응형
Posted by blueasa
, |