Example #1
0
 protected virtual void OnUILeave(EventMessage em, ref object paramRef)
 {
     SetState(ButtonState.NORMAL);
 }
Example #2
0
 void OnEventNext(EventMessage em, ref object paramRef)
 {
     prevDialog.Remove();
 }
Example #3
0
        // Update is called once per frame
        void Update()
        {
            if (currCam == null)
            {
                currCam = GetComponent <Camera>();
            }
            if (currCam == null)
            {
                return;
            }

            object _ret = null;

            currObj = null;

            Vector2 screenPos = Input.mousePosition;

            // Construct a ray from the current mouse coordinates
            Ray        ray = currCam.ScreenPointToRay(screenPos);
            RaycastHit raycastInfo;


            //Debug.DrawRay(ray.origin, ray.direction * 1000);
            if (Physics.Raycast(ray, out raycastInfo, 1000, ~gameObject.layer))
            {
                currObj = raycastInfo.collider.gameObject;
            }

            // PRESS true
            if (Input.GetMouseButtonDown(0))
            {
                if (currObj != null)
                {
                    pressObj = currObj;
                    EventMessage em = new EventMessage(currObj, "UICamera-Press", this, true, null, Vector2.zero, true, new object[] { screenPos });
                    EventManager.SendObjectEvent(em, ref _ret);
                }
            }
            // PRESS false (CLICK)
            else if (Input.GetMouseButtonUp(0))
            {
                if (currObj != null)
                {
                    pressObj = null;
                    EventMessage em = new EventMessage(currObj, "UICamera-Press", this, false, null, Vector2.zero, true, new object[] { screenPos });
                    EventManager.SendObjectEvent(em, ref _ret);
                }
            }
            // PRESS hold
            else if (Input.GetMouseButton(0))
            {
                if (currObj != pressObj)
                {
                    if (pressObj != null)
                    {
                        EventMessage em = new EventMessage(currObj, "UICamera-Leave", this, true, null, Vector2.zero, true, new object[] { screenPos });
                        EventManager.SendObjectEvent(em, ref _ret);
                    }
                    pressObj = currObj;
                    if (currObj != null)
                    {
                        EventMessage em = new EventMessage(currObj, "UICamera-Leave", this, false, null, Vector2.zero, true, new object[] { screenPos });
                        EventManager.SendObjectEvent(em, ref _ret);
                    }
                }
                else
                {
                    if (currObj != null)
                    {
                        EventMessage em = new EventMessage(currObj, "UICamera-Down", this, true, null, Vector2.zero, true, new object[] { screenPos });
                        EventManager.SendObjectEvent(em, ref _ret);
                    }
                }
            }
            // Hover
            else
            {
                if (currObj != null)
                {
                }
                else
                {
                    // Do not cast any object
                    if (pressObj != null)
                    {
                        EventMessage em = new EventMessage(pressObj, "UICamera-Leave", this, true, null, Vector2.zero, true, new object[] { screenPos });
                        EventManager.SendObjectEvent(em, ref _ret);
                        pressObj = currObj;
                    }
                }
            }
        }