Public Member Functions | |
void | StartGrabWithCode () |
void | StartGrabWithCode (Vector3 initialGrabPos_) |
void | StartGrabWithMouse () |
void | OnGrab () |
void | OnGrabWithMouse () |
void | EndGrab () |
void | Reset () |
Properties | |
Transform | grabParent [get] |
bool | resetRotationOnGrab [get, set] |
Vector3 | defaultGrabRotation [get, set] |
bool | grabResetting [get, set] |
Vector3 | grabPos [get, set] |
bool | grabRotationLocked [get] |
DSCardGrabber enables more user controlled card movment.
By default, this script will support Mouse click-and-drag input for card position control.
A more code-forward approach, like for controller movement, is available as well.
What is a card grab?
A card grab will move the grabParent, but not the top-parent of the card.
This anchors the card in its original position, while allowing the movement of the card, visually.
In the StacksDemo example project in DeckStacker, the following methods are called by events hooked up in the DSButtonHandler of Card Button objects in DeckStackerCard Demo prefab:
This should be attached to the DSCard prefab.
|
inline |
When grab is done (for example: when the player releases Mouse 0), call EndGrab to release the card.
If using the DSButtonHandler, invoke this method with the EndDrag() event.
|
inline |
When a given grab is successful, call OnGrab every frame to update the card's grabPos.
The actual movement of the card is handled in the DSCard.UpdateGrabPos() method.
If using the DSButtonHandler, invoke this method with the OnDrag() event.
|
inline |
If grabbing with the Mouse, use this one instead.
|
inline |
Called by DSCard.Reset()
|
inline |
When initiating a card grab via code, use this method.
The initial grab position is the position of the card.
|
inline |
This overload will use a Vector3 parameter for the card's initial grab position.
|
inline |
When initiating a grab with the mouse, start the grab with this method. If using the DSButtonHandler on a card, invoke this with the StartDrag() event.
|
getset |
When resetRotationOnGrab is enabled, cards will be set to this rotation when grabbed.
|
get |
This should be a parent object in the card prefab that will work well with user controlled movement.
|
getset |
This Vector3 will is the target worldspace position of the grab movement code.
|
getset |
This bool tells DSCardGrabber to reset the card's grab position back to (0,0,0).
|
get |
DSCardMovementHelper uses this to skip rotation code if resetRotationOnGrab is true and the card is grabbed.
|
getset |
This will make sure grabbed cards will reset their rotation.
If this is false, cards will stay at whatever rotation was previously set, when grabbed.
For example: When a card is in a RowFan stack, it will be rotated.