ImageTargetBaseBehaviour Class

Description

ImageTargetBaseBehaviour is the component to control ImageTarget in the AR scene.

You should set ImageTargetBaseBehaviour to be the parent of 3D contents that associate with the target. The transform between Augmenter and tracked Target is controlled by EasyAR.

To use ImageTargetBaseBehaviour (let a tracker track the target inside the ImageTargetBaseBehaviour), you have to first setup the component with a target from image or json and then load the ImageTargetBaseBehaviour into a TrackerBaseBehaviour.

Generally there are two methods to setup the component. One is to set ActiveTargetOnStart to be true and setup fields (Name, Path, Size and Storage), a load operation will be called at MonoBehaviour.Start . The other method is call SetupWith* manually. You can also reload other targets at any time using SetupWith* methods.

You need to load the ImageTargetBaseBehaviour into a TrackerBaseBehaviour after setup. There are also two methods. First one is to Bind a TrackerBaseBehaviour before SetupWith* calls or MonoBehaviour.Start (when ActiveTargetOnStart is true), the ImageTargetBaseBehaviour will be automatically load into the bound TrackerBaseBehaviour. The other method is call TrackerBaseBehaviour.LoadImageTargetBehaviour or LoadIntoTrackerBehaviour manually.

Public Fields

bool ActiveTargetOnStart
string Name
string Path
Vector2 Size
StorageType Storage
ImageTarget Target

Public Properties

List<TrackerBaseBehaviour> Loaders (until 1.2.1)
List<ImageTrackerBaseBehaviour> Loaders (since 1.3.0)

Public Functions

void Bind(TrackerBaseBehaviour behaviour) (until 1.2.1)
void Bind(TrackerBaseBehaviour behaviour) (since 1.3.0)
void UnBind(TrackerBaseBehaviour behaviour) (until 1.2.1)
void LoadIntoTrackerBehaviour(TrackerBaseBehaviour trackerBaseBehaviour) (until 1.2.1)
void UnloadFromAllTrackers() (until 1.2.1)
bool SetupWithImage(string path, StorageType storageType, string targetname, Vector2 size)
bool SetupWithJsonFile(string path, StorageType storageType, string targetname)
bool SetupWithJsonString(string json, StorageType storageType, string targetname)
bool SetupWithTarget(ImageTarget target)

Public Events

event Action<ImageTargetBaseBehaviour> TargetFound (since 1.3.0)
event Action<ImageTargetBaseBehaviour> TargetLost (since 1.3.0)
event Action<ImageTargetBaseBehaviour, ImageTrackerBaseBehaviour, bool> TargetLoad (since 1.3.0)
event Action<ImageTargetBaseBehaviour, ImageTrackerBaseBehaviour, bool> TargetUnload (since 1.3.0)

Overwritten MonoBahaviour Functions

protected virtual void Awake()
protected virtual void OnDestroy()
protected virtual void Start()
protected virtual void Update()

bool ActiveTargetOnStart

Whether to load the target on a MonoBehaviour.Start call.

string Name

The target name. The set operation should be called before MonoBehaviour.Start if ActiveTargetOnStart is true. The value will be updated when a target is loaded and the target is loaded into a tracker.

See ImageTarget.Load/ImageTarget.LoadImage/ImageTarget.LoadJsonFile/ImageTarget.LoadJsonString for more details.

string Path

The target path. The set operation should be called before MonoBehaviour.Start if ActiveTargetOnStart is true. The value will be updated when a target is loaded and the target is loaded into a tracker.

See ImageTarget.Load/ImageTarget.LoadImage/ImageTarget.LoadJsonFile/ImageTarget.LoadJsonString and StorageType for more details.

Vector2 Size

The target size. The set operation should be called before MonoBehaviour.Start and only none-{0, 0} value will be used to initialize the target size if ActiveTargetOnStart is true. The value will be updated when a target is loaded and the target is loaded into a tracker.

See ImageTarget.Load/ImageTarget.LoadImage/ImageTarget.LoadJsonFile/ImageTarget.LoadJsonString for more details.

StorageType Storage

The target storage type. The set operation should be called before MonoBehaviour.Start if ActiveTargetOnStart is true. The value will be updated when a target is loaded and the target is loaded into a tracker.

See ImageTarget.Load/ImageTarget.LoadImage/ImageTarget.LoadJsonFile/ImageTarget.LoadJsonString and StorageType for more details.

ImageTarget Target

The ImageTarget object. You can reach advanced controls with Target. See ImageTarget for more details.

List<TrackerBaseBehaviour> Loaders (until 1.2.1)

List<ImageTrackerBaseBehaviour> Loaders (since 1.3.0)

Current loaders (TrackerBaseBehaviour) that loads this component.

void Bind(TrackerBaseBehaviour behaviour) (until 1.2.1)

void Bind(ImageTrackerBaseBehaviour behaviour) (since 1.3.0)

Binds TrackerBaseBehaviour. If a TrackerBaseBehaviour is bind, all successful calls to SetupWith* or MonoBehaviour.Start (when ActiveTargetOnStart is true) will be followed by a TrackerBaseBehaviour.LoadImageTargetBehaviour to load the component into the TrackerBaseBehaviour. If not bind, you must manually call TrackerBaseBehaviour.LoadImageTargetBehaviour or LoadIntoTrackerBehaviour to load the component into the TrackerBaseBehaviour to make the target trackable by the tracker.

The behaviour of Bind has changed a lot in 1.3. It is not only a static buildup method, but also a dynamic method in replace of LoadIntoTrackerBehaviour(before 1.3), and Bind(null) is a replace for UnloadFromAllTrackers(before 1.3).

void UnBind(TrackerBaseBehaviour behaviour) (until 1.2.1)

Unbind TrackerBaseBehaviour. Please use Bind(null) in 1.3+.

void LoadIntoTrackerBehaviour(TrackerBaseBehaviour trackerBaseBehaviour) (until 1.2.1)

Load the component and its target into the TrackerBaseBehaviour. It is same with TrackerBaseBehaviour.LoadImageTargetBehaviour. Please use Bind instead in 1.3+.

void UnloadFromAllTrackers() (until 1.2.1)

Unloads the component and its target from all Loaders (TrackerBaseBehaviour). Please use Bind(null) in 1.3+.

bool SetupWithImage(string path, StorageType storageType, string targetname, Vector2 size)

Setup the component with image. See ImageTarget.LoadImage for more details.

Previous Target will be unload from all Loaders. You need to reload this component into a TrackerBaseBehaviour before it can be tracked.

bool SetupWithJsonFile(string path, StorageType storageType, string targetname)

Setup the component with json file. See ImageTarget.LoadJsonFile for more details.

Previous Target will be unload from all Loaders. You need to reload this component into a TrackerBaseBehaviour before it can be tracked.

bool SetupWithJsonString(string json, StorageType storageType, string targetname)

Setup the component with json string. See ImageTarget.LoadJsonString for more details.

Previous Target will be unload from all Loaders. You need to reload this component into a TrackerBaseBehaviour before it can be tracked.

bool SetupWithTarget(ImageTarget target)

Setup the component with a loaded target or could target. See ImageTarget.Load/ImageTarget.LoadImage/ImageTarget.LoadJsonFile/ImageTarget.LoadJsonString for details about how to load the target.

Previous Target will be unload from all Loaders. You need to reload this component into a TrackerBaseBehaviour before it can be tracked.

event Action<ImageTargetBaseBehaviour> TargetFound (since 1.3.0)

Target found event.

event Action<ImageTargetBaseBehaviour> TargetLost (since 1.3.0)

Target lost event.

event Action<ImageTargetBaseBehaviour, ImageTrackerBaseBehaviour, bool> TargetLoad (since 1.3.0)

Target load event.

event Action<ImageTargetBaseBehaviour, ImageTrackerBaseBehaviour, bool> TargetUnload (since 1.3.0)

Target unload event.