UIManager


The UIManager class is an essential element of EZ GUI which polls for input and dispatches it to your various EZ GUI controls. There should always be exactly one (1) GameObject with a UIManager script in any scene that contains EZ GUI controls.
Pointer Type
Sets the type of pointing device to be used. You can use this to easily switch between mouse, touchpad, or ray input. See the section below on pointer type settings.
Drag Threshold
This is the distance the input device must be dragged before it will no longer be considered a "tap". For instance, if the user places their finger on a button and then drags beyond the Drag Threshold, then when they lift their finger again, it will not be considered a "tap" which triggers the button. This is particularly important for scrollable lists of buttons.
NOTE: For MOUSE and TOUCHPAD pointer types, this is the distance in pixels. For the RAY pointer type, this value is interpreted as world units.
Ray Drag Threshold
This is similar to dragThreshold except instead of a distance in pixels, it is the world-distance between the endpoint of the Ray pointer (based on rayDepth) when the ray went active to the endpoint of the ray in successive frames.
Mouse And Touch Depth
This specifies how far, in world units, into the scene (i.e. from the camera) to cast mouse and touchpad events into the scene. Only modify this value if you wish to limit the player's "reach" into a 3D scene when using the mouse or touchpad for input. The default is infinity.
Ray Depth
This specifies how far, in world units, into the scene (i.e. from the camera) the RAY pointer type should extend. Objects beyond this distance will not be triggered by the ray.
Ray Mask
Determines which layers can be clicked/activated using the RAY pointer type.
Focus With Ray
Sets whether the RAY pointer (if any) should be used to set the keyboard focus, at the exclusion of the mouse/touchpad pointer(s). Set this to false if you want to use the touchpad or mouse to set the keyboard focus, and set it to true if you instead want to set the focus using the ray pointer.
Action Axis
For use with RAY pointer types. This is the name of the "axis" in the input manager to use to activate the ray. Essentially, this is the "axis" you want to use when the user wants to interact with the world. Use this to setup a "use key", etc. For more information on input axes or how to use the input manager, see the "Input" section of the Unity User Guide.
NOTE: If you do not plan to use Unity's input system for this purpose, be sure to set this value to an empty string.
Input Outside Viewport
Determines how input events that occur outside the game's viewport will be handled. Possible settings are:

Process_All - Process all input that occurs outside the game's viewport.

Ignore - Ignore all input that occurs outside the game's viewport. NOTE: This may lead to missing events, such as a pointer release that occurs outside the viewport.

Move_Off (default) - If any pointer that moves outside the game's viewport has a current target object, that object is sent a MOVE_OFF or RELEASE_OFF (as appropriate) event. Otherwise, it is ignored.
Warn On Non UI Hits
When checked, a warning will be logged to the console whenever a non-UI object in the scene is "hit" by an input event. Use this when you want to make sure you have all of your layers setup correctly to mask out non-UI objects.
UI Cameras
A list of all the cameras to be used for detecting GUI input from the mouse and touchpad pointer types. Each camera you assign can also have its own mask and ray depth setting.
Ray Camera
The camera to be used for the casting rays for the RAY pointer type, if using a camera other than the Main Camera. Otherwise, you can leave this set to the default.
Block Input
When true, no input will be processed. This is primarily used internally at runtime to disable input during transitions, etc. But it can also be used in other situations when you want to prevent user input.
Default Drag Offset
The default distance, in world units, a dragged control should be offset toward the camera so as to ensure it hovers above other objects and controls in the scene.
Cancel Drag Easing
The default easing for when a drag and drop is canceled.
Cancel Drag Duration
The duration of a canceled drag's easing animation.
Default Font
Default font to use when automatically creating SpriteText labels for controls in edit-mode.
Default Font Material
Default material use for the default font.
[keyboard rotation flags] (iPhone only)
When using iPhone, there will appear here a list of flags allowing you to specify in which orientations to which the keyboard should be allowed to auto-rotate.
Pointer Types
There are currently 6 pointer type settings to choose from:
  • MOUSE
  • TOUCHPAD
  • AUTO_TOUCHPAD
  • RAY
  • MOUSE_AND_RAY
  • TOUCHPAD_AND_RAY

Mouse and Touchpad pointer types are pretty straight-forward. When the user moves or clicks the mouse, or touches the touchpad, it just works. The MOUSE_AND_RAY and TOUCHPAD_AND_RAY types combine RAY pointer type functionality with the MOUSE and TOUCHPAD types. The AUTO_TOUCHPAD pointer type will automatically allow both mouse and touchpad input while in-editor, and automatically switches to TOUCHPAD when deployed to a touchpad-based device (iPhone, iPad, Android, etc).

The RAY pointer type

The RAY pointer type is special in that it does not directly use the mouse or touchpad. Rather, it projects a ray from the center of the screen (from the selected UI Camera) into the game scene a distance specified by the Ray Depth setting in UIManager. This pointer type is useful for things like providing Doom 3-like in-world user interfaces in an FPS. Use it to allow the user to use in-world objects such as keypad door locks, in-world control panels, etc. This way, the player's crosshairs serve as their pointing device when they are near enough to an in-world UI object.

Unlike the MOUSE and TOUCHPAD types, which are considered "active" whenever the left mouse button is pressed or the screen is touched, respectively, the RAY type is "active" when the input axis specified by Action Axis is active. This allows you to present the player with a user-configurable input scheme. The player can use Unity's input manager to setup what is effectively their "use/action" button/key. (For more information on Unity's Input Manager, or how to setup an axis, see the "Input" section of the Unity User Guide.) Alternatively, you can put the ray into an active state by either using the built-in UIActionBtn control type (useful for touchpad-based games), or by manually setting the ray's active state in-code by assigning one of three values to the UIManager's RayActive property:

  • Inactive - The ray is not active.
  • Momentary - The ray is active for a single frame (a momentary "click").
  • Constant - The ray is active until further notice.

The RAY pointer type is very powerful for creating interactive worlds.