[내일 배움 캠프 Unity 4기] W7D1 05.27 TIL

김용준·2024년 5월 28일
0

내일배움캠프

목록 보기
23/47

Goals

  • Learn the design pattern; strategy
  • Follow the lecture; Unity medium 5 ~ 10 section

Q & A

Q. There are two method to access gameobject; drag and drop in inspector window, called from the script (GetComponent or FindObject). What is the difference and Which situation one of those would be preferred?

A.

pros of drag & drop:

  • easily can be seen.
  • simple to check null via validation tool
  • these tasks can be done in graphic team

cons of drag & drop:

  • be carefull when treating *.meta files

pros of invoking from code:

  • easy to manage via dynamic allocating
  • advantage comes from the team project (sharing with git)

cons of invoking from code:

  • should be awake on the Unity life cycle.(null error occurs with the order of invokes)

Indeed, the difference of performance is pretty small. The adoption is on the user.

Q. What is the difference of using Action and event Action in Unity?

A. Similar with the difference of field and property, the event would be act as the instead of getter & setter. For instance, the variable can be written like below

float testVariable1; // field
float testVariable2  // property
	{
     get;
     set;
    }

Action testAction1; // Action
event Action testAction2 // event Action
	{
     add{}
     remove{}
	}
profile
꿈이큰개발자지망생

0개의 댓글