コード例 #1
0
    void LateUpdate()
    {
        if (s_pMinimap)
        {
            if (!m_pTarget || (m_bTargetIsLivingBeing && m_pTarget.GetComponentInChildren <LivingBeing>().IsDead))
            {
                Destroy(gameObject);
            }

            else
            {
                Vector2 tNewLocalPos = s_pMinimap.GetBlipLocalPosition(m_pTarget.position);

                bool bOutOfBorders = false;

                if (m_eForwardUpdateFrequency != ForwardUpdate.Once)
                {
                    Vector2 tScaledSize = m_tRectTransform.rect.size;
                    tScaledSize.Scale(m_tRectTransform.localScale);
                    Vector2 tClampedPos = s_pMinimap.KeepBlipInBounds(tNewLocalPos, tScaledSize);

                    if (tClampedPos != tNewLocalPos)
                    {
                        m_tRawImage.texture = m_tOutOfBordersBlip;

                        Vector2 tTargetDirection = (tNewLocalPos - tClampedPos).normalized;
                        m_tRectTransform.up = tTargetDirection;

                        bOutOfBorders = true;
                    }

                    else if (m_eForwardUpdateFrequency == ForwardUpdate.Always)
                    {
                        UpdateForward();
                    }

                    else
                    {
                        m_tRawImage.texture = m_tDefaultBlip;
                    }

                    tNewLocalPos = tClampedPos;
                }

                if (!m_bLockScreenRotation && !bOutOfBorders)
                {
                    m_tRectTransform.localEulerAngles = s_pMinimap.TransformRotation(m_pTarget.eulerAngles);
                }

                m_tRectTransform.localPosition = tNewLocalPos;
            }
        }
    }