Esempio n. 1
0
        public void RemoveWatch(IDataWatchHandle handle)
        {
            DataWatchHandle handleImpl = (DataWatchHandle)handle;

            if (m_Handles.Remove(handleImpl.id))
            {
                Watchers watchers;
                if (m_Watched.TryGetValue(handleImpl.watched, out watchers))
                {
                    List <Spy> spyList = watchers.spyList;
                    for (int i = 0; i < spyList.Count; i++)
                    {
                        Spy spy = spyList[i];
                        if (spy.handleID == handleImpl.id)
                        {
                            spyList.RemoveAt(i);

                            if (watchers.IsEmpty())
                            {
                                DoRemoveWatcher(watchers);
                            }
                        }
                    }
                }
                return;
            }
            throw new ArgumentException("Data watch was not registered");
        }
Esempio n. 2
0
        public void RemoveWatch(IDataWatchHandle handle)
        {
            DataWatchHandle dataWatchHandle = (DataWatchHandle)handle;

            if (this.m_Handles.Remove(dataWatchHandle.id))
            {
                DataWatchService.Watchers watchers;
                if (this.m_Watched.TryGetValue(dataWatchHandle.watched, out watchers))
                {
                    List <DataWatchService.Spy> spyList = watchers.spyList;
                    for (int i = 0; i < spyList.Count; i++)
                    {
                        if (spyList[i].handleID == dataWatchHandle.id)
                        {
                            spyList.RemoveAt(i);
                            if (watchers.spyList.Count == 0)
                            {
                                watchers.tracker.ReleaseTracker();
                                this.m_Watched.Remove(dataWatchHandle.watched);
                            }
                            return;
                        }
                    }
                }
            }
            throw new ArgumentException("Data watch was not registered");
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public IDataWatchHandle AddWatch(Object watched, Action <Object> onDataChanged)
        {
            if (watched == null)
            {
                throw new ArgumentException("Object watched cannot be null");
            }

            DataWatchHandle handle = new DataWatchHandle(++s_WatchID, this, watched);

            m_Handles[handle.id] = handle;

            Watchers watchers;

            if (!m_Watched.TryGetValue(watched, out watchers))
            {
                watchers           = new Watchers(watched, this);
                m_Watched[watched] = watchers;

                watchers.scheduledItem = m_Scheduler.ScheduleUntil(watchers.OnTimerPoolForChanges, 0, 0, null); //we poll as often as possible
            }
            watchers.spyList.Add(new Spy(handle.id, onDataChanged));
            return(handle);
        }