public static void DownloadTrackableAsync(string url, string datapath, AR.Tracking.Trackable id, bool multithreaded = false, Action callback = null) { Action <WWW> callbackIfSuccessful = www => { Debug.LogWarning(string.Format("[TrackableWebLoader] Missing trackable: ({0}) Downloading from web ({1}) to {2}", id, url, datapath)); byte[] data = www.bytes; string zippath = datapath + "/" + id.name + ".zip"; System.IO.File.WriteAllBytes(zippath, data); Array.Clear(data, 0, data.Length); TargetDownloaded.Invoke(id); }; Action callbackIfFails = () => Debug.LogError("[TrackableWebLoader] Importing trackable from url failed..."); WebLoad(url, false, 10, 5, callbackIfSuccessful, callbackIfFails); }
void Start() { ViewPointManager.Instance.AddViewpoint(this); // TODO: Refactor this (search by type?). Searching objects by name is not very robust way of doing things. Better to use search by types and direct references. foreach (ViewingSector sector in viewingSectors) { if (sector.trackable != null) { Trackable trackable = sector.trackable; GameObject objectInstance = GameObject.Find(trackable.name); if (objectInstance != null) { Trackable trackableInstance = objectInstance.GetComponent <Trackable>(); if (trackableInstance != null) { trackableInstance.AddViewPoint(this); } sector.trackable = trackableInstance; } } } }
void Update() { float heading = 0.0f; if (ApplicationManager.Instance.IsInEditor && player != null) { heading = player.transform.rotation.eulerAngles.y;// + 180.0f; } else { heading = Input.compass.trueHeading; } if (heading > 360.0f) { heading = heading - 360.0f; } CurrentHeading = heading; if (CurrentViewPoint != null) { Trackable before = GetFirstVisibleTrackable(); visibleTrackables = CurrentViewPoint.GetTrackablesInDirection(CurrentHeading); if (visibleTrackables.Count > 1) { Debug.LogWarning("[ViewPointManager] Doing trackable sorting. ATM this should never happen."); visibleTrackables.Sort((x, y) => x.ViewpointNearestToPlayerContaining.DistanceToPlayer.CompareTo(y.ViewpointNearestToPlayerContaining.DistanceToPlayer)); } Trackable after = GetFirstVisibleTrackable(); if (before != after) { FirstVisibleTrackableChanged(this, new EventArg <Trackable>(after)); } } }
public void AddTrackable(Trackable trackable) { allTrackables.Add(trackable); }