티스토리 뷰
반응형
안녕하세요. Base Of Coding입니다.
요즘 찾고 있는 정보가 있는데.. 이것저것 뒤져보다가 저는 쓸 일이 없지만
에셋번들 없이 사용하시는 분들께서는 도움이 될 것 같은 것들을 가져왔습니다.
imagetarget 동적할당 하는 부분인데요.
코드는 아래와 같습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | using UnityEngine; using System.Collections; using Vuforia; using System.Collections.Generic; public class DynamicDataSetLoader : MonoBehaviour { // specify these in Unity Inspector public GameObject augmentationObject = null; // you can use teapot or other object public string dataSetName = ""; // Assets/StreamingAssets/QCAR/DataSetName // Use this for initialization void Start() { // Vuforia 5.0 to 6.1 VuforiaBehaviour vb = GameObject.FindObjectOfType<VuforiaBehaviour>(); vb.RegisterVuforiaStartedCallback(LoadDataSet); // Vuforia 6.2+ VuforiaARController.Instance.RegisterVuforiaStartedCallback(LoadDataSet); } void LoadDataSet() { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); DataSet dataSet = objectTracker.CreateDataSet(); if (dataSet.Load(dataSetName)) { objectTracker.Stop(); // stop tracker so that we can add new dataset if (!objectTracker.ActivateDataSet(dataSet)) { // Note: ImageTracker cannot have more than 100 total targets activated Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>"); } if (!objectTracker.Start()) { Debug.Log("<color=yellow>Tracker Failed to Start.</color>"); } int counter = 0; IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); foreach (TrackableBehaviour tb in tbs) { if (tb.name == "New Game Object") { // change generic name to include trackable name tb.gameObject.name = ++counter + ":DynamicImageTarget-" + tb.TrackableName; // add additional script components for trackable tb.gameObject.AddComponent<DefaultTrackableEventHandler>(); tb.gameObject.AddComponent<TurnOffBehaviour>(); if (augmentationObject != null) { // instantiate augmentation object and parent to trackable GameObject augmentation = (GameObject)GameObject.Instantiate(augmentationObject); augmentation.transform.parent = tb.gameObject.transform; augmentation.transform.localPosition = new Vector3(0f, 0f, 0f); augmentation.transform.localRotation = Quaternion.identity; augmentation.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f); augmentation.gameObject.SetActive(true); } else { Debug.Log("<color=yellow>Warning: No augmentation object specified for: " + tb.TrackableName + "</color>"); } } } } else { Debug.LogError("<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>"); } } } |
한번 천천히 분석해가시면서 사용해보시면 좋을 것 같습니다.
출처는 Vuforia 포럼에서 가져왔습니다.
출처 : https://developer.vuforia.com/forum/faq/unity-load-dataset-setup-trackables-runtime
지금까지 Base Of Coding이였습니다.
- 이 글에 도움이 되셨다면, 공감(♡) 버튼과 댓글 부탁드리겠습니다. -
반응형
'게임 프로그래밍 ( 이제 안함 ) > AR & VR' 카테고리의 다른 글
AR - Wikitude 카메라 셋팅 컨트롤 ( Camera Setting Control ) (0) | 2019.02.16 |
---|---|
AR - Vuforia Image target 이름이 -Default로 변하는 현상 (0) | 2018.11.26 |
AR - Vuforia Unity3D 퍼미션 체크 충돌 이슈 (0) | 2018.09.14 |
AR - Vuforia 카메라 문제 ( iOS ) (0) | 2018.08.17 |
AR - 뷰포리아 카메라 앞/뒤 전환, 미러기능 (0) | 2018.07.31 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 유니티로 배우는 C#
- CSS
- 프리젠테이션 로직
- baseofcoding
- GitHub
- HTML
- c#
- JSP
- Spring
- 유니티3D
- MVC
- Base Of Coding
- VR
- 프로그래밍
- Controller
- Git
- 게임프로그래밍
- Next.js
- unity3d
- spring boot
- Vuforia
- 뷰포리아
- Java
- 서블릿
- 비지니스 로직
- Servlet
- Unity
- 유니티
- 안드로이드
- 스프링
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함