ForwardAllMouseEvents

From Unify Community Wiki
Revision as of 03:38, 21 June 2006 by Aarku (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Jonathan Czeck (aarku)

Contents

Description

This script will send mouse events to a target GameObject.

Usage

Assign this script to an object with a Collider, GUITexture, or GUIText. Then set the target property to the GameObject you want the mouse events forwarded to.

Advanced Usage

See DraggableGUIElement.

C# - ForwardAllMouseEvents.cs

<csharp>using UnityEngine; using System.Collections;

public class ForwardAllMouseEvents : MonoBehaviour {

   public GameObject target;
   
   void OnMouseEnter()
   {
       target.SendMessage("OnMouseEnter", SendMessageOptions.DontRequireReceiver);
   }
   
   void OnMouseOver()
   {
       target.SendMessage("OnMouseOver", SendMessageOptions.DontRequireReceiver);
   }
   void OnMouseExit()
   {
       target.SendMessage("OnMouseExit", SendMessageOptions.DontRequireReceiver);
   }
   void OnMouseDown()
   {
       target.SendMessage("OnMouseDown", SendMessageOptions.DontRequireReceiver);
   }
   void OnMouseUp()
   {
       target.SendMessage("OnMouseUp", SendMessageOptions.DontRequireReceiver);
   }
   void OnMouseDrag()
   {
       target.SendMessage("OnMouseDrag", SendMessageOptions.DontRequireReceiver);
   }

} </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox