Example #1
0
 public PendingRequest(CreationCallback creationCallback, CompletionCallback completionCallback,
                       long maxAgeMillis)
 {
     this.creationCallback   = creationCallback;
     this.completionCallback = completionCallback;
     this.maxAgeMillis       = maxAgeMillis;
 }
Example #2
0
        /// <summary>
        /// Enqueues a request. Can be called from any thread.
        /// </summary>
        /// <param name="creationCallback">The callback that creates the UnityWebRequest. This callback will
        /// be called when the request is ready to be serviced.</param>
        /// <param name="completionCallback">The callback to call when the request is complete. Will be called
        /// when the request completes.</param>
        /// <param name="maxAgeMillis">Indicates the cache strategy. If this is NO_CACHE, the cache will
        /// not be used, if it's a positive value, it indicates what is the maximum age of the cached
        /// copy that is considered acceptable. If it's ANY_AGE, any cached copy regardless of age
        /// will be considered acceptable.</param>
        public void EnqueueRequest(CreationCallback creationCallback, CompletionCallback completionCallback,
                                   long maxAgeMillis)
        {
            // Your call is very important to us.
            // Please stay on the line and your request will be handled by the next available operator.
            pendingRequests.Enqueue(new PendingRequest(creationCallback, completionCallback, maxAgeMillis));

            // If we are running in the editor, we don't have an update loop, so we have to manually
            // start pending requests here.
            if (!Application.isPlaying)
            {
                StartPendingRequests();
            }
        }
Example #3
0
        public ObjectPool(GameObject prefab, int poolSize, Transform parentTransform, CreationCallback creationCallback)
        {
            _objectPool = new GameObject[poolSize];

            for (int i = 0; i < poolSize; i++)
            {
                GameObject newObject = GameObject.Instantiate(prefab);
                newObject.transform.parent = parentTransform;
                newObject.SetActive(false);
                newObject.name = newObject.name + " [" + i + "]";

                creationCallback?.Invoke(newObject);

                _objectPool[i] = newObject;
            }
        }