コード例 #1
0
    // Here we handle a cloud target recognition event
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        GameObject newImageTarget = Instantiate(behaviour.gameObject) as GameObject;

        quad     = newImageTarget.transform.GetChild(1).gameObject;
        textMesh = quad.transform.GetChild(1).gameObject.GetComponent <TextMesh>();

        pvm = newImageTarget.transform.GetChild(0).gameObject.GetComponent <ProductViewModel>();

        GameObject augmentation = null;

        if (augmentation != null)
        {
            augmentation.transform.SetParent(newImageTarget.transform);
        }

        if (behaviour)
        {
            ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
            //ImageTargetBehaviour behaviour = (ImageTargetBehaviour)tracker.GetTargetFinder<TargetFinder>().EnableTracking(targetSearchResult, newImageTarget);


            IEnumerable <TargetFinder> targetfinders = tracker.GetTargetFinders();

            List <TargetFinder> convertedTargetFinders = targetfinders.ToList();

            if (convertedTargetFinders.Count() > 0)

            {
                ImageTargetBehaviour ImageTargetBehaviour = (ImageTargetBehaviour)convertedTargetFinders[0].EnableTracking(targetSearchResult, newImageTarget);
            }
        }

        TargetFinder.CloudRecoSearchResult cloudRecoSearchResult = (TargetFinder.CloudRecoSearchResult)targetSearchResult;

        // do something with the target metadata
        mTargetMetadata = cloudRecoSearchResult.MetaData;

        //ChangeTextNColor();
        pvm.GetData(this.mTargetMetadata);

        cloud.CloudRecoEnabled = true;
    }