Пример #1
0
        public void Step()
        {
            EventStepper.active = this;
            var count = this.passes;

            while (count > 0)
            {
                count -= 1;
                bool canceled = false;
                if (this.index != -1)
                {
                    this.method(this.collection, this.index);
                    float percent = ((float)this.index) / this.collection.Count;
                    canceled    = EditorUI.DrawProgressBar(EventStepper.title, EventStepper.message, percent);
                    this.index += 1;
                }
                bool loading = Application.isLoadingLevel;
                bool ended   = (this.index > this.collection.Count - 1) || this.index == -1;
                if ((loading || canceled || ended) && !this.complete)
                {
                    this.index    = -1;
                    this.complete = true;
                    this.onComplete();
                    EventStepper.instances.Remove(this);
                    EditorUI.ClearProgressBar();
                    break;
                }
            }
            EventStepper.active = null;
        }
Пример #2
0
        public static void AddStepper(string eventName, MethodStep method, IList collection, int passes = 1)
        {
            var stepper = new EventStepper(method, null, collection, passes);

            stepper.onComplete = () => Events.Remove(eventName, stepper.Step);
            Events.Add(eventName, stepper.Step).SetPermanent();
        }