Exemplo n.º 1
0
        public void SetVertexCount(int size)
        {
            if (_lineRenderer == null)
            {
                Awake();
            }

            if (_points.Count == size)
            {
                return;
            }

            _lineRenderer.SetVertexCount(size);

            while (_points.Count > size)
            {
                _points.RemoveAt(size - 1);
            }

            while (_points.Count < size)
            {
                _points.Add(Vector3.zero);
            }

            _points.Trim();
        }
Exemplo n.º 2
0
        private Row GetRow(int forIndex)
        {
            // If there are no rows available in the cache, create one from scratch
            if (_rowCache.Count == 0)
            {
                var newRow = CreateRow();
                PopulateRow(forIndex, newRow);
                return(newRow);
            }

            var data = _itemList[forIndex];

            Row row    = null;
            Row altRow = null;

            // Determine if the row we're looking for is an alt row
            var target = forIndex % 2;

            // Try and find a row which previously had this data, so we can reuse it
            for (var i = 0; i < _rowCache.Count; i++)
            {
                row = _rowCache[i];

                // If this row previously represented this data, just use that one.
                if (row.Data == data)
                {
                    _rowCache.RemoveAt(i);
                    PopulateRow(forIndex, row);
                    break;
                }

                // Cache a row which is was the same alt state as the row we're looking for, in case
                // we don't find an exact match.
                if (row.Index % 2 == target)
                {
                    altRow = row;
                }

                // Didn't match, reset to null
                row = null;
            }

            // If an exact match wasn't found, but a row with the same alt-status was found, use that one.
            if (row == null && altRow != null)
            {
                _rowCache.Remove(altRow);
                row = altRow;
                PopulateRow(forIndex, row);
            }
            else if (row == null)
            {
                // No match found, use the last added item in the cache
                row = _rowCache.PopLast();
                PopulateRow(forIndex, row);
            }

            return(row);
        }
Exemplo n.º 3
0
        private void CameraCheck()
        {
            // Check for cameras which have been destroyed
            for (var i = _cameraListeners.Count - 1; i >= 0; i--)
            {
                if (_cameraListeners[i] == null)
                {
                    _cameraListeners.RemoveAt(i);
                }
            }

            // If camera count has not changed, return
            if (Camera.allCamerasCount == _cameraListeners.Count)
            {
                return;
            }


            // If cache is not large enough to contain current camera count, resize
            if (Camera.allCamerasCount > _cameraCache.Length)
            {
                _cameraCache = new Camera[Camera.allCamerasCount];
            }


            var cameraCount = Camera.GetAllCameras(_cameraCache);

            // Iterate all camera objects and create camera listener for those without
            for (var i = 0; i < cameraCount; i++)
            {
                var c = _cameraCache[i];

                var found = false;

                for (var j = 0; j < _cameraListeners.Count; j++)
                {
                    if (_cameraListeners[j].Camera == c)
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    continue;
                }

                //Debug.Log("[SRDebugger] Found New Camera: {0}".Fmt(c.name));

                var listener = c.gameObject.AddComponent <ProfilerCameraListener>();
                listener.hideFlags = HideFlags.NotEditable | HideFlags.DontSave;
                listener.RenderDurationCallback = CameraDurationCallback;

                _cameraListeners.Add(listener);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Invalidate a single row (before removing, or changing selection status)
        /// </summary>
        /// <param name="itemIndex"></param>
        protected void InvalidateItem(int itemIndex)
        {
            if (!_visibleItemList.Contains(itemIndex))
            {
                return;
            }

            _visibleItemList.Remove(itemIndex);

            for (var i = 0; i < _visibleRows.Count; i++)
            {
                if (_visibleRows[i].Index == itemIndex)
                {
                    RecycleRow(_visibleRows[i]);
                    _visibleRows.RemoveAt(i);
                    break;
                }
            }
        }
Exemplo n.º 5
0
 void Update()
 {
     if (!UseFixedUpdate && Time.realtimeSinceStartup > _nextUpdate)
     {
         InternalPerformScan();
         _nextUpdate = Time.realtimeSinceStartup + UpdateFrequency;
     }
     else
     {
         // Check for null entries (ships destroyed)
         for (int i = _nearUnits.Count - 1; i >= 0; --i)
         {
             if (_nearUnits[i].Unit == null)
             {
                 var b = _nearUnits[i];
                 _nearUnits.RemoveAt(i);
                 RecycleBandit((Bandit)b);
             }
         }
     }
 }