Categorieën: Alle - touch - control

door Mike Ton 10 jaren geleden

1938

Unity 3D : Control Freak

The provided text appears to be a snippet of code or documentation related to a control system for a game or application. It involves various components and variables for handling touch input and graphical user interface settings.

Unity 3D : Control Freak

Control Freak

Input Wrapper

ResetInputAxes()

// Internally calls Input.ResetInputAxes() and releases all active touches of active Control Freak controller.

GetAxisPx()

axis -> pixel space?

GetAxis(string axisName)

GetAxisRaw(string axisName)

GetMouseButton()

GetMouseButtonUp()

GetMouseButtonDown()

GetButton(string axisName)

GetButtonUp(string axisName)

GetButtonDown(string axisName)

if CATCH_UNITY_AXIS_EXCEPTIONS

GetKey(KeyCode key)

GetKeyUp(KeyCode key)

GetKeyDown(KeyCode key)

Vector3

mousePosition()

//If there's an active controller in the scene, it's emulated mouse position will be returned

// Active TouchController instance

ImagesGUI

Sample
Debug
Buttons

Scripts

enum
TouchCoordSys

LOCAL_INCH

///< inches, relative to control rectangle's top-left corner

LOCAL_CM

///< centimeters, relative to control rectangle's top-left corner

LOCAL_NORMALIZED

///< control's normalized coords, relative to control rectangle's top-left corner

LOCAL_PX

///< pixels, relative to control rectangle's top-left corner

SCREEN_INCH

///< inches, relative to screen's top-left corner

SCREEN_CM

///< centimeters, relative to screen's top-left corner

SCREEN_NORMALIZED

///< normalized screen coordinates - (0,0) in the top-left, (1,1) in the bottom-right corn

SCREEN_PX

///< pixels, relative to screen's top-left corner

MonoBehaviour

(time)

maskAreas

List

touchables

blankZone

blankStick

(touch)

(multi)

twistSafeFingerDistCm

//< Minimal safe finger distance for twisting (in centimeters)

pinchMinDistCm

//< Minimal finger distance difference to activate pinch

twistThresh

//< twist angular dead zone in degrees

touchTapMaxDistCm

//< Maximal allowed drag distance for a touch to be considered static.

velPreserveTime

//< Amount of time that last non-zero drag velocity will be preserved after movement stopped. Use this to velocity-based swapping easier on those high-pixel-density, low-touch-precision devices.

strictMultiFingerMaxTime

//< Maximal allowed time for the second finger to touch the zone after the first one to start a multi-touch

doubleTapMaxGapTime

//< Maxmimal allowed time between taps to form a double tap

touchTapMaxTime

//< Maximal touch time for a tap (from touch start to release) and time betwwen taps for a double tap

(stick)

stickDigitalLeaveThresh

//< digital thershold for leaving active zone to resting zone (SHOULD be always lower than EnterThresh!)

stickDigitalEnterThresh

//< digital thershold for enetring active zone (0..1)

stickMagnetAngleMargin

//< number of degrees over needed to angle threshold in degrees, angle magnet margin

(mode)

disableWhenNoTouchScreen

//Disactivate this controller when the hardware doesn't support multi-touch input.

automaticMode

//When true, Monobehaviour will automaticly update joystick's state, otherwise - Poll(), UpdateJoy() functions need to called manually

guiPressedOfs

//< Depth offset for pressed control

//< Controller's base GUI depth

manualGui

//When true, automatic GUI rendering will be disabled and DrawControllerGUI() must be called manually

autoActivate

// Automatically set this controller as active (CFInput.ctrl)

LayoutBox[]

layoutBoxes

TouchZone[]

touchZones

TouchStick[]

sticks

TouchableControl
sub

TouchZone

TouchStick

private

(Anim)

pressAnimDuration

smoothReturn

///< Smoothly return to neutral after release.

Vector2

posPx

///< Current static/dynamic position

radPx

layoutPosPx

///< Static position calculated by layout

layoutRadPx

posCm

///< static mode position

sizeCm

///< static mode size

StickPosMode

stickVis

///< Stick position mode

class

Enabled()

/// Returns true if this control is enabled.

DefaultGUIEnabled()

/// Returns true if this control is rendered as a part of automatic GUI.

(GUI)

Hide()

/// Shortcut for Hide(false)

Show()

/// Shortcut for Show(false)

Enable()

/// Shortcut for Enable(false)

DisableGUI()

/// Disable default GUI rendering.

EnableGUI()

/// Enable default GUI rendering.

virtual

TouchController.EventResult

OnTouchMove(int touchId, Vector2 pos)

OnTouchEnd(int touchId, bool cancel = false)

// if bool not passed in; bool is assigned false

OnTouchStart(int touchId, Vector2 pos)

TouchController.HitTestResult

HitTest(Vector2 pos, int touchId)

void

TakeoverTouches(TouchableControl controlToUntouch)

/// Make any shared touches exlusive to this control.

ReleaseTouches()

/// Release all touches assigned to this control.

DrawGUI()

(Layout)

OnLayout()

OnLayoutAddContent()

(Update)

(Poll)

OnPostPoll()

OnPrePoll()

OnReset()

OnPostUpdate(bool firstPostPollUpdate)

OnUpdate(bool firstPostPollUpdate)

Init(TouchController joy)

Hide(bool skipAnim/*= false *////< Skip animation.)

/// Hide this control and release any active touches.

Show(bool skipAnim/*= false *////< Skip animation.)

/// Show hidden control.

Disable(bool skipAnimation///< Skip animation.)

/// Disable this stick and release any active touches.

Enable(bool skipAnimation ///< Skip animation.)

/// Enable this stick.

ResetRect()

/// Reset this control's screen position and size to it's default position (automatic layout).

var

protected

joy

visible

///< When hidden, control will be still controllable.

string

name

///< Control's name.

float

hitDistScale

///< Hit distance scale, used when testing two controls of the same priority level.

int

layoutBoxId

///< Layout Box id.

guiDepth

///< GUI depth offset to controller's base GUI depth

prio

///< Hit-detection priority.

acceptSharedTouches

///< When enabled, this control will accept new touch even if it's already used by higher priority control. Use with caution!

disableGui

///< Disable default GUI drawing.

initiallyHidden

initiallyDisabled

AnimTimer

CFInput

static
public

ctrl

// can be used to turn off touch

UFE

HELP

Stick
>>Button

(code)

HIde and Show TouchZone

// -------------

void ShowZone(string name, bool show)

{

if (CFInput.ctrl == null)

return;

TouchZone zone = CFInput.ctrl.GetZone(name);

if (show)

zone.Show();

else

zone.Hide();

}

// -----------

void Update()

{

if (CFInput.GetButtonDown("Start")) // "Start" is the GetButton() name assigned to the 'Start' zone

{

OnGameStart();

}

// (...)

}

// ---------------

void OnGameStart()

{

ShowZone("Start", false);

// (...)

}

// ---------------

void OnGameOver()

{

ShowZone("Start", true);

// (...)

}

TouchZone zone = CFInput.ctrl.GetZone(name);

zone.Hide();

zone.Show();

(query)

Get direction if set to 4/8 way digital or analog

GetVecEx()

Vector2 TouchStick.GetVecEx(StickPosMode vis)

Get stick's current vector in specified mode.

Get Position at Runtime

touchstick

base

stick_attackStick.GetBaseDisplayRect(true)

hat

stick_attackStick.GetHatDisplayRect(true)

true == scale bool

touchzone

this.touchCtrl.GetZone(ZONE_EXIT).SetRect(new Rect(5, 5 + 32 + 10, 32,32));

TouchStick.DigitalJustChanged(bool eightWayMode)

// Return true if digital direction just changed.

TouchStick.GetDigitalDir(bool eightWayMode)

// Get current digital direction.

TouchStick.GetPrevDigitalDir(bool eightWayMode = true)

// Get previous frame's digital direction.

(state)

JustReleased ()

JustPressed ()

Pressed ()

(config)

bool

false

SmoothReturn

smooth return to neutral after release?

EnableGetAxis()

disp

stick starts at center of touch

func

EnableGetButton

"Jump"

DynamicMode

Preset

type
TouchController

(Debug)

DebugImagesAndColor

SecondTouchEmulation

ScreenEmulation

TouchZones

functionality

EnableGetButton()

EnableGetKey()

time

display

space

Diameter(cm)

Position(cm)

LayoutBox

Sticks

Hat Move Scale

Control how the hat center will follow controlling finger.

Stick Pos Mode

(digital)

DIGITAL_4WAY

DIGITAL_8WAY

(analog)

ANALOG_4WAY

ANALOG_8WAY

FULL_ANALOG

(Dynamic)

Fade-out duration

Dynamic stick's fade-out animation duration in seconds.

Always Reset

Always reset dynamic stick's origin to touched position, even when pressed on still visible stick.

Dynamic Stick Screen Region

Define dynamic stick's work-area - normalized screen region where stick can be placed.

rectRegion = % of screen

Height

Width

pos

y

x

Dynamic Clamp

This will keep out stick fully inside our work area (and offset by margin specified below). situation like that - user touches just at the left edge of the area (which is also an edge of the screen). With clamping disabled, dynamic stick will be centered at the touch position and the player will lose ability to move the stick to the left, because moving the finger any further left and off the screen will terminate the touch. clamping enabled, stick's center will be placed in a safe distance from the edge (see Dynamic Margin).

Dynamic Mode

In Editor, while not playing, all dynamic sticks are positioned at the center of their Dynamic Stick Screen Region.

When in dynamic mode, stick is excluded from layout.

Layout

Draw debug region

Individual debug rendering switch.

???

GeneralSettings

(sample)
CF-UAGK
CF-Stick-And-4-Buttons
CF-Platformer-3-buttons
CF-Lerpz
CF-Halloween-Range
CF-FPP
CF-Dual-Stick
CF-Complete-Physics-Platformer
CF-Bootcamp