Move & Resize UI: Scripts for UI Windows and Objects

DCTShinobi

(12)
$4
Publisher DCTShinobi
File size 326.56kB
Number of files 80
Latest version 5
Latest release date 2017-11-27 06:13:28
First release date 2014-12-11 09:45:29
Supported Unity versions 2018.4.2 or higher
Newest Demo

Move/Resize Webplayer Demo

Scale/Anchor Webplayer Demo

Full Readme



Description:
This is a collection of scripts that allow the user to move and resize UI windows and objects in various ways at runtime. For descriptions of the various methods, see the "Included Scripts" section below. They are written for use with Unity's new UI system. Version 4 completely overhauled most of the existing scripts to use a single script as a main controller.

Version 5.1 adds a simple rotation script by special request.
NOTE: Rotated objects currently do not have accurate cursor detection.


Script Features:

Simplicity:
They are simply scripts that attach to objects.

No jumping to the cursor:
The object will not jump to center around the cursor. If you begin dragging an object from the corner, your drag will remain at the corner of the object.

Move smoothly or by intervals:
You have the options to move and resize objects smoothly or by defined intervals. Smooth is the default method, however, the interval method may be desired if using a grid-based system or if you want easier alignment.

Customizable border and inset sizes:
Variable-based thickness of borders and insets for easy customization. Borders are used for resizing. Insets are used for moving. They can easily be configured to work together.

Set minimum size:
You can set how small your objects can resize to both vertically and horizontally. They will never shrink so small that they cannot be enlarged again... unless you want them to.

Event friendly:
Use in accordance with events to make a window work how you want it to work. Do you want to be able to choose between the smooth and interval methods at runtime? All you need is a button or toggle. Do you want to lock the window in place for now, but unlock it later? A single button is the answer. Do you want to be able to drag your mouse freely in a window without moving anything? A panel with Pointer Enter/Exit events can do the job!

Fully commented scripts:
Want to know how the scripts work? Just follow along. It should make it much easier to add onto or modify.

Customizable cursors (limited):
Set your own images to be used as custom cursors when the cursor is over a moveable/resizable position.

Restrain to screen/parent:
Restrain an object from being moved or resized off the screen or outside of its parent. Completely optional.

Single control script:
A new script has been added to control raycasting, custom cursors, and activation of other scripts.

Unity 5:
Officially for Unity 5!

Movement multiplier:
The ratio of movement or resizing based on the mouse movement can be customized.


*NEW IN VERSION 5*

Rotation:
Objects can now be rotated.


Included Scripts:

Move:
Moves the scripted object when the mouse is dragged.

MoveParent:
Moves the direct parent of the scripted object when the mouse is dragged.

MoveOther:
Moves an object that has a distant or no relation to the scripted object when the mouse is dragged. Suggested use is for relations more distant than direct parent-child, though there may be other creative uses.

Resize:
Resizes the scripted object when the mouse drags its borders (edges).

ResizeParent:
Resizes the direct parent of the scripted object when the mouse is dragged.

ResizeOther:
Resizes an object that has a distant or no relation to the scripted object when the mouse is dragged. Suggested use is for relations more distant than direct parent-child, though there may be other creative uses.

Rotate:
Rotates an object.

BringToFront:
Clicking brings the object and its children to the front of the UI overlay.
Note: This feature is included in all of the above scripts as well. This script is only needed if an object has no script attached to itself or to its (grand)parent(s), but you still wish to bring the object to the front of the UI overlay.

DisableMoveResize:
A script used as a reference to the Move and Resize series of scripts to disable their actions if the object this script is attached to is clicked. It affects only its object, not its children or grandchildren.

ScaleHorizontal:
Scales two objects horizontally when the scripted object is dragged. As one gets wider, the other gets thinner.

ScaleVertical:
Scales two objects vertically when the scripted object is dragged. As one gets taller, the other gets shorter.

Anchor:
Anchors the alignment and/or positioning of one object to the scripted object. User can define the alignment and positioning in the inpector or can use the current alignment and positioning of the object.

MaximizeMinimizeRestore:
As the name implies, this script gives maximize an object to the size of its parent or screen, to minimize it to pre-defined or user-defined poisitions and sizes, and to restore its original size and position.

PushPull:
Allows one object to push another object or its edge then pull it back by defined amounts. Similar to anchoring, but with more versatility.

Ignore:
Used as a reference for raycasting. Any object with this script attached will be ignored by a raycast, returning the object that is behind it.

UIController:
Controls the raycasting and activation of the other scripts. Also sets the cursor to the correct custom cursor depending on the cursor position.


IMPORTANT:
These scripts were written specifically for use with mouse controls, so it is also unlikely to work with other forms of controllers without modification.
These scripts are tested using a single canvas set to Screen Space - Overlay with default settings. Any changes to the canvas' settings may cause the scripts to not work as intended.

Top Publisher Assets