using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SC.XR.Unity { class TrackableManager : Singleton { private List allTrackables = new List(); private Dictionary oldTrackableDic = new Dictionary(); public void GetTrackables(List trackables, TrackableQueryFilter filter) where T : Trackable { trackables.Clear(); switch (filter) { case TrackableQueryFilter.All: GetAllTrackable(trackables); break; case TrackableQueryFilter.New: GetNewTrackable(trackables); break; } } private void GetAllTrackable(List trackables) where T : Trackable { //TODO trackables.Clear(); TrackableApi.GetPlaneInfo(trackables); RefreshOldTrackable(trackables); } private void GetNewTrackable(List trackables) where T : Trackable { //TODO allTrackables.Clear(); trackables.Clear(); TrackableApi.GetPlaneInfo(allTrackables); for (int i = 0; i < allTrackables.Count; i++) { Trackable trackable = allTrackables[i]; if (!oldTrackableDic.ContainsKey(trackable.trackableId)) { trackables.SafeAdd(trackable); } } RefreshOldTrackable(allTrackables); } private void RefreshOldTrackable(List trackables) where T : Trackable { oldTrackableDic.Clear(); for (int i = 0; i < trackables.Count; i++) { Trackable trackable = trackables[i]; oldTrackableDic[trackable.trackableId] = trackable; } } } }