Esempio n. 1
0
        // Use this for initialization
        void Awake()
        {
            _lineRenderer = GetComponent <LineRenderer>();

            _points.Add(Vector3.zero);
            _points.Add(Vector3.zero);
        }
Esempio n. 2
0
        public void AddTab(SRTab tab, bool visibleInSidebar = true)
        {
            tab.CachedTransform.SetParent(TabContentsContainer, false);
            tab.CachedGameObject.SetActive(false);

            if (visibleInSidebar)
            {
                // Create a tab button for this tab
                var button = SRInstantiate.Instantiate(TabButtonPrefab);
                button.CachedTransform.SetParent(TabButtonContainer, false);
                button.TitleText.text = tab.Title.ToUpper();

                if (tab.IconExtraContent != null)
                {
                    var extraContent = SRInstantiate.Instantiate(tab.IconExtraContent);
                    extraContent.SetParent(button.ExtraContentContainer, false);
                }

                button.IconStyleComponent.StyleKey = tab.IconStyleKey;
                button.IsActive = false;

                button.Button.onClick.AddListener(() => MakeActive(tab));

                tab.TabButton = button;
            }

            _tabs.Add(tab);
            SortTabs();

            if (_tabs.Count == 1)
            {
                ActiveTab = tab;
            }
        }
Esempio 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);
            }
        }
Esempio n. 4
0
        public void AddItem(object item)
        {
            _itemList.Add(item);
            SetDirty();

            if (StickToBottom && Mathf.Approximately(ScrollRect.verticalNormalizedPosition, 0f))
            {
                ScrollRect.normalizedPosition = new Vector2(0, 0);
            }
        }
        protected void OnEntryAdded(ConsoleEntry entry)
        {
            if (_hasCleared)
            {
                _consoleEntries.Add(entry);
            }

            _allConsoleEntries.Add(entry);

            OnUpdated();
        }
Esempio n. 6
0
        protected void HandleDiscoveredObject(GameObject go)
        {
            if (go == CachedGameObject)
            {
                return;
            }

            T unit;

            var id = go.GetInstanceID();

            if (!Cache.TryGetValue(id, out unit))
            {
                unit = (SearchParents ? go.GetComponentInParent(Type) : go.GetComponent(Type)) as T;
                Cache.Add(id, unit);
            }

            if (unit == null)
            {
                Debug.LogWarning(
                    "SRRadar: Object on radar layer missing target type. Layer: {0} Target: {1}".Fmt(LayerMask.LayerToName(Mask),
                                                                                                     typeof(T)), go);

                return;
            }

            if (HasFound(unit))
            {
                return;
            }

            var b = GetBandit();

            b.Unit     = unit;
            b.Distance = (unit.CachedTransform.position - CachedTransform.position).magnitude;

            _nearUnits.Add(b);
        }
Esempio n. 7
0
 private void RecycleRow(Row row)
 {
     _rowCache.Add(row);
 }
Esempio n. 8
0
        protected void ScrollUpdate()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            //Debug.Log("[SRConsole] ScrollUpdate {0}".Fmt(Time.frameCount));

            var pos    = rectTransform.anchoredPosition;
            var startY = pos.y;

            var viewHeight = ((RectTransform)ScrollRect.transform).rect.height;

            // Determine the range of rows that should be visible
            var rowRangeLower  = Mathf.FloorToInt(startY / (ItemHeight + Spacing));
            var rowRangeHigher = Mathf.CeilToInt((startY + viewHeight) / (ItemHeight + Spacing));

            // Apply padding to reduce pop-in
            rowRangeLower  -= RowPadding;
            rowRangeHigher += RowPadding;

            rowRangeLower  = Mathf.Max(0, rowRangeLower);
            rowRangeHigher = Mathf.Min(_itemList.Count, rowRangeHigher);

            var isDirty = false;

#if PROFILE
            Profiler.BeginSample("Visible Rows Cull");
#endif

            for (var i = 0; i < _visibleRows.Count; i++)
            {
                var row = _visibleRows[i];

                // Move on if row is still visible
                if (row.Index >= rowRangeLower && row.Index <= rowRangeHigher)
                {
                    continue;
                }

                _visibleItemList.Remove(row.Index);
                _visibleRows.Remove(row);
                RecycleRow(row);
                isDirty = true;
            }

#if PROFILE
            Profiler.EndSample();
            Profiler.BeginSample("Item Visible Check");
#endif

            for (var i = rowRangeLower; i < rowRangeHigher; ++i)
            {
                if (i >= _itemList.Count)
                {
                    break;
                }

                // Move on if row is already visible
                if (_visibleItemList.Contains(i))
                {
                    continue;
                }

                var row = GetRow(i);
                _visibleRows.Add(row);
                _visibleItemList.Add(i);
                isDirty = true;
            }

#if PROFILE
            Profiler.EndSample();
#endif

            // If something visible has explicitly been changed, or the visible row count has changed
            if (isDirty || _visibleItemCount != _visibleRows.Count)
            {
                //Debug.Log("[SRConsole] IsDirty {0}".Fmt(Time.frameCount));
                LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
            }

            _visibleItemCount = _visibleRows.Count;
        }
Esempio n. 9
0
 public void AddItem(object item)
 {
     _itemList.Add(item);
     SetDirty();
 }
Esempio n. 10
0
 protected static void RecycleBandit(Bandit bandit)
 {
     BanditCache.Add(bandit);
 }