// Start is called before the first frame update private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this); } }
public PlayerChatManager() { if (chatLog == null) { chatLog = new GameObject().AddComponent <PlayerChatLog>(); } if (chatEntry == null) { chatEntry = new GameObject().AddComponent <PlayerChatEntry>(); } }
// Start is called before the first frame update private void Awake() { if (Instance == null) { Instance = this; _scrollRect = GetComponent <ScrollRect>(); } else { Destroy(this); } }
public PlayerChat() { if (instance != null) { throw new Exception($"There must only be one {nameof(PlayerChat)} instance."); } instance = this; chatLog = new GameObject().AddComponent <PlayerChatLog>(); chatLog.Manager = this; inputField = new GameObject().AddComponent <PlayerChatInputField>(); inputField.Manager = this; }