Example #1
0
        //Returns a list of updated or created gameobjects
        static public List<GameObject> updateTrackablesFor(ARDataSetBehaviour dataset)
        {
            List<GameObject> list = new List<GameObject>();
            if (dataset.Name == null)
                return list;

            DataSetInformation dsInfo = getStoredDataSetInformation(dataset.Name);
            foreach (ImageTargetInformation itInfo in dsInfo.ImageTargets)
            {
                ImageTargetBehaviour it = null;
                foreach (var existing in dataset.transform.GetComponentsInChildren<ImageTargetBehaviour>())
                {
                    if (existing.TrackableName == itInfo.Name)
                    {
                        it = existing;
                        break;
                    }
                }
                if (it == null)
                {
                    //No such target found, so create a new one
                    GameObject go = new GameObject("ARImageTarget<" + itInfo.Name + ">");
                    go.transform.parent = dataset.transform;
                    go.transform.position = Vector3.zero;
                    go.transform.rotation = Quaternion.identity;
                    go.AddComponent<ARTrackableBehaviour>();
                    it = go.AddComponent<ImageTargetBehaviour>();
                }
                updateImageTarget(it, dsInfo, itInfo);
                list.Add(it.gameObject);
            }

            return list;
        }
        void updateTrackablesFor(ARDataSetBehaviour dataset)
        {
            foreach (var go in ARUtilities.updateTrackablesFor(dataset))
            {
                EditorUtility.SetDirty(go);
                ImageTargetBehaviour it = go.GetComponent<ImageTargetBehaviour>();
                if (it != null)
                {
                    EditorUtility.SetDirty(it);
                }
            }

            UnityUtils.expandHierarchy(dataset.gameObject, true);
        }