Exemplo n.º 1
0
        public static void Update()
        {
            OnUpdateCallback current = FirstElement;

            while (current != null)
            {
                current.RunMethod();
                current = current.Next;
            }
        }
Exemplo n.º 2
0
        public static OnUpdateCallback Add(UpdateMethod callback, float fps)
        {
            if (callback == null)
            {
                return(null);
            }

            OnUpdateCallback newElement = new OnUpdateCallback(callback, fps);

            if (FirstElement == null)
            {
                FirstElement = LastElement = newElement;
            }
            else
            {
                newElement.Previous = LastElement;
                LastElement         = LastElement.Next = newElement;
            }

            return(newElement);
        }
Exemplo n.º 3
0
        /// <summary>Update waiting requests.</summary>
        internal static void Update()
        {
            // Get service:
            LocationService ls = UnityEngine.Input.location;

            // Get first in queue:
            PendingLocationRequest req = FirstQueued;

            if (ls.status != LocationServiceStatus.Initializing)
            {
                // Ready! All will clear now:
                FirstQueued = null;

                while (req != null)
                {
                    // Call ready:
                    req.Ready();

                    // Next:
                    req = req.Next;
                }
            }
            else
            {
                // Handle timeouts:
                PendingLocationRequest prev = null;

                float limit = Updater.deltaTime;

                while (req != null)
                {
                    // Update it:
                    if (req.Update(limit))
                    {
                        // Done; remove from queue:
                        if (prev == null)
                        {
                            FirstQueued = req.Next;
                        }
                        else
                        {
                            prev.Next = req.Next;
                        }

                        // Don't update prev:
                        req = req.Next;
                        continue;
                    }

                    // Next:
                    prev = req;
                    req  = req.Next;
                }
            }

            if (FirstQueued == null)
            {
                // Kill the updater:
                Updater.Stop();
                Updater = null;
            }
        }
Exemplo n.º 4
0
 public static void Reset()
 {
     FirstElement = LastElement = null;
 }
Exemplo n.º 5
0
        /// <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();
                }
            });
        }