우선 방법 하나로 MonoBehaviour 클래스를 상속받은 스크립트에서 다른 스크립트를 호출하는거다.
EX) 플레이어 스크립트
public class Player : MonoBehaviour
{
public void Move()
{
Debug.Log("Player is moving.");
}
}
다음 게임 매니저 스크립트
public class GameManager : MonoBehaviour
{
★☆★☆ public Player player; ★☆★☆
void Start()
{
if (player != null)
{
player.Move(); // Player 스크립트의 Move 메서드 호출
}
}
}
GameManager 스크립트는 Player 스크립트를 호출하여 Move()메서드를 실행