UI_Button 클론이 무한생성됩니다. public class Test : MonoBehaviour { GameObject er; void Update() { if (Input.GetMouseButtonDown(0)) { Managers.UI.ShowPopupUI<UI_Button>(); } } } 아래 코드로 문제가 있어서 화면을 클릭했을 때만 팝업이 뜨도록 위의 코드로 Test 스크립트를 일부 바꿔 봤습니다. 그러고나서 보니까 public static UIManager UI{get{return instance._ui;}} 이 지점에서 계속 다시 Test 파일의 if (Input.GetMouseButtonDown(0)) { Managers.UI.ShowPopupUI<UI_Button>(); } 이 부분으로 가는 것 같습니다. 늘어나는 갯수로 처음엔 한번 클릭했을 때는 한번으로 잘 늘어나는데 그 다음엔 2개가 생기고 그 다음엔 5개..? 규칙을 알 수 없게 늘어납니다 저 요즘 질문 너무 많이하죠..ㅜㅜ 그치만 미워하지 말아주세요 다 기본 3시간은 고민고민하며 노려보다가 보내는거긴해유..하핳.. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Test : MonoBehaviour { GameObject er ; void Start() { Managers.UI.ShowPopupUI<UI_Button>(); } void Update() { } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class ResourceManager { public T Load<T>(string path) where T:Object { return Resources.Load<T>(path); } public GameObject Instantiate(string path, Transform parent = null) { GameObject prefab = Load<GameObject>($"Prefabs/{path}"); if (prefab == null) { Debug.Log($"Failed to load prefab : {path}"); return null; } return Object.Instantiate(prefab, parent);//Object붙이는 이유는 리소스메니저에 있는 Instantiate를 또 호출하려고 할까봐. } public void Destroy(GameObject go) { if(go == null) return; Object.Destroy(go); } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class Managers : MonoBehaviour { static Managers s_Instance; //유일성이 보장된다 static Managers instance { get { Init(); return s_Instance; } } // 유일한 매니저를 갖고온다 ResourceManager _resource = new ResourceManager(); UIManager _ui = new UIManager(); public static UIManager UI{get{return instance._ui;}} public static ResourceManager Resource{get{return instance._resource;}} // Start is called before the first frame update void Start() { Init(); } // Update is called once per frame void Update() { } static void Init() { if (s_Instance == null) { GameObject go = GameObject.Find("@Managers"); if (go == null) { go = new GameObject { name = "@Managers" }; go.AddComponent<Managers>(); } DontDestroyOnLoad(go); s_Instance = go.GetComponent<Managers>(); } } }using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIManager { int _order = 0; //팝업 목록을 들고있어야함. 스택 구조으로 관리하기 가장 마지막에 띄운 팝업이 가장 먼저 삭제돼야하니까. Stack<UI_Popup> _popupStack = new Stack<UI_Popup>(); public T ShowPopupUI<T>(string name = null) where T : UI_Popup//T에는 UI버튼이라는 스크립트를 건네고 name에는 팝업프리펩을 건네줄거임. { if(string.IsNullOrEmpty(name))//이름이 비어있으면 T타입의 이름과 똑같은걸로 넣겠다. name = typeof(T).Name; GameObject go = Managers.Resource.Instantiate($"UI/Popup/{name}"); T popup = Util.GetOrAddComponent<T>(go); _popupStack.Push(popup); return popup; } public void ClosePopupUI() { if (_popupStack.Count == 0) //stack을 건드릴 떈 항상 카운트를 체크하는걸 습관화하기 return; UI_Popup popup = _popupStack.Pop(); Managers.Resource.Destroy(popup.gameObject); popup = null; _order--; } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class Util { public static T GetOrAddComponent<T>(GameObject go) where T : UnityEngine.Component { T component = go.GetComponent<T>(); if (component == null) component = go.AddComponent<T>(); return component; } public static GameObject FindChild(GameObject go, string name = null, bool recursive = false) { Transform transform = FindChild<Transform>(go, name, recursive);//<Transform>을 사용하면 FindChild 메서드가 호출될 때 해당 메서드는 Transform 타입의 자식을 찾도록 약속됩니다. 이는 제네릭을 사용하여 메서드를 특정 타입에 제한하는 방법 중 하나입니다. if (transform == null) return null; return transform.gameObject; } public static T FindChild<T>(GameObject go, string name = null, bool recursive = false) where T : UnityEngine.Object { if (go == null) return null; if (recursive == false) { for (int i = 0; i < go.transform.childCount; i++) { Transform childTransform = go.transform.GetChild(i); if (string.IsNullOrEmpty(name) || childTransform.name == name) { T component = childTransform.GetComponent<T>(); if (component != null) return component; } } } else { foreach (T component in go.GetComponentsInChildren<T>(true)) { if (string.IsNullOrEmpty(name) || component.name == name) return component; } } return null; } }
ResourceManager 스크립트 코드 중 일부입니다. public GameObject Instantiate(string path, Transform parent = null) { GameObject prefab = Load<GameObject>($"Prefabs/{path}"); if (prefab = null) { Debug.Log($"Failed to load prefab : {path}"); return null; } return Object.Instantiate(prefab, parent); } 여기서 prefab에 로드로 경로 잘 찾아서 오브젝트가 잘 들어가는데요 return Object.Instantiate(prefab, parent); 이 부분에서 아래의 오류가 뜹니다 ㅠㅠ 어딜 다시 봐야할까요?? System.ArgumentException: The Object you want to instantiate is null. at UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) [0x00009] in <30adf90198bc4c4b83910c6fb1877998>:0
EventHandler를 자동으로 만드는 과정에서 여러 스크립트가 관여하다보니 헷갈립니다. 드래그하려는 이미지들을 포함한 캔버스에 스크립트 파일을 넣어야하는거 맞나요? 스크립트 파일은 MonoBehavior을 상속받는 애들이라면 다 넣어야하는건지..? 넣는 기준이 헷갈려요. 그리고 뭔가 잘못했는지 한 이미지는 드래그 하면 움직이고 다른 이미지는 안움직였는데, 뭐가 다른지 확인해보려고 움직이는 이미지를 복붙해서 확인해보니 갑자기 다 안 움직입니다..ㅇㅁㅇ ㅎㅎ..... 너무 모르겠어서 이메일 보내보겠습니다 ㅠㅠ 감사합니다
[테스트1] 아래 처럼 클라이언트에서 Send를 5번 하는데 for (int i = 0; i < 5; i++) { byte[] sendBuffer = Encoding.UTF8.GetBytes($"Hello World! {i} "); int sendByte = socket.Send(sendBuffer); } 강의 결과 화면처럼 서버에서는 5번의 Send 패킷을 모았다가 출력 하는 모습을 볼 수 있습니다. [테스트2] 아래에서도 마찬가지로 Send를 5 번 하는데, 1초 딜레이 를 주고 실행했습니다. for (int i = 0; i < 5; i++) { byte[] sendBuffer = Encoding.UTF8.GetBytes($"{i} "); int sendByte = socket.Send(sendBuffer); Thread.Sleep(1000); } 이때는 서버에서 패킷을 모을 시간이 없었던건지, Send 패킷을 안모으고 출력 하는 모습을 볼 수 있습니다. [질문] 서버에서 패킷을 모으는 역할을 하는 것이 무엇인가요? SocketAsyncEventArgs 인가요? 그리고 패킷을 모으는 기준이 무엇인지 궁금합니다. 시간인가요? 아니면 끊임 없이 연속적으로 보내지는 패킷인가요? 아니면 다른 무엇인가요? SocketAsyncEventArgs recvArgs = new SocketAsyncEventArgs(); recvArgs.Completed += new EventHandler<SocketAsyncEventArgs>(OnRecvCompleted); recvArgs.SetBuffer(new byte[1024], 0, 1024);
error CS0234: The type or namespace name 'AddressableAssets' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) error CS0234: The type or namespace name 'ResourceManagement' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) 이 두 부분에서 에러가 뜨는데 어떻게 해결해야 하나요?
NullReferenceException: Object reference not set to an instance of an object GameManager.Update () (at Assets/_My/Scripts/GameManager.cs:50) 콘솔에 출력된 에러 내용입니다. cs:50 은 bulletText.text = currentBullet + " / " + maxBullet; 부분입니다. 오브젝트를 못찾는거같은데 어떻게 해결할 수 있을까요
안녕하세요. 질문이 있어서 글을 남기게 되었습니다. 루키스님의 지난 강의 유니티로 MMORPG만들기에서 데이터베이스를 mssql, entity framework로 만드셨는데 이번에도 같은 것으로 진행 하는것인지 궁금합니다. 인디, 또는 개인개발자를 대상으로 진행하는 교육인 만큼 리눅스 서버에서 돌아가는 mysql, 또는 mariaDB와 같은 비용이 최소화되는 환경으로 진행되었으면 하는데 여기에 대해서 답변 주실 수 있을까요? 이미 강의를 구입하였는데 저 또 한 개인개발을 목표로 하고 있어서 강의내용에 대해서 궁금합니다.!!
_listenSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _onAcceptHandler += onAcceptHandler; _listenSocket.Bind(endPoint); _listenSocket.Listen(10) 위 코드에서 new Socket() 한 뒤에 _onAcceptHandler += onAcceptHandler ; 로 핸들러를 추가 했는데, 아래 코드처럼 Listen() 뒤에 추가 해도 문제 없을까요? _listenSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _listenSocket.Bind(endPoint); _listenSocket.Listen(10); _onAcceptHandler += onAcceptHandler;
더미클라와 서버 의 Program.cs에서 byte가 arraysegment 부분으로 변환되는게 생략되었습니다. 어려운 작업은 아니지만, 뒤에 듣는사람 참고하라고 올립니다. 아닌가.. 내가 잘못한 부분이 있었네 public override void OnConnected(EndPoint endPoint) { Console.WriteLine($"OnConnected bytes : {endPoint}"); byte[] tempBuff = Encoding.UTF8.GetBytes("Welcome to MMORPG Server!"); ArraySegment<byte> sendBuff = new ArraySegment<byte>(tempBuff); Send(sendBuff); Thread.Sleep(1000); Disconnect(); } public override void OnConnected(EndPoint endPoint) { Console.WriteLine($"OnConnected bytes : {endPoint}"); //데이터를 보낸다 for (int i = 0; i < 5; i++) { byte[] tempBuff = Encoding.UTF8.GetBytes($"Hello World {i}"); ArraySegment<byte> sendBuff = new ArraySegment<byte>(tempBuff); Send(sendBuff); } }
우선 좋은 강의 감사합니다. 강의해주신 내용 토대로, 좀 더 디벨럽한뒤에 마켓에 출시하고자 합니다. 커뮤니티 게시판에 일부 에셋은 사용해도된다고 하였는데, 확인 차 문의드립니다. 캐릭터와 UI/ UX 수정은 하지만, 몬스터 디자인이 맘에 들어 그대로 사용하려고 합니다. 사용해도 되는지 여부와, 몬스터 이미지 에셋 판매 계획이 있으신지 문의드립니다!
UI 자동화 #1 강의 중 FIndChild 유틸함수를 만드는 과정에서 SC1579 오류가 발생합니다. "T에는 'GetEnumerator'의 공개 인스턴스 또는 확장 정의가 없다"라고 하면서 실행이 되지 않는데 이 부분이 이해가 되지 않아 질문글을 작성하게 되었습니다..
저는 앞으로 마블스냅 같은 게임을 1인개발로 만들어 출시해서 운영해보고 싶습니다. 그 목표를 이루는데에 있어서, 지금 이 강의가 도움이 될수있을까요? 게임 장르가 다르면 사용되는 기술이나 방법들이 많이 달라질수도 있는건가요? 이 강의를 들으면 오직 방치형, 리니지라이크 같은 종류의 게임들만을 만드는데만 도움이 되고 타 장르의 게임을 개발하는데는 별로 도움이 되지않는것인지 궁금합니다. 알려주세요.