Esempio n. 1
0
        /// <summary>Collects options from the given gameobject (or any parent in the hierarchy).</summary>
        public ContextEvent collectOptions(GameObject go)
        {
            triggerGameObject = go;

            if (go == null)
            {
                return(null);
            }

            // Create a context event:
            ContextEvent ce = createEvent();

            // Locate it at the gameobject:
            Vector2 pos = rootScreenLocation;

            ce.clientX = pos.x;
            ce.clientY = pos.y;

            trigger = PowerUI.Input.ResolveTarget(go);

            if (trigger != null)
            {
                // Great - dispatch to it (which can change the coords if it wants):
                trigger.dispatchEvent(ce);
            }

            return(ce);
        }
Esempio n. 2
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            trigger = ip.ActiveOverTarget;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);
                return(ce);
            }

            return(ce);
        }
Esempio n. 3
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            triggerElement = ip.ActiveOver;
            trigger        = triggerElement;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);

                triggerGameObject = null;
                return(ce);
            }

            // Collect from a 3D object:
            if (ip.LatestHitSuccess)
            {
                // Try to resolve the hit gameobject to an IEventTarget:
                triggerGameObject = ip.LatestHit.transform.gameObject;
                trigger           = ip.ResolveTarget();

                if (trigger != null)
                {
                    // Great - dispatch to it:
                    trigger.dispatchEvent(ce);
                }
            }

            return(ce);
        }