using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class SystemPageExit : MonoBehaviour { private Collider2D exitCollider; public SystemPage neighborPage; public SystemPage hostPage; private SystemPageCamera systemPageCamera; private void Start() { hostPage.systemPageExits.Append(this); exitCollider = GetComponent(); } private void OnTriggerEnter2D(Collider2D collision) { collision.gameObject.TryGetComponent(out systemPageCamera); if (systemPageCamera != null && systemPageCamera.currPage == hostPage) { Debug.Log(string.Format("Camera moving from {0} to {2}, the exit is {3}, hostPage: {1}, neighborPage:{2}.", systemPageCamera.currPage, hostPage, neighborPage, name)); systemPageCamera.targetPos = neighborPage.cameraTarget.position + new Vector3(0, 0, -10); systemPageCamera.currPage = neighborPage; systemPageCamera.isChangingPage = true; } } }