Log in or register to post comments

How do clear Object when have new search results

July 19, 2014 - 7:38am #1
<p>Hello everyone,</p><p><span style="font-size:12px;">I have a problem when&nbsp;</span><span style="letter-spacing: -0.03em; font-family: arial, sans-serif; background-color: transparent;">Creating Cloud Recognition Apps in Unity.</span></p><p>I can&#39;t clear old object when have new search result. Object will be overlap (Please see attached file)</p><p>Here is my code:</p>
<pre class="brush:csharp;">
/*==============================================================================
Copyright (c) 2012-2014 Qualcomm Connected Experiences, Inc.
All Rights Reserved.
==============================================================================*/
 
using System;
using UnityEngine;
 
/// &lt;summary&gt;
/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.
/// It registers itself at the CloudRecoBehaviour and is notified of new search results as well as error messages
/// The current state is visualized and new results are enabled using the TargetFinder API.
/// &lt;/summary&gt;
public class CloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler
{
    #region PRIVATE_MEMBER_VARIABLES
 
    // ImageTracker reference to avoid lookups
    private ImageTracker mImageTracker;
    private ContentManager mContentManager;
private CloudRecoBehaviour mCloudRecoBehaviour;
    // the parent gameobject of the referenced ImageTargetTemplate - reused for all target search results
  //  private GameObject mParentOfImageTargetTemplate;
 
    #endregion // PRIVATE_MEMBER_VARIABLES
 
 
 
    #region EXPOSED_PUBLIC_VARIABLES
 
    /// &lt;summary&gt;
    /// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.
    /// &lt;/summary&gt;
    public ImageTargetBehaviour ImageTargetTemplate;
 
    #endregion
 
    #region ICloudRecoEventHandler_IMPLEMENTATION
 
    /// &lt;summary&gt;
    /// called when TargetFinder has been initialized successfully
    /// &lt;/summary&gt;
    public void OnInitialized()
    {
        // get a reference to the Image Tracker, remember it
        mImageTracker = TrackerManager.Instance.GetTracker&lt;ImageTracker&gt;();
        mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));
    }
 
    /// &lt;summary&gt;
    /// visualize initialization errors
    /// &lt;/summary&gt;
    public void OnInitError(TargetFinder.InitState initError)
    {
        switch (initError)
        {
            case TargetFinder.InitState.INIT_ERROR_NO_NETWORK_CONNECTION:
                ErrorMsg.New(&quot;Network Unavailable&quot;, &quot;Please check your internet connection and try again.&quot;, RestartApplication);
                break;
            case TargetFinder.InitState.INIT_ERROR_SERVICE_NOT_AVAILABLE:
                ErrorMsg.New(&quot;Service Unavailable&quot;, &quot;Failed to initialize app because the service is not available.&quot;);
                break;
        }
    }
    
    /// &lt;summary&gt;
    /// visualize update errors
    /// &lt;/summary&gt;
    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
        switch (updateError)
        {
            case TargetFinder.UpdateState.UPDATE_ERROR_AUTHORIZATION_FAILED:
                ErrorMsg.New(&quot;Authorization Error&quot;,&quot;The cloud recognition service access keys are incorrect or have expired.&quot;);
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_NO_NETWORK_CONNECTION:
                ErrorMsg.New(&quot;Network Unavailable&quot;,&quot;Please check your internet connection and try again.&quot;);
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_PROJECT_SUSPENDED:
                ErrorMsg.New(&quot;Authorization Error&quot;,&quot;The cloud recognition service has been suspended.&quot;);
                break;
            case TargetFinder.UpdateState.UPDATE_ERROR_REQUEST_TIME
AttachmentSize
Image icon Screenshot_2014-07-18-01-52-44.png1.25 MB
Log in or register to post comments