コード例 #1
0
	public void OnTargetFound(DiceId found){
		if (OnGlobalTargetFoundCallback != null) {
			OnGlobalTargetFoundCallback (found);
		}
		Debug.Log ("OnTargetFound "+found.ToString());

		//if we already tracking the dice (compare markers to determine the best match [i.e. the marker on top])
		if (currentlyTracking.ContainsKey (found.diceIdx)) {
			//yes we do a quick search every time we find a new marker already in the system (we could optimize this search by caching or passing in the refs)
			DefaultTrackableEventHandler newlyFoundMarkerObj = FindMarkerObject (found.diceIdx);
			DefaultTrackableEventHandler alreadyCachedMarkerObj = FindMarkerObject (currentlyTracking [found.diceIdx].markerId);

			if(newlyFoundMarkerObj.MarkerID == alreadyCachedMarkerObj.MarkerID){
				Debug.LogError ("We are treating a marker we already found and cached as a new marker never seen before... ERROR. This is a sanity check.");
			} else {

				//udpate the found image we are tracking for a give die
				//FOR THE MOMENT NEW ONE ALWAYS WINS//
				currentlyTracking[found.diceIdx] = found;
				Debug.Log ("Update die[" + found.diceIdx + "] w/ "+found.type);
			}
				
		//if we are not tracking the die yet just ad it to the tracking dictionary
		} else {
			currentlyTracking.Add (found.diceIdx, found);
		}

		if(displayDebugText){
			UpdateDebugText ();
		}
	}
コード例 #2
0
	public void OnTargetLost(DiceId lost){
		if (OnGlobalTargetLostCallback != null) {
			OnGlobalTargetLostCallback (lost);
		}
		Debug.Log ("OnTargetLost "+lost.ToString());

		if (currentlyTracking.ContainsKey (lost.diceIdx)) {
			currentlyTracking.Remove (lost.diceIdx);
		} else {
			Debug.LogWarning ("weirdly doesnt contain  "+lost.ToString()+" as a tracked marker");

		}

		if(displayDebugText){
			UpdateDebugText ();
		}
	}