유니티 버전은 22.3.33f1사용하고 있고요,

맵과 맵을 텔레포터로 잇고, 텔레포트가 작동할 때마다 새로 로드된 씬의 텔레포터를 찾고, 이전 맵으로 가는건지 다음 맵으로 가는건지 판단하는 bool함수를 판별해

판별이 성공하면 해당 위치로 이동시켜주는 코드를 작성했습니다.


처음엔 private void OnLevelWasLoaded(int level)를 이용해보려 했는데, 나중버전에서는 없어지는 함수라고 해서 다른 방법 찾아보고 있습니다.

다른 함수 검색해보니까 onSceneLoaded가 있다고 해서 코드를 써봤는데 비주얼스튜디오에서 자동완성이 안뜨는걸로 봐선 뭔가 적용이 안되는것 같더라고요.

혹시 다른 방법 있을까요? 기존 코드와 onSceneLoaded 사용 봤던 링크 첨부하겠습니다.


private void OnLevelWasLoaded(int level) //이전 코드

{

    GameObject[] teleporters = GameObject.FindGameObjectsWithTag(Define.TPtag);

    foreach (GameObject teleporter in teleporters)

    {

    bool LR = MapTeleporter1.GiveIsLR(); //텔레포터내의 isLR값 반환해주는 함수.

    Debug.Log(teleporter.name + ", "+ LR);

    if(priviousMap != LR) //priviousMap은 이전 맵에서 텔레포트했던 그 텔레포터의 bool값 받아옴.

    {

    Debug.Log(teleporter.transform.position);

    this.transform.position = new Vector3 (teleporter.transform.position.x + offset, teleporter.transform.position.y, this.transform.position.z);

    break;

    }

}

}



https://discussions.unity.com/t/how-to-use-scenemanager-onsceneloaded/624895/3