Пример #1
0
        /// <summary>
        /// Retrieves a named custom instance.
        /// The queue's GameObject will be named Ticked Queue - name.
        /// If the name already exists, it will retrieve the older named instance.
        /// </summary>
        /// <param name="name">
        /// A <see cref="System.String"/> giving the name of the queue.
        /// </param>
        /// <returns>
        /// A <see cref="UnityTickedQueue"/> instance.
        /// </returns>
        public static UnityTickedQueue GetInstance(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Instance);
            }
            name = name.ToLower();

            UnityTickedQueue queue = null;

            if (_instances == null)
            {
                _instances = new Dictionary <string, UnityTickedQueue>();
            }
            else
            {
                _instances.TryGetValue(name, out queue);
            }

            if (queue == null)
            {
                queue            = CreateInstance(name);
                _instances[name] = queue;
            }

            return(queue);
        }
Пример #2
0
        public static ITickedReceipt ScheduleTick(this MonoBehaviour behaviour, string queueName, TickedActionDelegate ticked, int priority, float tickLength)
        {
            var queue  = UnityTickedQueue.GetInstance(queueName);
            var action = new TickedAction(queue.Queue, ticked, priority, (double)tickLength);

            queue.Add(action);

            return(action);
        }
Пример #3
0
 void Start()
 {
     if (this.queues != null)
     {
         foreach (var qc in this.queues)
         {
             var q = UnityTickedQueue.GetInstance(qc.name).Queue;
             q.MaxProcessedPerUpdate      = qc.maxProcessedPerUpdate;
             q.MaxProcessingTimePerUpdate = qc.maxProcessingTimePerUpdate;
         }
     }
 }