/// <summary>Gets the current position.</summary> public void getCurrentPosition(GeolocationEvent success,GeolocationErrorEvent error,GeoPositionOptions options){ // Get service: LocationService ls=UnityEngine.Input.location; if(!ls.isEnabledByUser){ // Denied. if(error!=null){ error(new GeoPositionError(GeoPositionError.PERMISSION_DENIED)); } return; } // Started yet? if(ls.status==LocationServiceStatus.Stopped){ // Start now: ls.Start(); }else if(ls.status!=LocationServiceStatus.Initializing){ // Call ready now: OnReady(success,error,options); return; } // Enqueue, taking our timeout into account. PendingLocationRequest node=new PendingLocationRequest(); // Apply settings: node.Success=success; node.Error=error; node.Options=options; if(options!=null && options.timeout!=0f){ // Get timeout in seconds: node.Timeout=(float)options.timeout/1000f; } node.Next=FirstQueued; FirstQueued=node; if(Updater==null){ // Start calling update now at 10fps: OnUpdate.Add(Update,10f); } }
/// <summary>Gets a bundle using the given bundle URI.</summary> private void LoadBundle(Location uri, BundleReadyEvent bre) { // Main thread only. (Even things like bund!=null can fail). Callback.MainThread(delegate(){ // The underlying uri is uri.Path. string path = uri.Path; // Loading or loaded? AssetBundle bund = Bundles.Get(path); if (bund != null) { bre(bund); return; } DataPackage package; if (Bundles.Loading.TryGetValue(path, out package)) { // Loading - just add a listener (always runs after the bundle loading callback): package.addEventListener("onload", delegate(UIEvent e){ // Callback: bre(Bundles.Get(path)); }); } else { // Make a request: package = new DataPackage(path, null); package.addEventListener("onload", delegate(UIEvent e){ // 5.4.1 onwards #if !UNITY_5_4_0 && UNITY_5_4_OR_NEWER AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(package.responseBytes); #else AssetBundleCreateRequest request = AssetBundle.CreateFromMemory(package.responseBytes); #endif // Get the enumerator: IEnumerator enumerator = Loader(request); // Add updater: OnUpdateCallback cb = null; cb = OnUpdate.Add(delegate(){ // Move enumerator: enumerator.MoveNext(); // Request done? if (request.isDone) { // Great! Stop: cb.Stop(); // Set now: AssetBundle bundle = request.assetBundle; Bundles.Add(path, bundle); // Callback: bre(bundle); } }); }); // Send now: package.send(); } }); }