예제 #1
0
        private void AdjustUITransforms()
        {
            if (_TrackingStation == null)
            {
                return;
            }

            RectTransform listRect = _TrackingStation.listContainer.parent.parent as RectTransform;

            if (listRect != null)
            {
                listRect.anchoredPosition = new Vector2(5, -142);
                listRect.sizeDelta        = new Vector2(280, -177);
            }

            RectTransform headerRect = _TrackingStation.listContainer.parent.parent.parent.GetChild(2) as RectTransform;

            if (headerRect != null)
            {
                headerRect.anchoredPosition = new Vector2(5, -108);
                headerRect.sizeDelta        = new Vector2(266, 25);
            }

            Tracking_Utils.TrackingLog("Squishing Sidebar UI Elements");
        }
예제 #2
0
        private IEnumerator WaitForTrackingList()
        {
            //WaitForSeconds wait = new WaitForSeconds(0.1f);

            SpaceTracking _TrackingStation = null;

            while (_TrackingStation == null)
            {
                _TrackingStation = GameObject.FindObjectOfType <SpaceTracking>();

                if (_TrackingStation == null)
                {
                    yield return(null);
                }
            }

            processSprites(_TrackingStation);

            if (loadedPrefabs != null)
            {
                processUIPrefabs();
            }

            if (UILoaded)
            {
                loaded = true;
            }

            Tracking_Utils.TrackingLog("UI Loaded");

            Destroy(gameObject);
        }
예제 #3
0
        private IEnumerator WaitForTrackingStation()
        {
            while (_TrackingStation == null)
            {
                var tracking = FindObjectsOfType <SpaceTracking>();

                if (tracking != null)
                {
                    for (int i = 0; i < tracking.Length; i++)
                    {
                        SpaceTracking space = tracking[i];

                        if (space == null)
                        {
                            continue;
                        }

                        _TrackingStation = space;
                    }
                }

                if (_TrackingStation == null)
                {
                    yield return(null);
                }
            }

            _ListParent = _TrackingStation.listContainer.parent;

            FindScrollRect();

            StartCoroutine(WaitForCamera());

            AdjustUITransforms();

            StartCoroutine(AttachSortHeader());

            _VesselToggleGroup = Instantiate(_TrackingStation.listToggleGroup);

            _OldTrackingList = _TrackingStation.listContainer.gameObject;

            _NewTrackingList = Instantiate(_OldTrackingList);

            _ReorderableList = _OldTrackingList.transform.parent.gameObject.AddComponent <ReorderableList>();
            _ReorderableList.Init(_NewTrackingList.GetComponent <LayoutGroup>(), _NewTrackingList.GetComponent <RectTransform>());
            _ReorderableList.SortType = (int)_CurrentMode;

            _NewTrackingList.transform.SetParent(_ListParent, false);

            _TrackingStation.listContainer.SetParent(null, false);

            _TrackingStation.tglTrackedObjects.onValueChanged.AddListener(new UnityAction <bool>(OnVesselListToggle));

            _OrderedBodyList = OrderBodies();
            _OrderedTypeList = OrderTypes();

            Tracking_Utils.TrackingLog("Tracking Station Processed");
        }
예제 #4
0
        private void FindScrollRect()
        {
            _ScrollView = _TrackingStation.listContainer.GetComponentInParent <ScrollRect>();

            if (_ScrollView == null)
            {
                Tracking_Utils.TrackingLog("Scroll Rect Not Found");
            }
            else
            {
                Tracking_Utils.TrackingLog("Scroll Rect Found");
            }
        }
예제 #5
0
        private IEnumerator AttachSortHeader()
        {
            Transform parent = _TrackingStation.listContainer.parent.parent.parent;

            while (Tracking_Loader.SortHeaderPrefab == null)
            {
                yield return(null);
            }

            SortHeader sort = Instantiate(Tracking_Loader.SortHeaderPrefab).GetComponent <SortHeader>();

            sort.transform.SetParent(parent, false);
            sort.transform.SetSiblingIndex(2);
            sort.Initialize(this);

            Tracking_Utils.TrackingLog("Sort Header Inserted");
        }
예제 #6
0
        private IEnumerator WaitForCamera()
        {
            while (_CanvasCamera == null)
            {
                _CanvasCamera = FindCamera();

                if (_CanvasCamera == null)
                {
                    Tracking_Utils.TrackingLog("Canvas Camera Not Found");
                }
                else
                {
                    Tracking_Utils.TrackingLog("Canvas Camera Found");
                }

                if (_CanvasCamera == null)
                {
                    yield return(null);
                }
            }

            FindCorners();
        }
예제 #7
0
        private void FindCorners()
        {
            if (_ScrollView == null || _CanvasCamera == null)
            {
                return;
            }

            Vector3[] objectCorners = new Vector3[4];
            ((RectTransform)_ScrollView.transform).GetWorldCorners(objectCorners);

            Vector3 bl = _CanvasCamera.WorldToScreenPoint(objectCorners[0]);

            float x = bl.x;
            float y = bl.y;

            bl = _CanvasCamera.WorldToScreenPoint(objectCorners[2]);

            float width  = bl.x - x;
            float height = bl.y - y;

            _ScrollViewRect = new Rect(x, y, width, height);

            Tracking_Utils.TrackingLog("Detected Vessel List Corners");
        }