DeckStacker v1.0
A card manager plugin for Unity games.
 
Loading...
Searching...
No Matches
DeckStacker.DSCardGrabber Class Reference
Inheritance diagram for DeckStacker.DSCardGrabber:

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]
 

Detailed Description

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:

  • StartGrabWithMouse is called by the "startDrag" event
  • OnGrabWithMouse is called by the "dragging" event
  • EndGrab is called by the "endDrag" event

This should be attached to the DSCard prefab.

Member Function Documentation

◆ EndGrab()

void DeckStacker.DSCardGrabber.EndGrab ( )
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.

◆ OnGrab()

void DeckStacker.DSCardGrabber.OnGrab ( )
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.

◆ OnGrabWithMouse()

void DeckStacker.DSCardGrabber.OnGrabWithMouse ( )
inline

If grabbing with the Mouse, use this one instead.

◆ Reset()

void DeckStacker.DSCardGrabber.Reset ( )
inline

Called by DSCard.Reset()

◆ StartGrabWithCode() [1/2]

void DeckStacker.DSCardGrabber.StartGrabWithCode ( )
inline

When initiating a card grab via code, use this method.

The initial grab position is the position of the card.

◆ StartGrabWithCode() [2/2]

void DeckStacker.DSCardGrabber.StartGrabWithCode ( Vector3 initialGrabPos_)
inline

This overload will use a Vector3 parameter for the card's initial grab position.

◆ StartGrabWithMouse()

void DeckStacker.DSCardGrabber.StartGrabWithMouse ( )
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.

Property Documentation

◆ defaultGrabRotation

Vector3 DeckStacker.DSCardGrabber.defaultGrabRotation
getset

When resetRotationOnGrab is enabled, cards will be set to this rotation when grabbed.

◆ grabParent

Transform DeckStacker.DSCardGrabber.grabParent
get

This should be a parent object in the card prefab that will work well with user controlled movement.

◆ grabPos

Vector3 DeckStacker.DSCardGrabber.grabPos
getset

This Vector3 will is the target worldspace position of the grab movement code.

◆ grabResetting

bool DeckStacker.DSCardGrabber.grabResetting
getset

This bool tells DSCardGrabber to reset the card's grab position back to (0,0,0).

◆ grabRotationLocked

bool DeckStacker.DSCardGrabber.grabRotationLocked
get

DSCardMovementHelper uses this to skip rotation code if resetRotationOnGrab is true and the card is grabbed.

◆ resetRotationOnGrab

bool DeckStacker.DSCardGrabber.resetRotationOnGrab
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.


The documentation for this class was generated from the following file: