Пример #1
0
        internal ImageTargetAbstractBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject, DataSet dataSet)
        {
            DataSetTrackableBehaviour dataSetTrackableBehaviour = gameObject.GetComponent <DataSetTrackableBehaviour>();

            if (dataSetTrackableBehaviour == null)
            {
                dataSetTrackableBehaviour = BehaviourComponentFactory.Instance.AddImageTargetBehaviour(gameObject);
            }
            if (!(dataSetTrackableBehaviour is ImageTargetAbstractBehaviour))
            {
                Debug.LogError(string.Format("DataSet.CreateTrackable: Trackable of type ImageTarget was created, but behaviour of type {0} was provided!", dataSetTrackableBehaviour.GetType()));
                return(null);
            }
            dataSetTrackableBehaviour.InitializeTarget(trackable, false);
            this.mTrackableBehaviours[trackable.ID] = dataSetTrackableBehaviour;
            return(dataSetTrackableBehaviour as ImageTargetAbstractBehaviour);
        }
Пример #2
0
 internal void AssociateTrackableBehavioursForDataSet(DataSet dataSet)
 {
     DataSetTrackableBehaviour[] array = (DataSetTrackableBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(DataSetTrackableBehaviour));
     for (int i = 0; i < array.Length; i++)
     {
         DataSetTrackableBehaviour dataSetTrackableBehaviour = array[i];
         if (!this.mBehavioursMarkedForDeletion.Contains(dataSetTrackableBehaviour) && !this.mVuMarkManager.IsBehaviourMarkedForDeletion(dataSetTrackableBehaviour))
         {
             if (dataSetTrackableBehaviour.TrackableName == null)
             {
                 Debug.LogError("Found Trackable without name.");
             }
             else
             {
                 int    num  = dataSet.Path.LastIndexOf('/') + 1;
                 string text = (num < dataSet.Path.Length) ? dataSet.Path.Substring(num) : null;
                 if (text != null && dataSetTrackableBehaviour.DataSetPath.EndsWith(text))
                 {
                     bool flag = false;
                     foreach (Trackable current in dataSet.GetTrackables())
                     {
                         if (current.Name.Equals(dataSetTrackableBehaviour.TrackableName))
                         {
                             if (this.mTrackableBehaviours.ContainsKey(current.ID) && this.mTrackableBehaviours[current.ID] != dataSetTrackableBehaviour)
                             {
                                 if (!this.mAutomaticallyCreatedBehaviours.Contains(current.ID) && !this.mBehavioursMarkedForDeletion.Contains(this.mTrackableBehaviours[current.ID]))
                                 {
                                     flag = true;
                                     continue;
                                 }
                                 UnityEngine.Object.Destroy(this.mTrackableBehaviours[current.ID].gameObject);
                                 this.mTrackableBehaviours.Remove(current.ID);
                                 this.mAutomaticallyCreatedBehaviours.Remove(current.ID);
                             }
                             flag = dataSetTrackableBehaviour.InitializeTarget(current, false);
                             if (dataSetTrackableBehaviour is VuMarkAbstractBehaviour)
                             {
                                 if (this.mVuMarkManager.AddTemplateBehaviour((VuMarkAbstractBehaviour)dataSetTrackableBehaviour))
                                 {
                                     Debug.Log(string.Concat(new object[]
                                     {
                                         "Found Trackable named ",
                                         dataSetTrackableBehaviour.Trackable.Name,
                                         " with id ",
                                         dataSetTrackableBehaviour.Trackable.ID
                                     }));
                                 }
                             }
                             else
                             {
                                 this.mTrackableBehaviours[current.ID] = dataSetTrackableBehaviour;
                                 Debug.Log(string.Concat(new object[]
                                 {
                                     "Found Trackable named ",
                                     dataSetTrackableBehaviour.Trackable.Name,
                                     " with id ",
                                     dataSetTrackableBehaviour.Trackable.ID
                                 }));
                             }
                         }
                     }
                     if (!flag)
                     {
                         Debug.LogError("Could not associate DataSetTrackableBehaviour '" + dataSetTrackableBehaviour.TrackableName + "' - no matching Trackable found in DataSet!");
                     }
                 }
             }
         }
     }
     VirtualButtonAbstractBehaviour[] vbBehaviours = (VirtualButtonAbstractBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(VirtualButtonAbstractBehaviour));
     this.AssociateVirtualButtonBehaviours(vbBehaviours, dataSet);
     this.CreateMissingDataSetTrackableBehaviours(dataSet);
 }