Logo
 All Classes Files Functions Variables Enumerations
Classes | Public Member Functions | Public Attributes | List of all members
TargetToggle Class Reference

Classes

class  KeybindList

Public Member Functions

int TargetCount ()
void AddTarget (Transform t)
void RemoveTarget (Transform t)
void NextTarget ()
void PreviousTarget ()
bool JumpToTarget (Transform t)
Transform CurrentTarget ()

Public Attributes

bool isActive = true
KeybindList keybindings
List< Transform > targets

Detailed Description

A class which enables target toggling

This script implements a simple target switching mechanic using the dynamic camera. Attach this to a dynamic camera, provide it a list of targets, and you can toggle the mainTarget that the camera will focus on.

The keys to toggle are able to be set within Unity's inspector.

This is capable of handling unexpected null varaiables, but using the AddTarget() and RemoveTarget() methods is the recommended way of modifying the list in code. If a null variable is encountered, the null will be removed and a valid target will be searched for.

For a similar implementation, see TrackingToggle

See Also
TrackingToggle

Member Function Documentation

void TargetToggle.AddTarget ( Transform  t)

Adds a target to the list of targets

This attempts to add a new target to the list of targets. Null values will result in an error and no change to the list.

Parameters
tThe new tranform to add
See Also
RemoveTarget
targets
Transform TargetToggle.CurrentTarget ( )

This returns the current target transform

If the list is empty, a null is returned.

Returns
The current target transfrom
See Also
targets
bool TargetToggle.JumpToTarget ( Transform  t)

This shifts the current target to a specified target

This will attempt to make the current camera mainTarget the argument provided. If the list is empty, the argument is null, or the argument is not in the list, a warning will be reported.

Parameters
tThe transform to jump to
void TargetToggle.NextTarget ( )

This method goes to the next entry in the list, and will wrap to the front of the list if the current element is the last entry in the list.

void TargetToggle.PreviousTarget ( )

This method goes to the previous entry in the list, and will wrap to the end of the list if the current element is the first in the list.

void TargetToggle.RemoveTarget ( Transform  t)

This attempts to remove a target from the list of targets A null or non-existant value will result in an error. If the current target is removed, the toggler switches to the previous target.

Parameters
tThe transform to remove
See Also
AddTarget
targets
int TargetToggle.TargetCount ( )

Returns the number of items currently in the target list.

Returns
The number of targets in the list
See Also
targets

Member Data Documentation

bool TargetToggle.isActive = true

Determines if the controller will respond to IO

If true, keyboard input will be read and targets will be toggled between. If false, new input will not be processed.

KeybindList TargetToggle.keybindings

Wraps the keybindings which toggle

See Also
KeybindList
List<Transform> TargetToggle.targets

The list of targets to toggle between

This is the list of targets that the TargetToggle will cycle between. It can be modified externally, but it is recommended that you modify this via code during runtime using the Add/Remove methods to avoid unexpected errors.

If you manually alter this List during runtim, there is a chance of serious errors.


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