Beispiel #1
0
    /// <summary>
    /// registers this component with the event handlers (if any)
    /// </summary>
    protected virtual void OnEnable()
    {
        if (!m_Initialized)
        {
            return;
        }

        // allow this control to talk to the player event handler
        if (Manager != null && Manager.Player != null)
        {
            Manager.Player.Register(this);
        }

        // register with the vp_UIManager if available or register with vp_InputMobile if not
        if (Manager != null)
        {
            Manager.RegisterControl(this);
        }
        else
        {
            vp_InputMobile.Register(this);
        }

        // button event binding callbacks
        foreach (vp_TouchButtonEventBinding d in m_ButtonEvents)
        {
            if (d.Method.Name == "OnPressControl")
            {
                PressControl += d;
            }
            else if (d.Method.Name == "OnHoldControl")
            {
                HoldControl += d;
            }
            else if (d.Method.Name == "OnDoublePressControl")
            {
                DoublePressControl += d;
            }
            else if (d.Method.Name == "OnDoubleReleaseControl")
            {
                DoubleReleaseControl += d;
            }
            else
            {
                ReleaseControl += d;
            }
        }

        // changed event binding callbacks
        foreach (vp_TouchChangedEventBinding d in m_ChangedEvents)
        {
            ChangeControl += d;
        }
    }
Beispiel #2
0
    /// <summary>
    /// unregisters this component from the event handlers (if any)
    /// </summary>
    protected virtual void OnDisable()
    {
        // unregister this monobehaviour from the player event handler
        if (Manager != null && Manager.Player != null)
        {
            Manager.Player.Unregister(this);
        }

        // unregister from the vp_UIManager if available or unregister from vp_InputMobile if not
        if (Manager != null)
        {
            Manager.UnregisterControl(this);
        }
        else
        {
            vp_InputMobile.Unregister(this);
        }

        // button event binding callbacks
        foreach (vp_TouchButtonEventBinding d in m_ButtonEvents)
        {
            if (d.Method.Name == "OnPressControl")
            {
                PressControl -= d;
            }
            else if (d.Method.Name == "OnHoldControl")
            {
                HoldControl -= d;
            }
            else if (d.Method.Name == "OnDoublePressControl")
            {
                DoublePressControl -= d;
            }
            else if (d.Method.Name == "OnDoubleReleaseControl")
            {
                DoubleReleaseControl -= d;
            }
            else
            {
                ReleaseControl -= d;
            }
        }

        // changed event binding callbacks
        foreach (vp_TouchChangedEventBinding d in m_ChangedEvents)
        {
            ChangeControl -= d;
        }
    }
Beispiel #3
0
    /// <summary>
    /// registers this component with the event handlers (if any)
    /// </summary>
    protected virtual void OnEnable()
    {
        if(!m_Initialized)
            return;

        // allow this control to talk to the player event handler
        if (Manager != null && Manager.Player != null)
            Manager.Player.Register(this);

        // register with the vp_UIManager if available or register with vp_InputMobile if not
        if(Manager != null)
            Manager.RegisterControl(this);
        else
            vp_InputMobile.Register(this);

        // button event binding callbacks
        foreach(vp_TouchButtonEventBinding d in m_ButtonEvents)
            if(d.Method.Name == "OnPressControl") PressControl += d;
            else if(d.Method.Name == "OnHoldControl") HoldControl += d;
            else if(d.Method.Name == "OnDoublePressControl") DoublePressControl += d;
            else if(d.Method.Name == "OnDoubleReleaseControl") DoubleReleaseControl += d;
            else ReleaseControl += d;

        // changed event binding callbacks
        foreach(vp_TouchChangedEventBinding d in m_ChangedEvents)
            ChangeControl += d;
    }
Beispiel #4
0
    /// <summary>
    /// unregisters this component from the event handlers (if any)
    /// </summary>
    protected virtual void OnDisable()
    {
        // unregister this monobehaviour from the player event handler
        if (Manager != null && Manager.Player != null)
            Manager.Player.Unregister(this);

        // unregister from the vp_UIManager if available or unregister from vp_InputMobile if not
        if(Manager != null)
            Manager.UnregisterControl(this);
        else
            vp_InputMobile.Unregister(this);

        // button event binding callbacks
        foreach(vp_TouchButtonEventBinding d in m_ButtonEvents)
            if(d.Method.Name == "OnPressControl") PressControl -= d;
            else if(d.Method.Name == "OnHoldControl") HoldControl -= d;
            else if(d.Method.Name == "OnDoublePressControl") DoublePressControl -= d;
            else if(d.Method.Name == "OnDoubleReleaseControl") DoubleReleaseControl -= d;
            else ReleaseControl -= d;

        // changed event binding callbacks
        foreach(vp_TouchChangedEventBinding d in m_ChangedEvents)
            ChangeControl -= d;
    }