示例#1
0
 private void NotifyDataChanged(DataWatchService.Watchers w)
 {
     DataWatchService.notificationTmpSpies.Clear();
     DataWatchService.notificationTmpSpies.AddRange(w.spyList);
     foreach (DataWatchService.Spy current in DataWatchService.notificationTmpSpies)
     {
         current.onDataChanged(w.watchedObject);
     }
     if (w.watchedObject == null)
     {
         this.DoRemoveWatcher(w);
     }
 }
示例#2
0
        public IDataWatchHandle AddWatch(UnityEngine.Object watched, Action <UnityEngine.Object> onDataChanged)
        {
            if (watched == null)
            {
                throw new ArgumentException("Object watched cannot be null");
            }
            DataWatchHandle dataWatchHandle = new DataWatchHandle(++DataWatchService.s_WatchID, this, watched);

            this.m_Handles[dataWatchHandle.id] = dataWatchHandle;
            DataWatchService.Watchers watchers;
            if (!this.m_Watched.TryGetValue(watched, out watchers))
            {
                watchers = new DataWatchService.Watchers(watched, this);
                this.m_Watched[watched] = watchers;
                watchers.scheduledItem  = this.m_Scheduler.ScheduleUntil(new Action <TimerState>(watchers.OnTimerPoolForChanges), 0L, 0L, null);
            }
            watchers.spyList.Add(new DataWatchService.Spy(dataWatchHandle.id, onDataChanged));
            return(dataWatchHandle);
        }
示例#3
0
        public IDataWatchHandle AddWatch(VisualElement watcher, UnityEngine.Object watched, Action onDataChanged)
        {
            if (watched == null)
            {
                throw new ArgumentException("Object watched cannot be null");
            }
            DataWatchHandle dataWatchHandle = new DataWatchHandle(++DataWatchService.s_WatchID, this, watched);

            this.m_Handles[dataWatchHandle.id] = dataWatchHandle;
            DataWatchService.Watchers value;
            if (!this.m_Watched.TryGetValue(watched, out value))
            {
                value = new DataWatchService.Watchers
                {
                    spyList = new List <DataWatchService.Spy>(),
                    tracker = ChangeTrackerHandle.AcquireTracker(watched)
                };
                this.m_Watched[watched] = value;
            }
            value.spyList.Add(new DataWatchService.Spy(dataWatchHandle.id, watcher, onDataChanged));
            return(dataWatchHandle);
        }
示例#4
0
 private void DoRemoveWatcher(DataWatchService.Watchers watchers)
 {
     this.m_Watched.Remove(watchers.watchedObject);
     this.m_Scheduler.Unschedule(watchers.scheduledItem);
     watchers.tracker.ReleaseTracker();
 }