Exemplo n.º 1
0
    void RayCastBannerMouse()
    {
        Vector3 origin    = camTrans.position;
        Vector3 direction = camTrans.forward;



        RaycastHit hit;

        switch (state)
        {
        case 1:
            //enter
            if (_meshRenderer.material.GetColor(_colorID) != _lerpColor)
            {
                _meshRenderer.material.SetColor(_colorID, Color.Lerp(_meshRenderer.material.GetColor(_colorID), _lerpColor, _fadeSpeed));
            }
            if (!Physics.Raycast(origin, direction, out hit, maxDist, layerMask))
            {
                state = -1;
                bannerManager.setInBanner(false);
            }
            break;

        case -1:
            //exit
            if (_meshRenderer.material.GetColor(_colorID) != _originalColor)
            {
                _meshRenderer.material.SetColor(_colorID, Color.Lerp(_meshRenderer.material.GetColor(_colorID), _originalColor, _fadeSpeed));
            }
            if (Physics.Raycast(origin, direction, out hit, maxDist, layerMask))
            {
                _meshRenderer = hit.transform.gameObject.GetComponent <SkinnedMeshRenderer>();
                state         = 1;
                bannerManager.setCurrentBanner(hit.transform.tag);
                bannerManager.setInBanner(true);
            }
            break;

        default:
            if (Physics.Raycast(origin, direction, out hit, maxDist, layerMask))
            {
                _meshRenderer = hit.transform.gameObject.GetComponent <SkinnedMeshRenderer>();
                bannerManager.setCurrentBanner(hit.transform.tag);
                bannerManager.setInBanner(true);
                state = 1;
            }
            break;
        }
    }