本文整理汇总了C#中DataSet.GetTrackables方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.GetTrackables方法的具体用法?C# DataSet.GetTrackables怎么用?C# DataSet.GetTrackables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSet
的用法示例。
在下文中一共展示了DataSet.GetTrackables方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssociateTrackableBehavioursForDataSet
/// <summary>
/// Finds DataSetTrackableBehaviours for this dataset and associates them with the Trackables in the DataSet.
/// VirtualButtonBehaviours created in the scene are associated with the VirtualButtons in the DataSet or created there.
///
/// If there is a Trackable in the DataSet where no TrackableBehaviour exists yet, this Behaviour is created, together with its VirtualButtons.
/// </summary>
public void AssociateTrackableBehavioursForDataSet(DataSet dataSet)
{
// Step: Add all TrackableBehaviours that belong to this data set and
// are already instantiated in the scene to the dictionary.
DataSetTrackableBehaviour[] trackableBehaviours = (DataSetTrackableBehaviour[])
Object.FindObjectsOfType(typeof(DataSetTrackableBehaviour));
// Initialize all Image Targets
foreach (DataSetTrackableBehaviour trackableBehaviour in trackableBehaviours)
{
IEditorDataSetTrackableBehaviour editorTrackableBehaviour = trackableBehaviour;
if (editorTrackableBehaviour.TrackableName == null)
{
Debug.LogError("Found Trackable without name.");
continue;
}
// check if the TrackableBehaviour references this DataSet
if (editorTrackableBehaviour.DataSetPath.Equals(dataSet.Path))
{
bool matchFound = false;
// find the trackable to be associated with this TrackableBehaviour:
foreach(Trackable trackable in dataSet.GetTrackables())
{
if (trackable.Name.Equals(editorTrackableBehaviour.TrackableName))
{
if (trackableBehaviour is ImageTargetBehaviour &&
trackable is ImageTarget)
{
IEditorImageTargetBehaviour editorImageTargetBehaviour = (ImageTargetBehaviour)trackableBehaviour;
matchFound = true;
editorImageTargetBehaviour.InitializeImageTarget((ImageTarget)trackable);
mTrackableBehaviours[trackable.ID] = trackableBehaviour;
Debug.Log("Found Trackable named " + trackableBehaviour.Trackable.Name +
" with id " + trackableBehaviour.Trackable.ID);
}
else if (trackableBehaviour is MultiTargetBehaviour &&
trackable is MultiTarget)
{
matchFound = true;
IEditorMultiTargetBehaviour editorMultiTargetBehaviour = (MultiTargetBehaviour)trackableBehaviour;
editorMultiTargetBehaviour.InitializeMultiTarget((MultiTarget)trackable);
mTrackableBehaviours[trackable.ID] = trackableBehaviour;
Debug.Log("Found Trackable named " + trackableBehaviour.Trackable.Name +
" with id " + trackableBehaviour.Trackable.ID);
}
}
}
if (!matchFound)
{
Debug.LogError("Could not associate DataSetTrackableBehaviour '" + editorTrackableBehaviour.TrackableName +
"' - no matching Trackable found in DataSet!");
}
}
}
// Step 2: Add all VirtualButtonBehaviours that belong to this data set
// and are already instantiated in the scene to the dictionary.
VirtualButtonBehaviour[] vbBehaviours = (VirtualButtonBehaviour[])
Object.FindObjectsOfType(typeof(VirtualButtonBehaviour));
AssociateVirtualButtonBehaviours(vbBehaviours, dataSet);
// Step 3: Create TrackableBehaviours that are not existing in the scene.
CreateMissingDataSetTrackableBehaviours(dataSet);
}
示例2: DeactivateDataSet
// Deactivates the given dataset.
// This can only be done when the tracker is not running.
public override bool DeactivateDataSet(DataSet dataSet)
{
if (dataSet == null)
{
Debug.LogError("Dataset is null.");
return false;
}
DataSetImpl dataSetImpl = (DataSetImpl)dataSet;
if (QCARWrapper.Instance.ImageTrackerDeactivateDataSet(dataSetImpl.DataSetPtr) == 0)
{
Debug.LogError("Could not deactivate dataset.");
return false;
}
StateManagerImpl stateManager = (StateManagerImpl)TrackerManager.Instance.GetStateManager();
// Deactivate all Trackables.
foreach (Trackable trackable in dataSet.GetTrackables())
stateManager.EnableTrackableBehavioursForTrackable(trackable, false);
mActiveDataSets.Remove(dataSetImpl);
return true;
}
示例3: CreateMissingDataSetTrackableBehaviours
private void CreateMissingDataSetTrackableBehaviours(DataSet dataSet)
{
foreach (Trackable trackable in dataSet.GetTrackables())
{
if (!mTrackableBehaviours.ContainsKey(trackable.ID))
{
if (trackable is ImageTarget)
{
ImageTargetBehaviour itb = CreateImageTargetBehaviour((ImageTarget)trackable);
// Create Virtual Buttons for this Image Target.
((IEditorImageTargetBehaviour)itb).CreateMissingVirtualButtonBehaviours();
// Add newly created Image Target to dictionary.
mTrackableBehaviours[trackable.ID] = itb;
}
else if (trackable is MultiTarget)
{
MultiTargetBehaviour mtb = CreateMultiTargetBehaviour((MultiTarget)trackable);
// Add newly created Multi Target to dictionary.
mTrackableBehaviours[trackable.ID] = mtb;
}
}
}
}
示例4: AssociateTrackableBehavioursForDataSet
/// <summary>
/// Finds DataSetTrackableBehaviours for this dataset and associates them with the Trackables in the DataSet.
/// VirtualButtonBehaviours created in the scene are associated with the VirtualButtons in the DataSet or created there.
///
/// If there is a Trackable in the DataSet where no TrackableBehaviour exists yet, this Behaviour is created, together with its VirtualButtons.
/// </summary>
public void AssociateTrackableBehavioursForDataSet(DataSet dataSet)
{
// Step: Add all TrackableBehaviours that belong to this data set and
// are already instantiated in the scene to the dictionary.
DataSetTrackableBehaviour[] trackableBehaviours = (DataSetTrackableBehaviour[])
Object.FindObjectsOfType(typeof(DataSetTrackableBehaviour));
// Initialize all Image Targets
foreach (DataSetTrackableBehaviour trackableBehaviour in trackableBehaviours)
{
// trackable has been destroyed and shouldn't be associated
if (mBehavioursMarkedForDeletion.Contains(trackableBehaviour))
continue;
IEditorDataSetTrackableBehaviour editorTrackableBehaviour = trackableBehaviour;
if (editorTrackableBehaviour.TrackableName == null)
{
Debug.LogError("Found Trackable without name.");
continue;
}
// check if the TrackableBehaviour references this DataSet
if (editorTrackableBehaviour.DataSetPath.Equals(dataSet.Path))
{
bool matchFound = false;
// find the trackable to be associated with this TrackableBehaviour:
foreach(Trackable trackable in dataSet.GetTrackables())
{
if (trackable.Name.Equals(editorTrackableBehaviour.TrackableName))
{
if (mTrackableBehaviours.ContainsKey(trackable.ID))
{
// don't replace existing behaviour if it has been created manually
if (!mAutomaticallyCreatedBehaviours.Contains(trackable.ID) && !mBehavioursMarkedForDeletion.Contains(mTrackableBehaviours[trackable.ID]))
{
matchFound = true;
continue;
}
// destroy automatically created behaviour - will be replaced by new one
Object.Destroy(mTrackableBehaviours[trackable.ID].gameObject);
mTrackableBehaviours.Remove(trackable.ID);
mAutomaticallyCreatedBehaviours.Remove(trackable.ID);
}
if (trackableBehaviour is ImageTargetBehaviour &&
trackable is ImageTarget)
{
IEditorImageTargetBehaviour editorImageTargetBehaviour = (ImageTargetBehaviour)trackableBehaviour;
matchFound = true;
editorImageTargetBehaviour.InitializeImageTarget((ImageTarget)trackable);
mTrackableBehaviours[trackable.ID] = trackableBehaviour;
Debug.Log("Found Trackable named " + trackableBehaviour.Trackable.Name +
" with id " + trackableBehaviour.Trackable.ID);
}
else if (trackableBehaviour is MultiTargetBehaviour &&
trackable is MultiTarget)
{
matchFound = true;
IEditorMultiTargetBehaviour editorMultiTargetBehaviour = (MultiTargetBehaviour)trackableBehaviour;
editorMultiTargetBehaviour.InitializeMultiTarget((MultiTarget)trackable);
mTrackableBehaviours[trackable.ID] = trackableBehaviour;
Debug.Log("Found Trackable named " + trackableBehaviour.Trackable.Name +
" with id " + trackableBehaviour.Trackable.ID);
}
else if (trackableBehaviour is CylinderTargetBehaviour &&
trackable is CylinderTarget)
{
matchFound = true;
IEditorCylinderTargetBehaviour editorCylinderTargetBehaviour = (CylinderTargetBehaviour)trackableBehaviour;
editorCylinderTargetBehaviour.InitializeCylinderTarget((CylinderTarget)trackable);
mTrackableBehaviours[trackable.ID] = trackableBehaviour;
Debug.Log("Found Trackable named " + trackableBehaviour.Trackable.Name +
" with id " + trackableBehaviour.Trackable.ID);
}
}
}
if (!matchFound)
{
Debug.LogError("Could not associate DataSetTrackableBehaviour '" + editorTrackableBehaviour.TrackableName +
"' - no matching Trackable found in DataSet!");
}
}
}
// Step 2: Add all VirtualButtonBehaviours that belong to this data set
// and are already instantiated in the scene to the dictionary.
VirtualButtonBehaviour[] vbBehaviours = (VirtualButtonBehaviour[])
//.........这里部分代码省略.........