Unity/Editor Inspector

클래스 안에 적용되는 Attribute

소나무꼴 2019. 5. 28. 00:13
public class Attribute_ : MonoBehaviour
{
    [RuntimeInitializeOnLoadMethod]
    static void OnRuntimeMethodLoad()
    {
        Debug.Log("After Scene is loaded and game is running");
    }

    [RuntimeInitializeOnLoadMethod]
    static void OnSecondRuntimeMethodLoad()
    {
        Debug.Log("SecondMethod After Scene is loaded and game is running.");
    }
    
    // Header 생성
    [Header("Health Settings")]
    public int health = 0;

    [Space(10)] // 10 pixels of spacing here.

    public int maxHealth = 100;

    // 숨김
    [HideInInspector]
    public int p = 5;

    [SerializeField]
    private int a = 1;

    [TextArea]
    public string MyTextArea;

    [Tooltip("Health value between 0 and 100.")]
    public int health_ = 0;

    public Color _color;

    [ContextMenuItem("Reset", "ResetBiography")]
    [Multiline(8)]
    string playerBiography = "";
    void ResetBiography()
    {
        playerBiography = "";
    }
    
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    static void OnBeforeSceneLoad() {
        Debug.LogWarning("OnBeforeSceneLoad ======> " + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + ".unity");
    }

    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
    static void OnAfterSceneLoad() {
        Debug.LogWarning("OnAfterSceneLoad ======> " + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + ".unity");
    }
    
    
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
    static void OnBeforeSplashScreen() {
        Debug.LogWarning("OnBeforeSplashScreen");
    }

    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
    static void OnAfterAssembliesLoaded() {
        Debug.LogWarning("OnAfterAssembliesLoaded");
    }
}