Exemple #1
0
 virtual public void OnHover(UIHoverEvent e)
 {
     if (CheckStartTime(e))
     {
         UpdateState();
     }
 }
Exemple #2
0
    public override void OnHover(UIHoverEvent e)
    {
        if ((LogicManager.VRMode & mode) > 0)
        {
            base.OnHover(e);
            if (e.hoverPhase == UIHoverEvent.HoverPhase.Begin)
            {
                if (onEnterHover != null)
                {
                    onEnterHover.Invoke();
                }
            }
            else if (e.hoverPhase == UIHoverEvent.HoverPhase.Middle)
            {
                if (ifUseUpdateEvent)
                {
                    //TODO add c# event here
                }
                else
                {
                    if (onUpdateHover != null)
                    {
                        float process = FocusTime / GetTotalConfirmTime();
                        onUpdateHover.Invoke(process);
                    }

                    if (onUpdateHoverV3 != null)
                    {
                        onUpdateHoverV3.Invoke(e.point);
                    }
                }
            }
            else if (e.hoverPhase == UIHoverEvent.HoverPhase.End)
            {
//				Debug.Log("OnHover End " + name + " " + transform.parent.name );
                if (onExitHover != null)
                {
                    onExitHover.Invoke();
                }
                if (onUpdateHoverV3 != null)
                {
                    onUpdateHoverV3.Invoke(Global.ONHOVERV3_PHASE_EXIT);
                }
            }
        }
    }
Exemple #3
0
    /// <summary>
    /// Checks the start time.
    /// </summary>
    /// <returns><c>true</c>, if in the middle of the hover, <c>false</c> otherwise.</returns>
    /// <param name="e">E.</param>
    protected bool CheckStartTime(UIHoverEvent e)
    {
        m_hoverTime = e.duration;
        if (e.hoverPhase == UIHoverEvent.HoverPhase.Middle)
        {
            return(true);
        }

        if (e.hoverPhase == UIHoverEvent.HoverPhase.Begin)
        {
            StartHover();
        }
        else if (e.hoverPhase == UIHoverEvent.HoverPhase.End)
        {
            EndHover();
        }

        return(false);
    }
Exemple #4
0
    public void ProcessUI()
    {
        // deal with the hover
        UIHoverEvent hoverEvent = new UIHoverEvent();

        hoverEvent.point = GetIntersectionPosition();
        UISensor hoverSensor = null;

        GameObject currentObj = GetCurrentGameObject();

        if (currentObj != null)
        {
            hoverSensor = currentObj.GetComponent <UISensor>();
        }

        if (hoverSensor == null)
        {
            if (lastSensor != null)
            {
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.End;
                hoverEvent.duration   = hoverDuration;
                lastSensor.OnHover(hoverEvent);
                hoverDuration = 0;
                lastSensor    = null;
            }
            if (lastSubSensor != null)
            {
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.End;
                hoverEvent.duration   = subHoverDuration;
                lastSubSensor.OnHover(hoverEvent);
                subHoverDuration = 0;
                lastSubSensor    = null;
            }
        }
        else if (hoverSensor.GetSensorType() == SensorType.Normal)
        {
//			Debug.Log("Hover " + hoverSensor.transform.parent.name );

            if (lastSensor != hoverSensor)
            {
                if (lastSensor != null)
                {
                    hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.End;
                    hoverEvent.duration   = hoverDuration;
                    lastSensor.OnHover(hoverEvent);
                }

                hoverDuration         = 0;
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.Begin;
                hoverEvent.duration   = hoverDuration;
                hoverSensor.OnHover(hoverEvent);
                lastSensor = hoverSensor;
            }
            else
            {
                hoverDuration += Time.deltaTime;

                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.Middle;
                hoverEvent.duration   = hoverDuration;
                hoverSensor.OnHover(hoverEvent);
            }

            // sub exit
            if (lastSubSensor != null)
            {
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.End;
                hoverEvent.duration   = subHoverDuration;
                lastSubSensor.OnHover(hoverEvent);
                subHoverDuration = 0;
                lastSubSensor    = null;
            }
        }
        else if (hoverSensor.GetSensorType() == SensorType.Sub)
        {
            if (lastSensor != null)
            {
                hoverDuration        += Time.deltaTime;
                hoverEvent.duration   = hoverDuration;
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.Middle;
                lastSensor.OnHover(hoverEvent);
            }

            if (lastSubSensor != hoverSensor)
            {
                if (lastSubSensor != null)
                {
                    hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.End;
                    hoverEvent.duration   = subHoverDuration;
                    lastSensor.OnHover(hoverEvent);
                }

                subHoverDuration      = 0;
                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.Begin;
                hoverEvent.duration   = subHoverDuration;
                hoverSensor.OnHover(hoverEvent);
                lastSubSensor = hoverSensor;
            }
            else
            {
                subHoverDuration += Time.deltaTime;

                hoverEvent.hoverPhase = UIHoverEvent.HoverPhase.Middle;
                hoverEvent.duration   = subHoverDuration;
                hoverSensor.OnHover(hoverEvent);
            }
        }
    }