기억 저장소 😎

  • 홈
  • 태그
  • 백준

c# 2

[Unity] RequireComponent

Unity를 사용해 게임을 만들다보면 어떤 오브젝트 내에 스크립트를 삽입하고 이 스크립트 내에서 꼭 필요한 Component가 있을 것이다. 이 때, RequireComponent라는 스크립팅 API를 쓰면 편리하다. 이 API는 해당 Component가 오브젝트 내에 존재하지 않다면 에러를 발생시켜준다. 작성 방법은 아래와 같다. [RequireComponent(typeof(Collider))] public class SomeScript : MonoBehaviour { }

Unity 2021.04.10

[Unity] 특정 Object의 자식 Object들 제거법

void DestoryChild(GameObject parentObject) { Transform[] childList = parentObject.GetComponentsInChildren(true); if (childList != null) { for (int i = 1; i < childList.Length; i++) { if (childList[i] != transform) Destroy(childList[i].gameObject); } } } 위 함수처럼 작성을 하면 parentObject의 자식 오브젝트들을 모두 제거해준다. 여기서 for 문 내의 i값을 0이 아닌 1부터 시작하는 이유는 childList[0]에는 parentObject가 담겨있기 때문이다.

Unity 2021.03.30
1
더보기
프로필사진

  • 프로그래밍 공부 (90)
    • 같은 삽질은 없다! (5)
    • Python (3)
    • 백준 (38)
    • 흥미진진한 자료구조 (0)
    • 재밌는 알고리즘 (2)
    • Unity (19)
    • 끄적끄적 (7)
    • 헷갈리는 개념 (2)
    • 운영체제 (1)
    • CodeGround (2)
    • 인공지능 (10)
    • 컴퓨터 그래픽스 (0)

Tag

2d canvas, Scripting API, Visual Studio 주석, 유니티 프로파일링, Unity HP, Unity, Unity 3d object 2d canvas, Make sure USB debugging, 유니티 최적화, Rider 여러 줄 주석이 안될 때, Unity 최적화, unity hp bar, Unity Rider 주석 단축키 안될 때, 유니티 프로파일러, Unity Profiler, c#, RequireComponent, Unity nickname, Visual Studio 주석 단축키, Unity Profiling,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2025/12   »
일 월 화 수 목 금 토
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바