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"); }
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); }
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"); }
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"); } }
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"); }
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(); }
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"); }