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

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-29 07:22

1. MonoBehaviour, ScriptableObject 로 부터 ( 직접 혹은 간접으로 ) 상속 받아야 한다.

     ps. GameObject 에 Attach 하려면 MonoBehavior로 부터 상속받고,

           일반 로직등에 필요한 클래스는 ScriptableObject로 부터 상속 받는다. 

 

2. 클래스 이름과 파일 이름이 일치해야 한다.

 

3. namespace를 사용할 수 없다.

 

4. MonoBehaviour 일 경우, 멤버 변수만 Inspector 에 나타난다.

 

5. MonoBehaviour 일 경우, 생성자를 사용하지 말고,  Awake( 이게 생성자 ), Start 함수를 사용한다.

 

6. ScriptableObject일 경우, MonoBehaviour 상속받은 스크립트에서 인스턴스 생성시 new를 사용하지 말고,ScriptableObject.CreateInstance("클래스명") as 클래스형을 사용한다.

 

7. ScriptableObject일 경우,  인스턴스 생성후에 새로운 객체를 재할당 할 때는, GameObject.DestroyImmediate(인스턴스) 호출하여 메모리를 꼭 해지하고 재할당.

 

8. Corutine은 다른 문법으로 사용된다.

반환형은 IEnumerator를 사용해야 하며, yield ... 를 사용할 때, yield return ... 을 사용한다.

 

using System.Collections;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
    // C# coroutine
    IEnumerator SomeCoroutine () {
    // Wait for one frame
    yield return 0;
   
    // Wait for two seconds
    yield return new WaitForSeconds (2);
}

}



[출처] C# 사용할때 주의할 점|작성자 내영

반응형
Posted by blueasa
, |