protected virtual void Start() { isTargetConfigured = false; //save the default pos and rot posTargetInit = transform.position; rotTargetInit = transform.rotation; scaleTargetInit = transform.lossyScale; mTrackableBehaviour = GetComponent <TrackableBehaviour> (); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } ///get the size of the target targetHeight = vImageTargetBehavior.GetSize() [1]; targetWidth = vImageTargetBehavior.GetSize() [0]; //local coordinates of th target ptTopRight = new Vector3(0.5f * (targetWidth / targetHeight), 0, 0.5f); ptTopLeft = new Vector3(-0.5f * (targetWidth / targetHeight), 0, 0.5f); ptBottomRight = new Vector3(0.5f * (targetWidth / targetHeight), 0, -0.5f); ptBottomLeft = new Vector3(-0.5f * (targetWidth / targetHeight), 0, -0.5f); }
// Use this for initialization void Start() { waterLayer = GameObject.Find("Water4Example (Advanced)").GetComponent <Transform>(); ITB = this.GetComponent <ImageTargetBehaviour>(); imageHeight = ITB.GetSize().y / 100; imageWidth = ITB.GetSize().x / 100; }
public void BuildTarget() { if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) // if current frame quality is high { udt_targetBuildingBehavior.BuildNewTarget(targetCounter.ToString(), targetBehaviour.GetSize().x); // build new targetBehaviour with the width of our imagetarget } }
public void BuildTarget() { if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { udt_targetBuildingBehavior.BuildNewTarget(targetCounter.ToString(), targetBehavior.GetSize().x); Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance; Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://ar-demo-1f5c9.appspot.com"); Firebase.Storage.StorageReference file_ref = storage_ref.Child("images/" + FileControl.FilePath); file_ref.PutFileAsync("./Assets/Resources/" + FileControl.FilePath + ".txt").ContinueWith((Task <StorageMetadata> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log("STILL HERE"); Debug.Log(task.Exception.ToString()); // Uh-oh, an error occurred! } else { // Metadata contains file metadata such as size, content-type, and download URL. Firebase.Storage.StorageMetadata metadata = task.Result; //string download_url = metadata.DownloadUrl.ToString(); //Debug.Log("Finished uploading..."); //Debug.Log("download url = " + download_url); } }); } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter); // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); checkquality = true; } else { checkquality = false; Debug.Log("Cannot build new target, due to poor camera image quality"); if (m_QualityDialog) { StopAllCoroutines(); m_QualityDialog.GetComponent <CanvasGroup>().alpha = 1; StartCoroutine(FadeOutQualityDialog()); } } }
protected virtual void Start() { //------------------------------ncCode targetHeight = mImgTarget.GetSize()[1]; targetWidth = mImgTarget.GetSize()[0]; ptTopRight = new Vector3(0.5f * (targetWidth / targetHeight), 0, 0.5f); ptTopLeft = new Vector3(-0.5f * (targetWidth / targetHeight), 0, 0.5f); ptBottomRight = new Vector3(0.5f * (targetWidth / targetHeight), 0, -0.5f); ptBottomLeft = new Vector3(-0.5f * (targetWidth / targetHeight), 0, -0.5f); //------------------------------ mTrackableBehaviour = GetComponent<TrackableBehaviour>(); if (mTrackableBehaviour) mTrackableBehaviour.RegisterTrackableEventHandler(this); }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // Enable Model GameObject.Find("ModelAllocator").GetComponent <ModelAllocator>().enable(); // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter); // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); GameObject.Find("ModelAllocator").GetComponent <ModelAllocator>().disable(); // Disable creating new target GameObject.Find("BuildPanel").SetActive(false); GameObject.Find("ModelAllocator").GetComponent <ModelAllocator>().activateInfoSpeak(); GameObject.Find("ModelAllocator").GetComponent <ModelAllocator>().speakIntro(); // Animate Ground StartCoroutine(summonAnim()); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); if (m_QualityDialog) { StopAllCoroutines(); m_QualityDialog.GetComponent <CanvasGroup>().alpha = 1; StartCoroutine(FadeOutQualityDialog()); } } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { /*if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || * m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) * {*/ // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter); // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); /*} * else * { * Debug.Log("Cannot build new target, due to poor camera image quality"); * if (m_QualityDialog) * { * StopAllCoroutines(); * m_QualityDialog.GetComponent<CanvasGroup>().alpha = 1; * StartCoroutine(FadeOutQualityDialog()); * } * }*/ // print(obj.tempw); StartCoroutine("TakePic"); // obj.HandleUnitSelection(); }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); // if (mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || // mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) // { // // create the name of the next target. // // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names // string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: // mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); // } // else // { // Debug.Log("Cannot build new target, due to poor camera image quality"); // if (mQualityDialog) // { // mQualityDialog.gameObject.SetActive(true); // } // } }
// Update is called once per frame void Update() { if (mImageTargetBehaviour == null) { Debug.Log("ImageTargetBehaviour not found"); return; } else { Vector2 targetSize = mImageTargetBehaviour.GetSize(); float targetAspect = targetSize.x / targetSize.y; // We define a point in the target local reference // we take the bottom-left corner of the target, // just as an example // Note: the target reference plane in Unity is X-Z, // while Y is the normal direction to the target plane Vector3 pointOnTarget = new Vector3(-0.5f, 0, -0.5f / targetAspect); // We convert the local point to world coordinates Vector3 targetPointInWorldRef = transform.TransformPoint(pointOnTarget); // We project the world coordinates to screen coords (pixels) Vector3 screenPoint = Camera.main.WorldToScreenPoint(targetPointInWorldRef); Debug.Log("target point in screen coords: " + screenPoint.x + ", " + screenPoint.y + " name " + mImageTargetBehaviour.name); } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { //if((GameObject.Find("UserDefinedTarget-1") as GameObject) != null) //{ // //} // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); GameController.instance.OnCreateSandbox(); // Game specific callback } else { Debug.Log("Cannot build new target, due to poor camera image quality"); if (mQualityDialog) { mQualityDialog.gameObject.SetActive(true); } } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { //Hide photo button TargetBuilderUIHandler.gameObject.SetActive(false); CrosshairManager.gameObject.SetActive(true); // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); if (mQualityDialog) { mQualityDialog.gameObject.SetActive(true); } } }
public void BuildTarget() { if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH || udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM) { udt_targetBuildingBehavior.BuildNewTarget(targetCounter.ToString(),targetBehavior.GetSize().x); } }
//create new target when camera button clicked public void BuildNewTarget() { if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { measureDistance.buildButtonClicked(); // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = "USERTARGET"; // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); if (m_QualityDialog) { StopAllCoroutines(); //showing Quality message for a sertain time buy StartCoroutine m_QualityDialog.GetComponent <CanvasGroup>().alpha = 1; StartCoroutine(FadeOutQualityDialog()); } } }
// Updates the scale values in the transform component from a given size. public static void UpdateScale(ImageTargetBehaviour it, Vector2 size) { // Update the scale: float childScaleFactor = it.GetSize()[0] / size[0]; if (it.AspectRatio <= 1.0f) { it.transform.localScale = new Vector3(size[0], size[0], size[0]); } else { it.transform.localScale = new Vector3(size[1], size[1], size[1]); } // Check if 3D content should keep its size or if it should be scaled // with the target. if (it.mPreserveChildSize) { foreach (Transform child in it.transform) { child.localPosition = new Vector3(child.localPosition.x * childScaleFactor, child.localPosition.y * childScaleFactor, child.localPosition.z * childScaleFactor); child.localScale = new Vector3(child.localScale.x * childScaleFactor, child.localScale.y * childScaleFactor, child.localScale.z * childScaleFactor); } } }
void OnWillRenderObject() { if (!targetBehaviour || targetBehaviour.ImageTarget == null) { return; } //一半的大小是(0.5,0.3) //识别图大小是(512,326) //targetBehaviour.GetSize()是ImageTarget在Unity场景的中单位(Unity scene units)大小(1,0.6) //Vuforia默认的单位是米 Vector2 halfSize = targetBehaviour.GetSize() * 0.5f; //获取世界坐标,识别图的4个拐角世界坐标 //图片(模型)坐标原点在中心点,因是二维的所以y为0,通过一半的大小参数得到4个角的局部坐标 Vector3 targetAnglePoint1 = _controller.transform.TransformPoint(new Vector3(-halfSize.x, 0, halfSize.y)); Vector3 targetAnglePoint2 = _controller.transform.TransformPoint(new Vector3(-halfSize.x, 0, -halfSize.y)); Vector3 targetAnglePoint3 = _controller.transform.TransformPoint(new Vector3(halfSize.x, 0, halfSize.y)); Vector3 targetAnglePoint4 = _controller.transform.TransformPoint(new Vector3(halfSize.x, 0, -halfSize.y)); Renderprepare(); //设置Shader参数 GetComponent <Renderer>().material.SetVector("_Uvpoint1", new Vector4(targetAnglePoint1.x, targetAnglePoint1.y, targetAnglePoint1.z, 1f)); GetComponent <Renderer>().material.SetVector("_Uvpoint2", new Vector4(targetAnglePoint2.x, targetAnglePoint2.y, targetAnglePoint2.z, 1f)); GetComponent <Renderer>().material.SetVector("_Uvpoint3", new Vector4(targetAnglePoint3.x, targetAnglePoint3.y, targetAnglePoint3.z, 1f)); GetComponent <Renderer>().material.SetVector("_Uvpoint4", new Vector4(targetAnglePoint4.x, targetAnglePoint4.y, targetAnglePoint4.z, 1f)); }
public void BuildTarget() // данный метод будет создвать новуй источник отслеживаня, т.е. при определении высококачественной картинки будет создаваться новая цель. Посути это кнопка!!! { if (UDT_Quality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) // определяем качество картинки { UDT_BuildingBehaviour.BuildNewTarget(targetCount.ToString(), targetBehaviour.GetSize().x); // targetName можно задать любым String, проблема в том, что всякий раз, когда он находит новуюй источник имя будет всегда одинаковым, это не страшно, однако можно это обойти путем создания int и ++ ее при обнаружении нового источника // второй переменной является ширина, задать размеры лучше всего нашего ImageTarget. } }
public void BuildTarget() { if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { //I want to build a new target udt_targetBuildingBehavior.BuildNewTarget(TrackerCounter.ToString(), targetBehaviour.GetSize().x); } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); }
void Start() { #if USE_VUFORIA Vector2 imageTargetSize = imageTaget.GetSize(); float targetWidth = imageTargetSize.x; float targetHeight = imageTargetSize.y; cube = CreateCubeForVuforiaTarget(this.gameObject, targetWidth, targetHeight); #endif }
public void BuildTarget() { if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { //print(targetBehaviour.GetComponent<DefaultTrackableEventHandler>().didclick); didPress = !didPress; targetBehaviour.GetComponent <DefaultTrackableEventHandler>().HideorShowOnButtonPress(didPress); // I want to build a new target udt_targetBuildingBehaviour.BuildNewTarget(targetCounter.ToString(), targetBehaviour.GetSize().x); } }
/// <summary> /// updates the next target name and triggers a target build /// </summary> private void BuildNewTarget() { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names mCurrentTargetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target name: Debug.Log("ImageTargetBuilder.Build with target name " + mCurrentTargetName); mTargetBuildingBehaviour.BuildNewTarget(mCurrentTargetName, ImageTargetTemplate.GetSize().x); }
/// 此方法attached在button上,用于开始create新object(ImageTarget)并向事件system send new TrackableSource is available /// 注意,是开始create而不是this方法就能create好了,它需要和OnNewTrackableSource配合使用 public void IBuildNewTarget() { //create新的target的名字,用于BuildNewTarget方法。上文create的是新的ImageTarget的名字,用于在Hierarchy里display //string targetName = string.Format(imageTargetTemplate.TrackableName + targetCounter); string targetName = string.Format(imageTargetTemplate.TrackableName + targetCounter); //This will start building a new target and report back to the event handlers as soon as a new TrackableSource is available. //create新object targetBuildingBehaviour.BuildNewTarget(targetName, imageTargetTemplate.GetSize().x); //builder.Build (targetName, 300); }
/// <summary> /// 拍摄按钮的点击 /// </summary> public void BulidNewTarget() { if (frameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_LOW || frameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_NONE) { Debug.Log("Cannot Build"); } else { string name = "UseTarget_" + count; mUseTargetBehavior.BuildNewTarget(name, ImageTarget.GetSize().x); } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { //================Info Message===================== m_InfoMesssage.GetComponent <CanvasGroup>().alpha = 0; //================Info Message========================= brush.SetActive(true); stick.SetActive(true); ARbutton.SetActive(false); qualityTitle.SetActive(false); // titlebar.SetActive(false); Titlebar.SetActive(false); paintButton.SetActive(true); blue.SetActive(true); green.SetActive(true); red.SetActive(true); eraser.SetActive(true); frameLow.SetActive(false); frameMed.SetActive(false); frameHigh.SetActive(false); if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter); // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); if (m_QualityDialog) { StopAllCoroutines(); m_QualityDialog.GetComponent <CanvasGroup>().alpha = 1; StartCoroutine(FadeOutQualityDialog()); } } }
// Use this for initialization void InitImageTarget() { //获取所有的可识别对象 IEnumerable <TrackableBehaviour> trackableBehaviours = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); if (trackableBehaviours != null) { Debug.LogFormat("共有 {0} 个识别图", trackableBehaviours.Count()); Vector3 pos = new Vector3(0, 0, 0); foreach (TrackableBehaviour trackableBehaviour in trackableBehaviours) { if (trackableBehaviour == null) { continue; } trackableBehaviour.gameObject.AddComponent <CustomTrackableEventHandler>(); trackableBehaviour.transform.localPosition = pos; trackableBehaviour.gameObject.layer = 8; ImageTargetBehaviour targetBehaviour = trackableBehaviour.gameObject.GetComponent <ImageTargetBehaviour>(); //NOTE 不建议手动设置ImageTargetBehaviour的Size,设置之后会导致计算出的位置不对 //NOTE 多个ImageTarget之间要有间隙,可以理解为平铺开来 pos += new Vector3(targetBehaviour.GetSize().y, pos.y, pos.z); ImageOffsetX = targetBehaviour.GetSize().y; trackableBehaviour.gameObject.name = string.Concat("ImageTarget_", trackableBehaviour.TrackableName); if (!Name2TrackDict.ContainsKey(trackableBehaviour.TrackableName)) { Name2TrackDict.Add(trackableBehaviour.TrackableName, trackableBehaviour); } } Debug.Log("所有识别图都已生成完成"); } CustomTrackableEventHandler.OnFound += CustomTrackableEventHandler_OnFound; CustomTrackableEventHandler.OnLost += CustomTrackableEventHandler_OnLost; }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public bool BuildNewTarget() { if (_frameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || _frameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names var targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, _targetCounter); // generate a new target: _targetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); return(true); } Debug.Log("Cannot build new target, due to poor camera image quality"); return(false); }
public List <float> GetTreasurePosition() { Vector2 targetSize = imageTarget.GetSize(); float targetAspect = targetSize.x / targetSize.y; List <float> originPositions = new List <float> (); Vector3 pointOnTarget = new Vector3(-0.5f, 0, -0.5f / targetAspect); Vector3 targetPointInWorldRef = transform.TransformPoint(pointOnTarget); Vector3 screenPoint = Camera.main.WorldToScreenPoint(targetPointInWorldRef); originPositions.Add(screenPoint.x); originPositions.Add(screenPoint.y); originPositions.Add(screenPoint.z); return(originPositions); }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || m_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, m_TargetCounter); // generate a new target: m_TargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); StatusMessage.Instance.Display("Low camera image quality", true); } }
/// <summary> /// Instantiates a new user-defined target and is also responsible for dispatching callback to /// IUserDefinedTargetEventHandler::OnNewTrackableSource /// </summary> public void BuildNewTarget() { if (mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM || mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH) { // create the name of the next target. // the TrackableName of the original, linked ImageTargetBehaviour is extended with a continuous number to ensure unique names string targetName = string.Format("{0}-{1}", ImageTargetTemplate.TrackableName, mTargetCounter); // generate a new target: mTargetBuildingBehaviour.BuildNewTarget(targetName, ImageTargetTemplate.GetSize().x); } else { Debug.Log("Cannot build new target, due to poor camera image quality"); // user pressed track button even though it is low quality - give a new message? } }