MonoBehaviour.Reset()
Description
Reset to default values.
Reset is called when the user hits the Reset button in the Inspector's context menu or when adding the component the first time. This function is only called in editor mode. Reset is most commonly used to give good default values in the Inspector.
// Sets target to a default value. // This could be used in a follow camera.
using UnityEngine;
public class Example : MonoBehaviour { public GameObject target;
void Reset() { //Output the message to the Console Debug.Log("Reset"); if (!target) target = GameObject.FindWithTag("Player"); } }
ref : https://docs.unity3d.com/ScriptReference/MonoBehaviour.Reset.html
반응형
'게임엔진(GameEngine) > Unity3D' 카테고리의 다른 글
[InitializeOnLoad] : 에티더 UnityEditor 에디터 스크립트 생성자 호출하기 (0) | 2019.09.07 |
---|---|
에디터에서 해당 오브젝트에 대한 prefab path 얻어오기 : Get a prefabs file location in Unity (0) | 2019.09.07 |
Coroutine 과 Thread 차이 (0) | 2019.06.20 |
Why does Mathf.Sign(0.0f) return 1? (0) | 2019.06.11 |
Can Transition To Self (0) | 2019.05.24 |