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 (); } }
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 (); } }
private void OnTrackingLost() { Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true); Collider[] colliderComponents = GetComponentsInChildren<Collider>(true); // Disable rendering: foreach (Renderer component in rendererComponents) { //if (component.gameObject.layer == InteractionLayerIndex) { Debug.Log ("Shut off "+component.gameObject.name); component.enabled = false; //} } // Disable colliders: foreach (Collider component in colliderComponents) { //if (component.gameObject.layer == InteractionLayerIndex) { component.enabled = false; //} } Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost"); if (TargetLostCallback != null) { DiceId diceId = new DiceId(){ type = CurrentDiceImage, diceIdx = Marker.Marker.MarkerID / 6, markerId = Marker.Marker.MarkerID, }; TargetLostCallback (diceId); } }
private void OnTrackingFound() { Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true); Collider[] colliderComponents = GetComponentsInChildren<Collider>(true); // Enable rendering: foreach (Renderer component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (Collider component in colliderComponents) { component.enabled = true; } Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found"); if(TargetFoundCallback != null){ DiceId diceId = new DiceId(){ type = CurrentDiceImage, diceIdx = Marker.Marker.MarkerID / 6, markerId = Marker.Marker.MarkerID, }; TargetFoundCallback (diceId); } }