Example #1
0
    private void Update()
    {
        try
        {
            if (!_eventObject.IsEnabled())
            {
                _position = Vector3.zero;
                return;
            }

            if (_actorControler == null)
            {
                _actorControler = gameObject.GetComponent <FieldMapActorController>();
                if (_actorControler == null)
                {
                    return;
                }

                if (!_actorControler.IsActive())
                {
                    return;
                }
            }

            Camera    mainCamera      = _actorControler.fieldMap.GetMainCamera();
            BGCAM_DEF currentBgCamera = _actorControler.fieldMap.GetCurrentBgCamera();

            Vector3 position = PSX.CalculateGTE_RTPT(
                this.gameObject.transform.position,
                Matrix4x4.identity,
                currentBgCamera.GetMatrixRT(),
                currentBgCamera.GetViewDistance(),
                _actorControler.fieldMap.GetProjectionOffset());

            position   = mainCamera.WorldToScreenPoint(position);
            position.y = Screen.height - position.y;

            _position = position;
        }
        catch (Exception ex)
        {
            Log.Error(ex, "Failed to update {0}", this);
            _position = Vector3.zero;
        }
    }