Unity/Unity 리서치 103

Unity에 AdMob 구현

📗참고: https://learnandcreate.tistory.com/2365 패키지 설치 Admob Package 다운로드: https://github.com/googleads/googleads-mobile-unity/releases (v8.6.0 받음) 테스트 할거면 Android에 테스트 아이디 넣음 ca-app-pub-3940256099942544~3347511713 📃Document: https://developers.google.com/admob/unity/rewarded?hl=ko Admob에서 앱 추가 📌Admob: https://apps.admob.com/v2/home 광고단위 추가 구글 샘플프로젝트 📑Init하는 부분 https://github.com/googleads/googlead..

스크롤뷰 두개 동시에 움직이기

Horizontail과 Vertical을 각각 만들거나, ScrollView끼리 Hierachy관계인 경우 입력에 따라 단 하나의 스크롤뷰만 움직인다. (직접 해보면 덜걱거려서 부자연스러운 UX가 됨) 기본적으로 한놈만 작동하고 다른건 다 쌩까도록 구현되어있음. 동시에 움직이고 싶을 경우 무시받고 있는 ScrollView에게 직접 Event를 전달해주면 된다. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class DragDispatcher : MonoBehaviour, IBeginDragHandler..

중첩된 LayoutView가 제대로 작동하지 않을 때

LabelGroup과 하위의 BranchLabel, TagLabel에 모두 HorizontailLayoutView가 있음 하위의 LayoutView가 업데이트 내역이 상위 LayoutView에 제때에 적용이 안되서 문제인듯? Solution (야매) 상위 Layout Group의 Control Child Size 체크하니까 된다 Solution (덜 야매) 👹원인 😀해결 ContentSizeFilter는 자손 컨텐츠의 크기에 따라 자동으로 LayoutView의 크기를 맞춰주는 역할을 하는 컴포넌트. ContentSizeFilter를 임의로 Refresh시킴. [SerializeField] private ContentSizeFitter sizeFitter; private void RefreshContent..

인스펙터(Inspector)에 테스트 버튼 만들기

InventoryManager 컴포넌트에 버튼을 달고 싶은 경우, using UnityEngine; using UnityEditor; [CustomEditor(typeof(InventoryManager))] public class Test : Editor { public override void OnInspectorGUI() { base.OnInspectorGUI(); var inventoryManager = target as InventoryManager; if (GUILayout.Button("Test1")) { if (inventoryManager) { inventoryManager.Test1(); } } if (GUILayout.Button("Test2")) { if (inventoryManage..

내가 부모의 몇 번째 Active된 자식인지 반환하는 함수

private int GetViewIndex() { var cnt = -1; for (var i = 0; i < transform.parent.childCount; i++) { var view = transform.parent.GetChild(i); if (view.gameObject.activeSelf) { cnt++; if (view.transform == transform) return cnt; } } return cnt; } 다른방법 https://qits.tistory.com/entry/GetComponentsInChildren-%EC%9E%90%EC%8B%9D%EC%98%A4%EB%B8%8C%EC%A0%9D%ED%8A%B8%EC%97%90%EC%84%9C-%ED%99%9C%EC%84%B1%EB..

URP 쉐이더 종류

📕 개념 https://velog.io/@astray36/%EC%98%A4-%EA%B0%9C-URP%EC%9D%98-%EA%B0%9C%EB%85%90 오-개) URP의 개념 Universal RP는 결국 쓰게 되겠지만 아직 호환성이라던가 조금 다루기 난해한 부분이 있다. 그래서 기피한 것도 있고. 일단은 한번 알아보자LWRP(Light Weight Render Pipline)로 시작해서 URP(Universal Render Pipl velog.io https://mrbinggrae.tistory.com/243 Universal Render Pipeline 대충이라도 알고 쓰자 * 내가 그래픽 작업자도 아니고 배운다고 써 먹을 수도 없을 거 같아서 딱 필요한 부분만 공부한 내용을 정리해놨다. (특히 까막눈..

DontDestroyOnLoad의 적용범위

StageController는 DontDestroyOnLoad인 싱글톤 클래스 빠르게 진행하여 과정에 대한 기록은 다소 미흡하니 결과만 체크할 것 1. Dependency가 있는 GameObject(Component) Dependency가 있어도 다음 씬에선 나가리 2. 동일한 GameObject DontDestroyOnLoad인 컴포넌트와 같은 GameObject면 같이 다음 씬으로 데리고 간다. Denpendency가 있던 없던 상관없다 3. 자식 GameObject 자식 GameObject도 모두 함께 간다 4. 내부에서 생성된 클래스 using System; using System.Collections; using System.Collections.Generic; using MoreMountain..

gameObject에 SendMessage 보내기

Java의 Reflection과 유사. String으로 매소드 이름과 매개변수를 보냄. MMPreventPassingThrough3D.cs (Sample) /// /// On fixedUpdate, checks the last movement and if needed casts a ray to detect obstacles /// protected virtual void FixedUpdate() { _lastMovement = this.transform.position - _positionLastFrame; _lastMovementSquared = _lastMovement.sqrMagnitude; // if we've moved further than our bounds, we may have misse..

[RTS Engine] Object Pooling 이 제대로 안될 때

Effect의 Pooling을 담당하는 부분 EffectObjPool.cs private Dictionary effectObjs = new Dictionary(); //this holds all inactive effect objects of different types. // ... public void AddFreeEffectObj (EffectObj instance) { Queue currentQueue = new Queue(); if (effectObjs.TryGetValue(instance.GetCode(), out currentQueue) == false) //if the queue for this effect object type is not found { effectObjs.Add(inst..

Unity 웹뷰(WebView) - 흰 화면만 뜨는 경우

https://github.com/gree/unity-webview GitHub - gree/unity-webview Contribute to gree/unity-webview development by creating an account on GitHub. github.com 다운로드 받은 다음 Package를 Import한다. (nofragment는 뭔지 모르겠음) private WebViewObject webViewObject; public void OnClick_Webview() { StartWebView(); } public void StartWebView() { string strUrl = "https://www.naver.com/"; try { webViewObject = (new GameO..

[Addressable] Build Mode Script

Fast Mode - 번들로 만들어지지 않은 상태로 바로바로 플레이가 가능한 모드이다. 작업 중인 컴퓨터의 에셋 데이터베이스에서 바로바로 정보를 가져오기 때문에, 실제로 어드레서블에셋들이 그룹화되어있지 않다. ​ Virtual Mode - 플레이를 누르면 사전 빌드 단계를 거쳐서 그룹화된 번들 파일들을 생성한 후 플레이 된다. 따라서 실제 그룹화가 되어있고, 그 정보에서 데이터를 불러온다. 그래서 프로파일링 할 때 유용하다. 하지만 데이터가 계속해서 활성화되어 있기 때문에 실제 빌드 시 작동은 하지만 메모리에 이점이 전혀 없다. ​ Packed Play Mode - 실제 빌드를 통해 그룹화된 파일을 생성해야만 이 모드로 플레이(재생)가 된다. https://m.blog.naver.com/PostView...