private IEnumerator ReferenceFullPaperFade(ChildObjFadeStatus status) { if (status == ChildObjFadeStatus.CLOSE) { for (float i = CANVAS_CLOSE_TIME; i >= 0; i -= Time.deltaTime) { float percentage = i / CANVAS_CLOSE_TIME; bkgFullPaper.alpha = percentage; yield return(null); } FullPaperObj.SetActive(false); // Reset to navigation recognizer GazeGestureManager.Instance.Transition(GazeGestureManager.Instance.NavigationRecognizer); } else if (status == ChildObjFadeStatus.OPEN) { FullPaperObj.SetActive(true); // Clear, if any. foreach (GameObject go in fullPaperPages) { Destroy(go); } UpdateRefDocObjects(fullPaperGrid, fullPaperPages); prevManipulationPosition = Vector3.zero; for (float i = 0; i <= CANVAS_OPEN_TIME; i += Time.deltaTime) { float percentage = i / CANVAS_OPEN_TIME; bkgFullPaper.alpha = percentage; yield return(null); } // Start the manipulation recognizer GazeGestureManager.Instance.Transition(GazeGestureManager.Instance.ManipulationRecognizer); } else if (status == ChildObjFadeStatus.CLOSE_AND_OPEN) { // Show, find, or create, Flag: OFF -> ON //GameObject newDocumentObj = Instantiate(Resources.Load("PanelRefDocument")) as GameObject;\ GameObject newFullPaperObj = Instantiate(FullPaperObj, gameObject.transform); newFullPaperObj.SetActive(true); newFullPaperObj.transform.position = FullPaperObj.transform.position; newFullPaperObj.transform.rotation = FullPaperObj.transform.rotation; HorizontalLayoutGroup newFullPaperGrid = newFullPaperObj.GetComponent <HorizontalLayoutGroup>(); List <GameObject> newFullPaperPages = new List <GameObject>(); UpdateRefDocObjects(newFullPaperGrid, newFullPaperPages); CanvasGroup newBkgFullPaper = newFullPaperObj.GetComponent <CanvasGroup>(); for (float i = CANVAS_OPEN_TIME; i >= 0; i -= Time.deltaTime) { float percentage = i / CANVAS_OPEN_TIME; // Fading out bkgFullPaper.alpha = percentage; // Fading in newBkgFullPaper.alpha = 1 - percentage; yield return(null); } // Replace the attributes foreach (GameObject go in fullPaperPages) { Destroy(go); } fullPaperPages = newFullPaperPages; fullPaperGrid = newFullPaperGrid; FullPaperObj.SetActive(false); FullPaperObj = newFullPaperObj; bkgFullPaper = newBkgFullPaper; Debug.Log("Ref: full paper replaced:" + refFileName); } }
private void Update() { if (Screen.orientation != ScreenOrientation.Landscape) { Screen.orientation = ScreenOrientation.Landscape; } int width = Screen.width, height = Screen.height; if (w != width && h != height) { //Debug.Log("CHANGED DIMENSIONS"); w = width; h = height; } if (myCardsContainer && false) { HorizontalLayoutGroup hlg = myCardsContainer.transform.GetComponent <HorizontalLayoutGroup>(); int cardCt = myCardsContainer.transform.childCount; if (cardCt <= 6) { hlg.spacing = 0; } else if (cardCt <= 8) { hlg.spacing = -20; } else if (cardCt <= 10) { hlg.spacing = -40; } //else if (cardCt <= 10) // hlg.spacing = -5; //else if (cardCt <= 12) // hlg.spacing = -25; else { hlg.spacing = -50; } } if (Time.time - spawnCardTimer >= .7f) //&& mainCanvas.transform.GetChild(1).name != "AnimatedCard(Clone)") { GameObject canvas = null; if (mainCanvas != null) { canvas = mainCanvas; } else if (multiplayersCanvas) { canvas = multiplayersCanvas; } else if (!isServer && Client.client && !Client.client.inLobby && Client.client.lobbySearchCanvas) { canvas = Client.client.lobbySearchCanvas; } if (canvas != null) { GameObject animatedCard = Instantiate(animatedCardPrefab); float x = UnityEngine.Random.Range(-600f, 700f); animatedCard.transform.SetParent(canvas.transform); animatedCard.transform.SetSiblingIndex(1); animatedCard.transform.localPosition = new Vector3(x, 500f, 0); } spawnCardTimer = Time.time; } }
// Use this for initialization void Start() { hlg = GetComponent <HorizontalLayoutGroup>(); }
private void Awake() { this.m_horizontalLayoutGroup = this.m_scrollRectContentsRT.GetComponentInChildren <HorizontalLayoutGroup>(); }
// Use this for initialization void Start() { layout = this.GetComponent <HorizontalLayoutGroup> (); }
private void CreateCategoryHeader(GameObject parent, GameObject headerArea) { CategoryHeader = Object.Instantiate(_optionsPanel, Canvas.transform); CategoryHeader.GetComponent <RectTransform>().anchorMin = new Vector2(0.275f, 0.86f); CategoryHeader.GetComponent <RectTransform>().anchorMax = new Vector2(1f, 1f); CategoryHeader.SetActive(false); CategoryHeader.name = "Category Headers"; Object.DestroyImmediate(CategoryHeader.transform.Find("Scroll View").Find("Viewport").Find("VerticalLayout").gameObject); Object.DestroyImmediate(CategoryHeader.transform.Find("Scroll View").Find("Scrollbar Vertical").gameObject); GameObject headers = Object.Instantiate(headerArea, CategoryHeader.transform.Find("Scroll View").Find("Viewport")); headers.name = "Categories (JUICED)"; Object.DestroyImmediate(headers.GetComponent <OnEnableEvent>()); Object.DestroyImmediate(headers.GetComponent <AwakeEvent>()); RectTransform rt = headers.GetComponent <RectTransform>(); rt.pivot = new Vector2(0.5f, 0.5f); rt.anchorMin = new Vector2(0f, 0.2f); rt.anchorMax = new Vector2(0f, 0.8f); rt.anchoredPosition = new Vector2(0, 0); var localPosition = headers.transform.localPosition; localPosition = new Vector3(localPosition.x, -47f, localPosition.z); headers.transform.localPosition = localPosition; headers.GetComponent <CanvasGroup>().alpha = 1; RectTransform[] oldButtons = headers.GetComponentsInChildren <RectTransform>(); foreach (var oldButton in oldButtons) { if (oldButton == null) { continue; } if (oldButton != headers.GetComponent <RectTransform>()) { Object.DestroyImmediate(oldButton.gameObject); } } CategoryHeaderHighlight = Object.Instantiate(parent.GetComponent <HGHeaderNavigationController>().headerHighlightObject, parent.GetComponent <HGHeaderNavigationController>().headerHighlightObject.transform.parent); CategoryHeaderHighlight.SetActive(false); HGHeaderNavigationController categoryController = headers.AddComponent <HGHeaderNavigationController>(); categoryController.headerHighlightObject = CategoryHeaderHighlight; categoryController.unselectedTextColor = Color.white; categoryController.makeSelectedHeaderButtonNoninteractable = true; var categoryViewPortHeaderRectTransform = CategoryHeader.transform.Find("Scroll View").Find("Viewport").gameObject.GetComponent <RectTransform>(); categoryViewPortHeaderRectTransform.anchorMin = new Vector2(0.11f, 0); categoryViewPortHeaderRectTransform.anchorMax = new Vector2(0.89f, 1); UISkinData skinData = CategoryHeader.transform.Find("Scroll View").GetComponent <ScrollRectSkinController>().skinData; UILayerKey layerKey = CategoryHeader.transform.Find("Scroll View").GetComponent <HGScrollRectHelper>().requiredTopLayer; Object.DestroyImmediate(CategoryHeader.transform.Find("Scroll View").GetComponent <ScrollRectSkinController>()); Object.DestroyImmediate(CategoryHeader.transform.Find("Scroll View").GetComponent <HGScrollRectHelper>()); Object.DestroyImmediate(CategoryHeader.transform.Find("Scroll View").GetComponent <ScrollRect>()); CategoryScrollRect categoryScrollRect = CategoryHeader.transform.Find("Scroll View").gameObject.AddComponent <CategoryScrollRect>(); categoryScrollRect.inertia = false; categoryScrollRect.content = headers.GetComponent <RectTransform>(); categoryScrollRect.content.pivot = new Vector2(0, 0.5f); categoryScrollRect.horizontal = true; categoryScrollRect.vertical = false; categoryScrollRect.movementType = ScrollRect.MovementType.Unrestricted; categoryScrollRect.viewport = categoryViewPortHeaderRectTransform; categoryScrollRect.horizontalScrollbar = null; CategoryHeader.transform.Find("Scroll View").gameObject.AddComponent <HGScrollRectHelper>().requiredTopLayer = layerKey; CategoryHeader.transform.Find("Scroll View").gameObject.AddComponent <ScrollRectSkinController>().skinData = skinData; ContentSizeFitter sizeFitter = headers.AddComponent <ContentSizeFitter>(); sizeFitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; sizeFitter.verticalFit = ContentSizeFitter.FitMode.Unconstrained; HorizontalLayoutGroup hlg = headers.GetComponent <HorizontalLayoutGroup>(); hlg.enabled = true; hlg.padding = new RectOffset(8, 8, 4, 4); hlg.spacing = 16; hlg.childAlignment = TextAnchor.MiddleCenter; hlg.childControlWidth = true; hlg.childControlHeight = true; hlg.childForceExpandWidth = true; hlg.childForceExpandHeight = true; }
static void SetLocations() { int mapW = 15; int mapH = 15; GameObject tableGO = GameObject.Find("table"); if (tableGO == null) { Debug.LogError("Not found table"); } foreach (Transform child in tableGO.transform) { GameObject.DestroyImmediate(child.gameObject); } Debug.Log("Found table"); RectTransform tableRect = tableGO.GetComponent <RectTransform>(); float cellW = 34; float cellPad = 2; for (int i = 0; i < mapH; i++) { for (int j = 0; j < mapW; j++) { if (Mathf.Abs(i - 7) <= 1 || Mathf.Abs(j - 7) <= 1) { GameObject cellGO = new GameObject(string.Format("{0}x{1}", j, i)); Image cellImg = cellGO.AddComponent <Image>(); cellGO.transform.SetParent(tableRect.transform); cellImg.rectTransform.sizeDelta = new Vector2(cellW - cellPad, cellW - cellPad); cellImg.rectTransform.anchoredPosition = new Vector2(j * cellW - cellW * 7.0f + cellPad, i * cellW - cellW * 7.0f - cellPad); cellImg.color = new Color(1.0f, 0.0f, 0.0f, 0.5f); HorizontalLayoutGroup cellLayout = cellGO.AddComponent <HorizontalLayoutGroup>(); cellLayout.childAlignment = TextAnchor.MiddleCenter; cellLayout.childControlWidth = true; cellLayout.childForceExpandWidth = true; cellLayout.childControlHeight = true; cellLayout.childForceExpandHeight = true; cellLayout.padding = new RectOffset(10, 10, 0, 0); } } } Vector2[] spotPos = { new Vector2(-cellW * 3.9f, -cellW * 6.3f), new Vector2(-cellW * 3.9f, cellW * 2.7f), new Vector2(cellW * 5.2f, cellW * 2.7f), new Vector2(cellW * 5.2f, -cellW * 6.3f), }; cellW = 40; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { GameObject cellGO = new GameObject(string.Format("spot_{0}x{1}", i, j)); Image cellImg = cellGO.AddComponent <Image>(); cellGO.transform.SetParent(tableRect.transform); cellImg.rectTransform.sizeDelta = new Vector2(cellW - cellPad, cellW - cellPad); cellImg.rectTransform.anchoredPosition = spotPos[i] + new Vector2((j - 2.0f) * cellW, 0); cellImg.color = new Color(1.0f, 0.0f, 0.0f, 0.5f); } } }
public void Initiate(DynamicScrollRect scrollRect, T[] infoList, int startIndex, GameObject objReference, bool createMoreIfNeeded = true, int?forceAmount = null) { mScrollRect = scrollRect; if (mScrollRect == null) { throw new Exception("No scroll rect in gameObject."); } if (objReference == null) { throw new Exception("No Reference GameObject setted."); } this.infoList = infoList; mScrollRect.onValueChanged.AddListener(OnScroll); mScrollRect.onBeginDrag.AddListener(OnBeginDrag); mScrollRect.onEndDrag.AddListener(OnEndDrag); mMovementType = mScrollRect.movementType; mScrollRect.realMovementType = mScrollRect.movementType; mScrollRect.movementType = ScrollRect.MovementType.Unrestricted; if (mScrollRect.content.GetComponent <VerticalLayoutGroup>() != null) { mVerticalLayoutGroup = mScrollRect.content.GetComponent <VerticalLayoutGroup>(); mVerticalLayoutGroup.spacing = spacing; } if (mScrollRect.content.GetComponent <HorizontalLayoutGroup>() != null) { mHorizontalLayoutGroup = mScrollRect.content.GetComponent <HorizontalLayoutGroup>(); mHorizontalLayoutGroup.spacing = spacing; } if (mScrollRect.content.GetComponent <GridLayoutGroup>() != null) { mGridLayoutGroup = mScrollRect.content.GetComponent <GridLayoutGroup>(); mGridLayoutGroup.spacing = new Vector2(spacing, spacing); } if (mScrollRect.content.GetComponent <ContentSizeFitter>() != null) { mContentSizeFitter = mScrollRect.content.GetComponent <ContentSizeFitter>(); } mIsHorizontal = mScrollRect.horizontal; mIsVertical = mScrollRect.vertical; objectPool.createMoreIfNeeded = createMoreIfNeeded; objectPool.Initialize(forceAmount.HasValue ? forceAmount.Value : 0, objReference, mScrollRect.content); DisableGridComponents(); CreateList(startIndex); objectPool.ForEach(x => x.SetRefreshListAction(RefreshPosition)); if (!mIsHorizontal || !mIsVertical) { return; } Debug.LogError("DynamicScroll doesn't support scrolling in both directions, please choose one direction (horizontal or vertical)"); mIsHorizontal = false; }
private void Awake() => _layout = GetComponent <HorizontalLayoutGroup>();
//設置捲軸區域(協程) //[param] scrollCount = 捲軸數量, visibleCount = 可視圖格數量, elementChainGroup = 各捲軸圖格鍊, isAnimation = 是否啟用動畫 private IEnumerator Cor_SetScrollAreaLayout(int scrollCount, int visibleCount, Vector2 spacing, List <List <ElementImageType> > elementChainGroup, bool isAnimation, LotteryLineSetting lineSetting = null) { //判斷UI介面是否重新調整 RectTransform panelRect = scrollHolder.GetComponent <RectTransform>(); HorizontalLayoutGroup panelLg = scrollHolder.GetComponent <HorizontalLayoutGroup>(); float scrollHeight = panelRect.rect.height - panelLg.padding.top - panelLg.padding.bottom; //取得捲軸區域高度 //設定更新前後布局資料 LayoutSheet originData = new LayoutSheet(0, 0, Vector2.zero, 0); //改變前布局資料 LayoutSheet newData = new LayoutSheet(0, 0, Vector2.zero, 0); //新的布局資料 bool isLayoutReset = false; //布局參數是否重置 bool _isAnimation = isAnimation; //布局更新啟用動畫 if (layoutData.ApplyData == null) //初始化的狀況 { isLayoutReset = true; _isAnimation = false; //初始化時強制不使用動畫 } else if (layoutData.ApplyData.MatchTest(scrollCount, visibleCount, spacing, scrollHeight) == false) //更新參數的狀況 { isLayoutReset = true; originData = layoutData.ApplyData; } if (isLayoutReset) { layoutData.CalculateLayoutData(scrollCount, visibleCount, spacing, scrollHeight, true); //如果有改變則套用新的參數資料 } newData = layoutData.ApplyData; //設定捲軸數量 if (isLayoutReset) { this.scrollCount = scrollCount; //校正Editor參數 //重新設定捲軸數量 SetScrollCount(_isAnimation); } //設定捲軸圖格鍊 if (elementChainGroup == null) //不指定圖格鍊時 { for (int i = 0; i < scrollGroup.Count; i++) { if ((scrollGroup[i].elementChain == null || scrollGroup[i].elementChain.Count == 0) && defaultElementChain != null) //若捲軸沒有設定圖格鍊, 則套用預設圖格鍊 { scrollGroup[i].SetElementChain(defaultElementChain, visibleCount); } if (isLayoutReset) //重新調整布局 { scrollGroup[i].SetElementChain(null, visibleCount); //若可視圖格長度有變動, 則捲軸的尾部也會跟著變動 } } } else //有指定圖格鍊時 { if (elementChainGroup.Count != scrollCount) { throw new System.Exception("[ERROR]圖格鍊數量與捲軸數量不符"); } for (int i = 0; i < scrollGroup.Count; i++) //設定各捲軸的圖格鍊 { scrollGroup[i].SetElementChain(elementChainGroup[i], visibleCount); } } //設置位置偵測器 SetPostionSensor(layoutData.ApplyData.elementPos_leftDown, layoutData.ApplyData.elementPos_rightUp, scrollCount, visibleCount); //中獎線重新設置 LotteryLineManager.Instance.SettingInitialize(lineSetting); //設定可視圖格數&調整UI if (isLayoutReset) { this.visibleElementCount = visibleCount; //校正Editor參數 this.elementSpacing = spacing; //校正Editor參數 for (int i = 0; i < scrollGroup.Count; i++) { if (_isAnimation) //有動畫 { if ((previousSpinResult != null && previousSpinResult.Count > 0) && (originData.VisibleCount != newData.VisibleCount)) //若拉霸結果有儲存紀錄, 且可視圖格數量有改變, 則將slider.value設為0(拉至最下方), 以防動畫演示出現Bug { List <ElementImageType> _nowElements = new List <ElementImageType>(); //該捲軸目前的顯示圖格 for (int j = 0; j < previousSpinResult.Count; j++) { if ((int)previousSpinResult[j].coordinate.x == i) { _nowElements.Add(previousSpinResult[j].elementType); //將目前顯示圖格中X軸(列號)符合的項目加入列表 } } scrollGroup[i].ResetScrollPosition(_nowElements, visibleCount); //重置捲軸 } if (i == scrollGroup.Count - 1) //等待最後一個捲軸的動畫撥放完成 { yield return(StartCoroutine(scrollGroup[i].Cor_SetUILayout(originData, newData, layoutAnimationDuration))); } else { StartCoroutine(scrollGroup[i].Cor_SetUILayout(originData, newData, layoutAnimationDuration)); } } else { StartCoroutine(scrollGroup[i].Cor_SetUILayout(null, layoutData.ApplyData)); //無動畫 } } } yield return(null); }
void createBorders() { int numBorders = System.Enum.GetNames(typeof(zDraggableBorder.Borders)).Length - 2; if (frame == null) { RectTransform frameRect; frame = new GameObject("Frame"); frameRect = frame.AddComponent <RectTransform>(); frameRect.SetParent(transform); frameRect.offsetMax = new Vector2(0, 0); frameRect.offsetMin = new Vector2(0, 0); frameRect.anchorMin = new Vector2(0, 0); frameRect.anchorMax = new Vector2(1, 1); frameRect = frame.GetComponent <RectTransform>(); borderRects = new RectTransform[numBorders]; borders = new zDraggableBorder[numBorders]; GameObject thisSegment; Transform header = null; RectTransform segRect; var le = frame.AddComponent <LayoutElement>(); le.ignoreLayout = true; for (int i = 0; i < numBorders; i++) { thisSegment = new GameObject(((zDraggableBorder.Borders)i).ToString()); segRect = thisSegment.AddComponent <RectTransform>(); segRect.SetParent(frameRect); segRect.offsetMax = new Vector2(0, 0); segRect.offsetMin = new Vector2(0, 0); segRect.anchorMin = new Vector2(0, 0); segRect.anchorMax = new Vector2(1, 1); zDraggableBorder border = thisSegment.AddComponent <zDraggableBorder>(); border.SetDirection((zDraggableBorder.Borders)i); border.SetBorderWidth(borderWidth, headerHeight); border.SetTargetRect(rect); borders[i] = border; borderRects[i] = segRect; if (i == (int)zDraggableBorder.Borders.Drag) { header = thisSegment.transform; HorizontalLayoutGroup headerLayout = thisSegment.AddComponent <HorizontalLayoutGroup>(); headerLayout.childControlWidth = true; headerLayout.childForceExpandWidth = true; } } if (draggableMenu == null) { draggableMenu = Resources.Load("zDraggableMenu") as GameObject; } if (draggableMenu != null) { GameObject thisMenu = Instantiate(draggableMenu, frame.transform); thisMenu.transform.SetParent(frame.transform); thisMenu.GetComponent <RectTransform>().anchoredPosition = Vector3.zero; menuController = thisMenu.GetComponent <zDraggableMenuController>(); } else { Debug.Log("no menu"); } } for (int i = 0; i < numBorders; i++) { borders[i].SetDirection((zDraggableBorder.Borders)i); if (i == (int)zDraggableBorder.Borders.L || i == (int)zDraggableBorder.Borders.R) { if (useLineGraphics) { borders[i].SetImage(zResourceLoader.lineV); } else { borders[i].SetImage(null); } } if (i == (int)zDraggableBorder.Borders.T || i == (int)zDraggableBorder.Borders.B) { if (useLineGraphics) { borders[i].SetImage(zResourceLoader.lineH); } else { borders[i].SetImage(null); } } borders[i].SetBorderWidth(borderWidth, headerHeight); } }
private void DrawMarker(string markerName, string markerValue, Vector2 markerPosition, Sprite markerSprite, Vector2 markerSize, Color markerColor) { GameObject marker = FindChild(markerName); if (marker == null) { marker = new GameObject(markerName); marker.transform.SetParent(FindChild("MarkersContainer").transform); marker.AddComponent <RectTransform>(); marker.AddComponent <Image>(); marker.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0); marker.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0); marker.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); marker.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); marker.AddComponent <ChartMarkerController>(); GameObject background = new GameObject("background"); background.transform.SetParent(marker.transform); CanvasGroup backgroundCG = background.AddComponent <CanvasGroup>(); backgroundCG.alpha = 0; HorizontalLayoutGroup backgroundHLGTmp = background.AddComponent <HorizontalLayoutGroup>(); backgroundHLGTmp.childForceExpandHeight = false; backgroundHLGTmp.childAlignment = TextAnchor.MiddleCenter; backgroundHLGTmp.childControlHeight = true; backgroundHLGTmp.childControlWidth = true; ContentSizeFitter backgroundCSF = background.AddComponent <ContentSizeFitter>(); backgroundCSF.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; backgroundCSF.verticalFit = ContentSizeFitter.FitMode.PreferredSize; background.AddComponent <Image>(); background.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); background.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); background.GetComponent <RectTransform>().localPosition = markersFieldOffset; background.SetActive(false); GameObject markerLabel = new GameObject("label"); Text markerLabelTextTmp = markerLabel.AddComponent <Text>(); markerLabelTextTmp.text = markerValue; markerLabelTextTmp.alignment = TextAnchor.MiddleCenter; markerLabel.transform.SetParent(background.transform); markerLabel.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1); markerLabel.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); markerLabel.GetComponent <RectTransform>().localPosition = markersLabelsOffset; marker.GetComponent <ChartMarkerController>().markerLabel = markerLabel; marker.GetComponent <ChartMarkerController>().background = background; } ChartMarkerController markerController = marker.GetComponent <ChartMarkerController>(); Text markerLabelText = markerController.markerLabel.GetComponentInChildren <Text>(); Image backgroundImage = markerController.background.GetComponent <Image>(); markerController.interactionType = markerInteractionType; backgroundImage.sprite = markersLabelsBackground; Image markerImage = marker.GetComponent <Image>(); RectTransform markerRT = marker.GetComponent <RectTransform>(); markerImage.sprite = markerSprite; markerImage.color = markerColor; markerRT.anchoredPosition = markerPosition; markerRT.sizeDelta = markerSize; markerLabelText.fontSize = markersLabelsFontSize; markerLabelText.font = markersLabelsFont != null ? markersLabelsFont : Resources.GetBuiltinResource <Font>("Arial.ttf"); markerLabelText.color = markersLabelsFontColor; if (showValuePrefix) { markerLabelText.text = valuePrefix + " " + markerValue; } else { markerLabelText.text = markerValue; } backgroundImage.GetComponent <RectTransform>().localPosition = markersFieldOffset; HorizontalLayoutGroup backgroundHLG = backgroundImage.GetComponent <HorizontalLayoutGroup>(); if (backgroundHLG != null) { backgroundHLG.padding.left = (int)markersLabelsOffset.x; backgroundHLG.padding.bottom = (int)markersLabelsOffset.y; } }
private void OnEnable() { _horizontalLayoutGroup = GetComponent <HorizontalLayoutGroup>(); _rectTransform = GetComponent <RectTransform>(); _parentRectTransform = _rectTransform.parent.GetComponent <RectTransform>(); }
protected override void AddComponents() { // Add the gameObjects var viewportGO = InstanciateObject("Viewport", gameObject); var containerGO = InstanciateObject("Container", viewportGO); var vScrollbarGO = InstanciateScrollbar("Vertical Scrollbar", gameObject, out vScrollbarCmp, out vScrollbarImageCmp, out vScrollbarHandleImageCmp); var hScrollbarGO = InstanciateScrollbar("Horizontal Scrollbar", gameObject, out hScrollbarCmp, out hScrollbarImageCmp, out hScrollbarHandleImageCmp); // Set virtual parent virtualChildContainer = containerGO; // Add Components scrollRectCmp = propsScrollRect().Set(gameObject); rectMask2Cmp = propsRectMask2D().Set(viewportGO); horizontalLayoutCmp = propsHorizontalLayoutGroup().Set(containerGO); contentSizeCmp = propsContentSizeFilter().Set(containerGO); propsVScrollbarImage().SetAllExceptType(vScrollbarImageCmp); propsVScrollbar().Set(vScrollbarCmp); propsVScrollbarHandleImageCmp().SetAllExceptType(vScrollbarHandleImageCmp); propsHScrollbarImage().SetAllExceptType(hScrollbarImageCmp); propsHScrollbar().Set(hScrollbarCmp); propsHScrollbarHandleImageCmp().SetAllExceptType(hScrollbarHandleImageCmp); // Relations scrollRectCmp.content = containerGO.GetComponent <RectTransform>(); scrollRectCmp.viewport = viewportGO.GetComponent <RectTransform>(); scrollRectCmp.horizontalScrollbar = hScrollbarCmp; scrollRectCmp.verticalScrollbar = vScrollbarCmp; // Obtain percentage size SetReferenceSize(new RectTransformSetter()); new RectTransformBSetter() { pivot = new Vector2(0f, 1f), localPosition = new Vector2(0f, 0f), anchorMin = new Vector2(0f, 0f), anchorMax = new Vector2(1, 1f), sizeDelta = new Vector2(0, 0), }.SetOrSearchBySizeDelta(viewportGO); new RectTransformBSetter() { pivot = new Vector2(0f, 1f), localPosition = new Vector2(0, 0f), anchorMin = new Vector2(0, 0f), anchorMax = new Vector2(1, 1f), offsetMin = new Vector2(0, 0f), offsetMax = new Vector2(0, 0f), }.SetOrSearchByAnchors(containerGO); new RectTransformBSetter() { pivot = new Vector2(1f, 1f), localPosition = new Vector2(0f, 0), anchorMin = new Vector2(1, 0f), anchorMax = new Vector2(1, 1f), sizeDelta = new Vector2(20, -20f), // 20,-20 }.SetOrSearchBySizeDelta(vScrollbarGO); new RectTransformBSetter() { pivot = new Vector2(0f, 0f), localPosition = new Vector2(0f, 0), anchorMin = new Vector2(0f, 0f), anchorMax = new Vector2(1f, 0f), sizeDelta = new Vector2(0, 20f), // 0,20 }.SetOrSearchBySizeDelta(hScrollbarGO); }
private static void CreateDestroyWindow(Transform parent, ref InGameInventoryManager inGameManager, ref Settings settings) { GameObject destroyWindow = new GameObject("Destroy Window"); inGameManager.destroyWindow = destroyWindow; destroyWindow.transform.SetParent(parent); Image destroyWindowBG = destroyWindow.AddComponent <Image>(); destroyWindowBG.color = new Color(0, 0, 0, .5f); destroyWindowBG.sprite = settings.destroyWindowBGSprite; RectTransform destroyWindowRect = destroyWindow.GetComponent <RectTransform>(); destroyWindowRect.sizeDelta = new Vector2(600, 200); destroyWindowRect.localPosition = Vector2.zero; VerticalLayoutGroup destroyWindowLayout = destroyWindow.AddComponent <VerticalLayoutGroup>(); destroyWindowLayout.padding.left = 20; destroyWindowLayout.padding.right = 20; destroyWindowLayout.childControlWidth = true; destroyWindowLayout.childControlHeight = true; GameObject destroyWindowTextHolder = new GameObject("Text"); destroyWindowTextHolder.transform.SetParent(destroyWindow.transform); TextMeshProUGUI destroyWindowText = destroyWindowTextHolder.AddComponent <TextMeshProUGUI>(); destroyWindowText.text = DESTROY_WINDOW_TEXT; destroyWindowText.color = Color.yellow; destroyWindowText.fontSize = 32; RectTransform destroyWindowTextHolderRect = destroyWindowTextHolder.GetComponent <RectTransform>(); destroyWindowTextHolderRect.anchorMin = new Vector2(0, 1); destroyWindowTextHolderRect.anchorMax = new Vector2(1, 1); destroyWindowTextHolderRect.pivot = new Vector2(.5f, 1); destroyWindowTextHolderRect.sizeDelta = new Vector2(0, 100); GameObject buttonHolder = new GameObject("Button Holder"); buttonHolder.transform.SetParent(destroyWindow.transform); RectTransform buttonHolderRect = buttonHolder.AddComponent <RectTransform>(); buttonHolderRect.anchorMin = Vector2.zero; buttonHolderRect.anchorMax = new Vector2(1, 0); buttonHolderRect.pivot = new Vector2(.5f, 0); buttonHolderRect.sizeDelta = new Vector2(0, 100); buttonHolderRect.localPosition = Vector2.zero; buttonHolderRect.anchoredPosition = Vector2.zero; LayoutElement buttonHolderLayoutElement = buttonHolder.AddComponent <LayoutElement>(); buttonHolderLayoutElement.preferredHeight = 0; HorizontalLayoutGroup buttonHolderLayout = buttonHolder.AddComponent <HorizontalLayoutGroup>(); buttonHolderLayout.childAlignment = TextAnchor.MiddleCenter; buttonHolderLayout.childControlHeight = true; buttonHolderLayout.childControlWidth = true; buttonHolderLayout.padding.left = 50; buttonHolderLayout.padding.right = 50; buttonHolderLayout.padding.top = 15; buttonHolderLayout.padding.bottom = 15; buttonHolderLayout.spacing = 30; inGameManager.cancelDestroyButton = CreateButtonInLayout("Cancel Button", "Cancel", buttonHolder.transform); inGameManager.cancelDestroyButton.GetComponent <Image>().sprite = settings.destroyWindowButtonsSprite; inGameManager.destroyItemButton = CreateButtonInLayout("Yes Button", "Yes", buttonHolder.transform); inGameManager.destroyItemButton.GetComponent <Image>().sprite = settings.destroyWindowButtonsSprite; }
private void Awake() { m_HorizontalLayoutGroup = GetComponent <HorizontalLayoutGroup>(); }
// 영문 키보드 or 한글 키보드 제작 게임 오브젝트 생성 및 정렬 GameObject MakeKeyBoard(KeyBoardType type, bool set) { // 패널 생성 GameObject panel = new GameObject(type.ToString()); panel.layer = LayerMask.NameToLayer("UI"); panel.AddComponent <CanvasRenderer>(); Image image = panel.AddComponent <Image>(); image.color = Color.white; image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/Background.psd"); image.type = Image.Type.Sliced; //image.sprite = Resources.GetBuiltinResource(typeof(Sprite), "Background.psd") as Sprite; //i.sprite = Resources.Load("Assets/Background") as Sprite; panel.transform.SetParent(mainCanvasObj.transform, false); panelRect = panel.GetComponent <RectTransform>(); panelRect.sizeDelta = new Vector3(resolution.x * 1.05f, resolution.x * 0.4f); panelRect.anchoredPosition3D = new Vector3(0, resolution.x * 1.5f, resolution.x); panelRect.localRotation = Quaternion.Euler(35f, 0f, 0f); // 세로로 정렬할 부모 오브젝트 생성 GameObject vertical = new GameObject("VerticalLayer"); vertical.transform.SetParent(panel.transform); VerticalLayoutGroup vV = vertical.AddComponent <VerticalLayoutGroup>(); vV.spacing = 30f; RectTransform vR = vertical.GetComponent <RectTransform>(); vR.localScale = new Vector3(1, 1, 1); vR.sizeDelta = new Vector3(resolution.x, resolution.x * 0.3f); vR.localRotation = Quaternion.Euler(Vector3.zero); vR.anchoredPosition3D = Vector3.zero; // 버튼 오브젝트 GameObject buttonObj = Resources.Load("Button") as GameObject; // 버튼 리스트 List <Key> buttonList; string[] parse; if (type == KeyBoardType.LowerEng) { parse = EngkeyOrder.Split('|'); buttonList = EngbuttonList; } else if (type == KeyBoardType.Special1) { parse = special1Order.Split('|'); buttonList = SpecialbuttonList; } else { parse = KorKeyOrder.Split('|'); buttonList = KorbuttonList; } int c = 0; // 수평으로 정렬할 빈 오브젝트 5개 생성 GameObject[] a = new GameObject[5]; // 1줄에 버튼 여러개 생성 for (int i = 0; i < 5; i++) { a[i] = new GameObject("HorizotalLayer"); HorizontalLayoutGroup aH = a[i].AddComponent <HorizontalLayoutGroup>(); a[i].transform.SetParent(vertical.transform); RectTransform aR = a[i].GetComponent <RectTransform>(); aR.localScale = new Vector3(1, 1, 1); aR.localRotation = Quaternion.Euler(Vector3.zero); aR.anchoredPosition3D = Vector3.zero; switch (i) { case 0: case 1: for (int j = 0; j < 10; j++) { GameObject button = Instantiate(buttonObj, a[i].transform); button.transform.GetChild(0).GetComponent <Text>().text = parse[c++]; button.transform.GetChild(0).GetComponent <Text>().fontSize = 50; Key k = button.AddComponent <Key>(); button.layer = LayerMask.NameToLayer("UI"); buttonList.Add(k); } aH.spacing = 40f; break; case 2: case 3: int index = 9; if (type == KeyBoardType.Special1 && i == 2) { index = 10; } for (int j = 0; j < index; j++) { GameObject button = Instantiate(buttonObj, a[i].transform); if (parse[c] == "shift") { LayoutElement layout = button.AddComponent <LayoutElement>(); layout.preferredWidth = shiftSize; } else if (parse[c] == "backspace") { LayoutElement layout = button.AddComponent <LayoutElement>(); layout.preferredWidth = backspaceSize; } button.transform.GetChild(0).GetComponent <Text>().text = parse[c++]; button.transform.GetChild(0).GetComponent <Text>().fontSize = 50; Key k = button.AddComponent <Key>(); button.layer = LayerMask.NameToLayer("UI"); buttonList.Add(k); } aH.spacing = 40f; break; case 4: for (int j = 0; j < 6; j++) { GameObject button = Instantiate(buttonObj, a[i].transform); if (parse[c] == "space") { LayoutElement layout = button.AddComponent <LayoutElement>(); layout.preferredWidth = spacebarSize; } else if (parse[c] == "Enter") { LayoutElement layout = button.AddComponent <LayoutElement>(); layout.preferredWidth = enterSize; } button.transform.GetChild(0).GetComponent <Text>().text = parse[c++]; button.transform.GetChild(0).GetComponent <Text>().fontSize = 50; Key k = button.AddComponent <Key>(); button.layer = LayerMask.NameToLayer("UI"); buttonList.Add(k); } aH.spacing = 40f; break; } } panel.SetActive(set); return(panel); }
// Use this for initialization void Start() { ColorBar = transform.Find("ColorBar").gameObject; ColorBar.SetActive(isColorBarShow); layoutGroup = ColorBar.GetComponent <HorizontalLayoutGroup>(); }
/// <summary> /// Create a template game object. /// </summary> public static GameObject CreateTemplate() { GameObject obj = new GameObject(PREFAB_NAME); RectTransform root_rect = obj.AddComponent <RectTransform>(); MyUtilities.Anchor(ref root_rect, MyUtilities.EAnchorPreset.DualStretch, MyUtilities.EAnchorPivot.MiddleCenter, Vector2.zero, Vector2.zero); #if UNITY_EDITOR Animator root_animator = obj.AddComponent <Animator>(); string[] paths = new string[] { "Assets/MyClasses", "Assets/Core/MyClasses", "Assets/Plugin/MyClasses", "Assets/Plugins/MyClasses", "Assets/Framework/MyClasses", "Assets/Frameworks/MyClasses" }; for (int i = 0; i < paths.Length; i++) { if (System.IO.File.Exists(paths[i] + "/Sources/Animations/my_animator_toast_message.controller")) { root_animator.runtimeAnimatorController = (RuntimeAnimatorController)UnityEditor.AssetDatabase.LoadAssetAtPath(paths[i] + "/Sources/Animations/my_animator_toast_message.controller", typeof(RuntimeAnimatorController)); Debug.LogError("[" + typeof(MyUGUIToastMessage).Name + "] CreateTemplate(): please setup \"my_animator_toast\" controller."); Debug.LogError("[" + typeof(MyUGUIToastMessage).Name + "] CreateTemplate(): mapping \"my_animation_toast_message_show\" motion for \"Show\" state."); Debug.LogError("[" + typeof(MyUGUIToastMessage).Name + "] CreateTemplate(): mapping \"my_animation_toast_message_idle\" motion for \"Idle\" state."); Debug.LogError("[" + typeof(MyUGUIToastMessage).Name + "] CreateTemplate(): mapping \"my_animation_toast_message_hide\" motion for \"Hide\" state."); break; } } #endif GameObject container = new GameObject("Container"); container.transform.SetParent(obj.transform, false); RectTransform container_rect = container.AddComponent <RectTransform>(); MyUtilities.Anchor(ref container_rect, MyUtilities.EAnchorPreset.BottomCenter, MyUtilities.EAnchorPivot.BottomCenter, 500, 80, 0, 40); Image container_image = container.AddComponent <Image>(); container_image.color = new Color(0, 0, 0, 0.5f); container_image.raycastTarget = false; LayoutElement container_layout_element = container.AddComponent <LayoutElement>(); container_layout_element.minWidth = 80; container_layout_element.minHeight = 80; HorizontalLayoutGroup container_horizontal_layout_group = container.AddComponent <HorizontalLayoutGroup>(); container_horizontal_layout_group.padding = new RectOffset(20, 20, 20, 20); container_horizontal_layout_group.childAlignment = TextAnchor.MiddleCenter; container_horizontal_layout_group.childControlWidth = true; container_horizontal_layout_group.childControlHeight = true; container_horizontal_layout_group.childForceExpandWidth = true; container_horizontal_layout_group.childForceExpandHeight = true; ContentSizeFitter container_content_size_filter = container.AddComponent <ContentSizeFitter>(); container_content_size_filter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; container_content_size_filter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; CanvasGroup container_canvas_group = container.AddComponent <CanvasGroup>(); container_canvas_group.alpha = 1; container_canvas_group.interactable = false; container_canvas_group.blocksRaycasts = false; GameObject text = new GameObject("Text"); text.transform.SetParent(container.transform, false); Text text_text = text.AddComponent <Text>(); text_text.text = "This is toast message"; text_text.color = Color.white; text_text.font = Resources.GetBuiltinResource <Font>("Arial.ttf"); text_text.fontSize = 50; text_text.alignment = TextAnchor.MiddleCenter; text_text.horizontalOverflow = HorizontalWrapMode.Wrap; text_text.verticalOverflow = VerticalWrapMode.Overflow; text_text.raycastTarget = false; return(obj); }
private void Awake() { _rectTransform = GetComponent <RectTransform>(); _layoutGroup = GetComponent <HorizontalLayoutGroup>(); }
public void ShowMissionResults(int garrMissionID, int missionResultType, bool awardOvermax) { GarrMissionRec record = StaticDB.garrMissionDB.GetRecord(garrMissionID); if (record == null) { return; } this.RegisterMainScriptObjEvents(); this.m_missionResultsDisplayCanvasGroupAutoFadeOut.Reset(); this.m_currentResultType = (MissionResultType)missionResultType; this.m_followerExperienceDisplayArea.SetActive(false); this.m_attemptedAutoComplete = false; this.m_garrMissionID = garrMissionID; this.m_darknessBG.SetActive(true); this.m_popupView.SetActive(true); this.m_bonusLootDisplay.SetActive(false); if (this.missionFollowerSlotGroup != null) { MissionFollowerSlot[] componentsInChildren = this.missionFollowerSlotGroup.GetComponentsInChildren <MissionFollowerSlot>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i] != null && componentsInChildren[i] != this.missionFollowerSlotGroup.transform) { componentsInChildren[i].gameObject.transform.SetParent(null); Object.Destroy(componentsInChildren[i].gameObject); } } } MissionEncounter[] componentsInChildren2 = this.enemyPortraitsGroup.GetComponentsInChildren <MissionEncounter>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if (componentsInChildren2[j] != null && componentsInChildren2[j] != this.enemyPortraitsGroup.transform) { componentsInChildren2[j].gameObject.transform.SetParent(null); Object.Destroy(componentsInChildren2[j].gameObject); } } if (this.treasureChestHorde != null && this.treasureChestAlliance != null) { if (GarrisonStatus.Faction() == PVP_FACTION.HORDE) { this.treasureChestHorde.SetActive(true); this.treasureChestAlliance.SetActive(false); } else { this.treasureChestHorde.SetActive(false); this.treasureChestAlliance.SetActive(true); } } WrapperGarrisonMission wrapperGarrisonMission = PersistentMissionData.missionDictionary[garrMissionID]; this.m_missionStartedTime = wrapperGarrisonMission.StartTime; this.m_missionDurationInSeconds = wrapperGarrisonMission.MissionDuration; for (int k = 0; k < wrapperGarrisonMission.Encounters.Count; k++) { GameObject gameObject = Object.Instantiate <GameObject>(this.missionEncounterPrefab); gameObject.transform.SetParent(this.enemyPortraitsGroup.transform, false); MissionEncounter component = gameObject.GetComponent <MissionEncounter>(); int garrMechanicID = (wrapperGarrisonMission.Encounters[k].MechanicIDs.Count <= 0) ? 0 : wrapperGarrisonMission.Encounters[k].MechanicIDs[0]; component.SetEncounter(wrapperGarrisonMission.Encounters[k].EncounterID, garrMechanicID); } this.missionNameText.text = record.Name; this.missionLocationText.text = record.Location; this.missioniLevelText.text = StaticDB.GetString("ITEM_LEVEL_ABBREVIATION", null) + " " + record.TargetItemLevel; GarrMissionTypeRec record2 = StaticDB.garrMissionTypeDB.GetRecord((int)record.GarrMissionTypeID); this.missionTypeImage.overrideSprite = TextureAtlas.instance.GetAtlasSprite((int)record2.UiTextureAtlasMemberID); if (this.missionFollowerSlotGroup != null) { int num = 0; while ((long)num < (long)((ulong)record.MaxFollowers)) { GameObject gameObject2 = Object.Instantiate <GameObject>(this.missionFollowerSlotPrefab); gameObject2.transform.SetParent(this.missionFollowerSlotGroup.transform, false); MissionFollowerSlot component2 = gameObject2.GetComponent <MissionFollowerSlot>(); component2.m_enemyPortraitsGroup = this.enemyPortraitsGroup; num++; } } if (record.UiTextureKitID > 0u) { UiTextureKitRec record3 = StaticDB.uiTextureKitDB.GetRecord((int)record.UiTextureKitID); this.m_scrollingEnvironment_Back.enabled = false; this.m_scrollingEnvironment_Mid.enabled = false; this.m_scrollingEnvironment_Fore.enabled = false; int uitextureAtlasMemberID = TextureAtlas.GetUITextureAtlasMemberID("_" + record3.KitPrefix + "-Back"); if (uitextureAtlasMemberID > 0) { Sprite atlasSprite = TextureAtlas.instance.GetAtlasSprite(uitextureAtlasMemberID); if (atlasSprite != null) { this.m_scrollingEnvironment_Back.enabled = true; this.m_scrollingEnvironment_Back.sprite = atlasSprite; } } int uitextureAtlasMemberID2 = TextureAtlas.GetUITextureAtlasMemberID("_" + record3.KitPrefix + "-Mid"); if (uitextureAtlasMemberID2 > 0) { Sprite atlasSprite2 = TextureAtlas.instance.GetAtlasSprite(uitextureAtlasMemberID2); if (atlasSprite2 != null) { this.m_scrollingEnvironment_Mid.enabled = true; this.m_scrollingEnvironment_Mid.sprite = atlasSprite2; } } int uitextureAtlasMemberID3 = TextureAtlas.GetUITextureAtlasMemberID("_" + record3.KitPrefix + "-Fore"); if (uitextureAtlasMemberID3 > 0) { Sprite atlasSprite3 = TextureAtlas.instance.GetAtlasSprite(uitextureAtlasMemberID3); if (atlasSprite3 != null) { this.m_scrollingEnvironment_Fore.enabled = true; this.m_scrollingEnvironment_Fore.sprite = atlasSprite3; } } } else { Debug.LogWarning(string.Concat(new object[] { "DATA ERROR: Mission UITextureKit Not Set for mission ID:", record.ID, " - ", record.Name })); Debug.LogWarning("This means the scrolling background images will show the wrong location"); } if (this.m_lootGroupObj == null || this.m_missionRewardDisplayPrefab == null) { return; } MissionRewardDisplay[] componentsInChildren3 = this.m_lootGroupObj.GetComponentsInChildren <MissionRewardDisplay>(true); for (int l = 0; l < componentsInChildren3.Length; l++) { if (componentsInChildren3[l] != null) { componentsInChildren3[l].gameObject.transform.SetParent(null); Object.Destroy(componentsInChildren3[l].gameObject); } } if (missionResultType == 1) { PersistentFollowerData.ClearPreMissionFollowerData(); } List <WrapperGarrisonFollower> list = new List <WrapperGarrisonFollower>(); MissionFollowerSlot[] componentsInChildren4 = this.missionFollowerSlotGroup.GetComponentsInChildren <MissionFollowerSlot>(true); int num2 = 0; foreach (WrapperGarrisonFollower wrapperGarrisonFollower in PersistentFollowerData.followerDictionary.Values) { if (wrapperGarrisonFollower.CurrentMissionID == garrMissionID) { componentsInChildren4[num2++].SetFollower(wrapperGarrisonFollower.GarrFollowerID); if (missionResultType == 1) { PersistentFollowerData.CachePreMissionFollower(wrapperGarrisonFollower); } list.Add(wrapperGarrisonFollower); } } this.UpdateMissionStatus(garrMissionID); foreach (MissionFollowerSlot missionFollowerSlot in componentsInChildren4) { missionFollowerSlot.InitHeartPanel(); } MissionRewardDisplay.InitMissionRewards(this.m_missionRewardDisplayPrefab.gameObject, this.m_lootGroupObj.transform, wrapperGarrisonMission.Rewards); if (record.OvermaxRewardPackID > 0 && wrapperGarrisonMission.OvermaxRewards.Count > 0) { this.m_bonusLootDisplay.SetActive(true); WrapperGarrisonMissionReward wrapperGarrisonMissionReward = wrapperGarrisonMission.OvermaxRewards[0]; if (wrapperGarrisonMissionReward.ItemID > 0) { this.m_bonusMissionRewardDisplay.InitReward(MissionRewardDisplay.RewardType.item, wrapperGarrisonMissionReward.ItemID, (int)wrapperGarrisonMissionReward.ItemQuantity, 0, wrapperGarrisonMissionReward.ItemFileDataID); } else if (wrapperGarrisonMissionReward.FollowerXP > 0u) { this.m_bonusMissionRewardDisplay.InitReward(MissionRewardDisplay.RewardType.followerXP, 0, (int)wrapperGarrisonMissionReward.FollowerXP, 0, 0); } else if (wrapperGarrisonMissionReward.CurrencyQuantity > 0u) { if (wrapperGarrisonMissionReward.CurrencyType == 0) { this.m_bonusMissionRewardDisplay.InitReward(MissionRewardDisplay.RewardType.gold, 0, (int)(wrapperGarrisonMissionReward.CurrencyQuantity / 10000u), 0, 0); } else { CurrencyTypesRec record4 = StaticDB.currencyTypesDB.GetRecord(wrapperGarrisonMissionReward.CurrencyType); int rewardQuantity = (int)((ulong)wrapperGarrisonMissionReward.CurrencyQuantity / (ulong)(((record4.Flags & 8u) == 0u) ? 1L : 100L)); this.m_bonusMissionRewardDisplay.InitReward(MissionRewardDisplay.RewardType.currency, wrapperGarrisonMissionReward.CurrencyType, rewardQuantity, 0, 0); } } } this.m_timeUntilFadeOutMissionDetailsDisplay = this.m_missionDetailsFadeOutDelay; this.m_timeUntilShowFollowerExperienceDisplays = this.m_experienceDisplayInitialEntranceDelay; if (missionResultType == 2) { this.InitFollowerExperienceDisplays(); this.m_missionInProgressMessage.SetActive(false); this.m_missionSuccessMessage.SetActive(true); this.m_missionFailMessage.SetActive(false); if (this.m_fancyEntrance != null) { Object.Destroy(this.m_fancyEntrance); iTween.Stop(this.m_missionSuccessMessage); this.m_missionSuccessMessage.transform.localScale = Vector3.one; iTween.Stop(this.m_missionFailMessage); this.m_missionFailMessage.transform.localScale = Vector3.one; } this.m_missionSuccessMessage.SetActive(false); this.m_fancyEntrance = this.m_missionSuccessMessage.AddComponent <FancyEntrance>(); this.m_fancyEntrance.m_fadeInCanvasGroup = this.m_missionSuccessMessage.GetComponent <CanvasGroup>(); this.m_fancyEntrance.m_fadeInTime = this.m_messageFadeInTime; this.m_fancyEntrance.m_punchScale = this.m_messagePunchScale; this.m_fancyEntrance.m_punchScaleAmount = this.m_messagePunchScaleAmount; this.m_fancyEntrance.m_punchScaleDuration = this.m_messagePunchScaleDuration; this.m_fancyEntrance.m_timeToDelayEntrance = this.m_messageTimeToDelayEntrance; this.m_fancyEntrance.m_activateOnEnable = true; this.m_fancyEntrance.m_objectToNotifyOnBegin = base.gameObject; this.m_fancyEntrance.m_notifyOnBeginCallbackName = "OnShowSuccessMessage"; this.m_missionSuccessMessage.SetActive(true); MissionRewardDisplay[] componentsInChildren5 = this.m_lootGroupObj.GetComponentsInChildren <MissionRewardDisplay>(true); for (int n = 0; n < componentsInChildren5.Length; n++) { componentsInChildren5[n].ShowResultSuccess(this.m_lootEffectInitialDelay + this.m_lootEffectDelay * (float)n); } if (this.m_bonusLootChance > 0) { iTween.ValueTo(base.gameObject, iTween.Hash(new object[] { "name", "ShakeIt", "from", 0.3f, "to", 1f, "delay", this.m_bonusLootShakeInitialDelay, "time", this.m_bonusLootShakeDuration, "onupdate", "OnBonusLootShakeUpdate", "oncomplete", "OnBonusLootShakeComplete" })); } if (awardOvermax) { this.m_bonusMissionRewardDisplay.ShowResultSuccess(this.m_lootEffectInitialDelay + this.m_lootEffectDelay * (float)componentsInChildren5.Length); } else { this.m_bonusMissionRewardDisplay.ShowResultFail(this.m_lootEffectInitialDelay + this.m_lootEffectDelay * (float)componentsInChildren5.Length); } } if (missionResultType == 3) { this.InitFollowerExperienceDisplays(); this.m_missionInProgressMessage.SetActive(false); this.m_missionSuccessMessage.SetActive(false); this.m_missionFailMessage.SetActive(true); if (this.m_fancyEntrance != null) { Object.Destroy(this.m_fancyEntrance); iTween.Stop(this.m_missionSuccessMessage); this.m_missionSuccessMessage.transform.localScale = Vector3.one; iTween.Stop(this.m_missionFailMessage); this.m_missionFailMessage.transform.localScale = Vector3.one; } this.m_missionFailMessage.SetActive(false); this.m_fancyEntrance = this.m_missionFailMessage.AddComponent <FancyEntrance>(); this.m_fancyEntrance.m_fadeInCanvasGroup = this.m_missionFailMessage.GetComponent <CanvasGroup>(); this.m_fancyEntrance.m_fadeInTime = this.m_messageFadeInTime; this.m_fancyEntrance.m_punchScale = this.m_messagePunchScale; this.m_fancyEntrance.m_punchScaleAmount = this.m_messagePunchScaleAmount; this.m_fancyEntrance.m_punchScaleDuration = this.m_messagePunchScaleDuration; this.m_fancyEntrance.m_timeToDelayEntrance = this.m_messageTimeToDelayEntrance; this.m_fancyEntrance.m_activateOnEnable = true; this.m_fancyEntrance.m_objectToNotifyOnBegin = base.gameObject; this.m_fancyEntrance.m_notifyOnBeginCallbackName = "OnShowFailMessage"; this.m_missionFailMessage.SetActive(true); MissionRewardDisplay[] componentsInChildren6 = this.m_lootGroupObj.GetComponentsInChildren <MissionRewardDisplay>(true); for (int num3 = 0; num3 < componentsInChildren6.Length; num3++) { componentsInChildren6[num3].ShowResultFail(this.m_lootEffectInitialDelay); } this.m_bonusMissionRewardDisplay.ShowResultFail(this.m_lootEffectInitialDelay); } if (missionResultType == 0) { this.m_missionInProgressMessage.SetActive(true); this.m_missionSuccessMessage.SetActive(false); this.m_missionFailMessage.SetActive(false); this.m_bonusMissionRewardDisplay.ClearResults(); } if (missionResultType == 1) { this.m_missionInProgressMessage.SetActive(false); this.m_missionSuccessMessage.SetActive(false); this.m_missionFailMessage.SetActive(false); FollowerExperienceDisplay[] componentsInChildren7 = this.m_followerExperienceDisplayArea.GetComponentsInChildren <FollowerExperienceDisplay>(true); foreach (FollowerExperienceDisplay followerExperienceDisplay in componentsInChildren7) { followerExperienceDisplay.gameObject.transform.SetParent(null); Object.Destroy(followerExperienceDisplay.gameObject); } } if (this.m_partyBuffGroup == null) { return; } AbilityDisplay[] componentsInChildren8 = this.m_partyBuffGroup.GetComponentsInChildren <AbilityDisplay>(true); foreach (AbilityDisplay abilityDisplay in componentsInChildren8) { abilityDisplay.gameObject.transform.SetParent(null); Object.Destroy(abilityDisplay.gameObject); } int adjustedMissionDuration = GeneralHelpers.GetAdjustedMissionDuration(record, list, this.enemyPortraitsGroup); int num6 = 0; foreach (WrapperGarrisonFollower wrapperGarrisonFollower2 in PersistentFollowerData.followerDictionary.Values) { if (wrapperGarrisonFollower2.CurrentMissionID == garrMissionID) { int[] buffsForCurrentMission = GeneralHelpers.GetBuffsForCurrentMission(wrapperGarrisonFollower2.GarrFollowerID, garrMissionID, this.missionFollowerSlotGroup, adjustedMissionDuration); num6 += buffsForCurrentMission.Length; foreach (int garrAbilityID in buffsForCurrentMission) { GameObject gameObject3 = Object.Instantiate <GameObject>(this.m_mechanicEffectDisplayPrefab); gameObject3.transform.SetParent(this.m_partyBuffGroup.transform, false); AbilityDisplay component3 = gameObject3.GetComponent <AbilityDisplay>(); component3.SetAbility(garrAbilityID, false, false, null); } } } if (num6 > 8) { this.m_partyBuffsText.text = string.Empty; } else { this.m_partyBuffsText.text = StaticDB.GetString("PARTY_BUFFS", null); } HorizontalLayoutGroup component4 = this.m_partyBuffGroup.GetComponent <HorizontalLayoutGroup>(); if (component4 != null) { if (num6 > 10 && Main.instance.IsNarrowScreen()) { component4.spacing = 3f; } else { component4.spacing = 6f; } } this.m_partyBuffGroup.SetActive(num6 > 0); }
public void InitUI() { //assign transform by your ui framework //transform = ; scrollrect_m_MatchList = transform.Find("m_MatchListRoot/m_MatchList").GetComponent <ScrollRect>(); image_m_MatchList = transform.Find("m_MatchListRoot/m_MatchList").GetComponent <Image>(); mask_Viewport = transform.Find("m_MatchListRoot/m_MatchList/Viewport").GetComponent <Mask>(); image_Viewport = transform.Find("m_MatchListRoot/m_MatchList/Viewport").GetComponent <Image>(); contentsizefitter_Content = transform.Find("m_MatchListRoot/m_MatchList/Viewport/Content").GetComponent <ContentSizeFitter>(); verticallayoutgroup_Content = transform.Find("m_MatchListRoot/m_MatchList/Viewport/Content").GetComponent <VerticalLayoutGroup>(); //image_CountDownDiTu_26 = transform.Find("m_TopNode/m_CountDownNode/CountDownDiTu_26").GetComponent<Image>(); text_GameTimeText3_21 = transform.Find("m_MatchGroundNode/m_GroundState/m_CountDownNode/GameTimeText3_21").GetComponent <Text>(); //text_GameTimeText2_22 = transform.Find("m_TopNode/m_CountDownNode/GameTimeText2_22").GetComponent<Text>(); //image_TimePic_29 = transform.Find("m_TopNode/m_CountDownNode/TimePic_29").GetComponent<Image>(); //slider_m_MatchProgress = transform.Find("m_MatchGroundNode/m_GroundState/m_MatchProgress").GetComponent<Slider>(); rectTran_Identification = transform.Find("m_MatchGroundNode/m_GroundState/RunWay/Identification").GetComponent <RectTransform>(); RenderRealPathHPEffect = transform.Find("m_MatchGroundNode/m_GroundState/RunWay/RenderRealPathHPEffect").GetComponent <RawImage>(); //image_Background = transform.Find("m_TopNode/m_MatchProgress/m_MatchProgress/Background").GetComponent<Image>(); //image_Fill = transform.Find("m_TopNode/m_MatchProgress/m_MatchProgress/Fill Area/Fill").GetComponent<Image>(); //image_Handle = transform.Find("m_TopNode/m_MatchProgress/m_MatchProgress/Handle Slide Area/Handle").GetComponent<Image>(); //image_Point1 = transform.Find("m_TopNode/m_MatchProgress/Point1").GetComponent<Image>(); //image_Point2 = transform.Find("m_TopNode/m_MatchProgress/Point2").GetComponent<Image>(); //text_Start_33 = transform.Find("m_TopNode/m_MatchProgress/Start_33").GetComponent<Text>(); //text_End_34 = transform.Find("m_TopNode/m_MatchProgress/End_34").GetComponent<Text>(); toggle_ToggleName = transform.Find("m_MatchGroundNode/m_GroundState/ToggleName").GetComponent <Toggle>(); //image_Background32 = transform.Find("m_MatchGroundNode/ToggleName/Background").GetComponent<Image>(); //image_Checkmark = transform.Find("m_MatchGroundNode/ToggleName/Checkmark").GetComponent<Image>(); //text_TextName_4 = transform.Find("m_MatchGroundNode/ToggleName/TextName_4").GetComponent<Text>(); //slider_m_SpeedProgress = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/m_SpeedProgress").GetComponent<Slider>(); //image_Background36 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/m_SpeedProgress/Background").GetComponent<Image>(); //image_Fill37 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/m_SpeedProgress/Fill Area/Fill").GetComponent<Image>(); //image_Handle38 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/m_SpeedProgress/Handle Slide Area/Handle").GetComponent<Image>(); //image_Background40 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/SliderEnsure/Background").GetComponent<Image>(); //image_Fill41 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/SliderEnsure/Fill Area/Fill").GetComponent<Image>(); //image_Handle42 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/SliderEnsure/Handle Slide Area/Handle").GetComponent<Image>(); //text_SpeedTxt_42 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/SpeedTxt_42").GetComponent<Text>(); //text_SpeedValue_43 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/SpeedValue_43").GetComponent<Text>(); //text_EnergyTxt_44 = transform.Find("m_MatchGroundNode/m_Info/m_HorseState/EnergyTxt_44").GetComponent<Text>(); image_GroundDiTu_45 = transform.Find("m_MatchGroundNode/m_GroundState/GroundDiTu_45").GetComponent <Image>(); imgFiled = transform.Find("m_MatchGroundNode/m_GroundState/imgField").GetComponent <Image>(); imgWeather = transform.Find("m_MatchGroundNode/m_GroundState/imgWeather").GetComponent <Image>(); text_JourneyText3_13 = transform.Find("m_MatchGroundNode/m_GroundState/JourneyText3_13").GetComponent <Text>(); text_JourneyText3_14 = transform.Find("m_MatchGroundNode/m_GroundState/JourneyText3_14").GetComponent <Text>(); text_JourneyText1_15 = transform.Find("m_MatchGroundNode/m_GroundState/JourneyText1_15").GetComponent <Text>(); //image_m_View = transform.Find("m_FightSkillRoot/m_View").GetComponent<Image>(); //button_m_View = transform.Find("m_FightSkillRoot/m_View").GetComponent<Button>(); //text_Title_50 = transform.Find("m_FightSkillRoot/m_View/Title_50").GetComponent<Text>(); image_BtnSkill = transform.Find("m_FightSkillRoot/Skill2/BtnSkill").GetComponent <Image>(); button_BtnSkill = transform.Find("m_FightSkillRoot/Skill2/BtnSkill").GetComponent <Button>(); image_FillSkill = transform.Find("m_FightSkillRoot/Skill2/FillSkill").GetComponent <Image>(); image_ProSkill = transform.Find("m_FightSkillRoot/Skill2/ProSkill").GetComponent <Image>(); text_CDSkill = transform.Find("m_FightSkillRoot/Skill2/CDSkill").GetComponent <Text>(); image_BtnSkill58 = transform.Find("m_FightSkillRoot/Skill1/BtnSkill").GetComponent <Image>(); button_BtnSkill59 = transform.Find("m_FightSkillRoot/Skill1/BtnSkill").GetComponent <Button>(); image_FillSkill60 = transform.Find("m_FightSkillRoot/Skill1/FillSkill").GetComponent <Image>(); image_ProSkill61 = transform.Find("m_FightSkillRoot/Skill1/ProSkill").GetComponent <Image>(); text_CDSkill62 = transform.Find("m_FightSkillRoot/Skill1/CDSkill").GetComponent <Text>(); image_BtnSkill63 = transform.Find("m_FightSkillRoot/Skill0/BtnSkill").GetComponent <Image>(); button_BtnSkill64 = transform.Find("m_FightSkillRoot/Skill0/BtnSkill").GetComponent <Button>(); image_FillSkill65 = transform.Find("m_FightSkillRoot/Skill0/FillSkill").GetComponent <Image>(); image_ProSkill66 = transform.Find("m_FightSkillRoot/Skill0/ProSkill").GetComponent <Image>(); text_CDSkill67 = transform.Find("m_FightSkillRoot/Skill0/CDSkill").GetComponent <Text>(); image_KeyDiTu_63 = transform.Find("m_FightButtonRoot/m_DirKeyGroup/KeyDiTu_63").GetComponent <Image>(); layoutelement_DirBtnItemTemplate = transform.Find("m_FightButtonRoot/m_DirKeyGroup/DirBtnItemTemplate").GetComponent <LayoutElement>(); image_KeyState = transform.Find("m_FightButtonRoot/m_DirKeyGroup/DirBtnItemTemplate/KeyState").GetComponent <Image>(); image_KeyDir = transform.Find("m_FightButtonRoot/m_DirKeyGroup/DirBtnItemTemplate/KeyDir").GetComponent <Image>(); contentsizefitter_OpObj = transform.Find("m_FightButtonRoot/m_DirKeyGroup/m_DirList/OpObj").GetComponent <ContentSizeFitter>(); horizontallayoutgroup_OpObj = transform.Find("m_FightButtonRoot/m_DirKeyGroup/m_DirList/OpObj").GetComponent <HorizontalLayoutGroup>(); image_DirKeyDiTu_64 = transform.Find("m_FightButtonRoot/DirObj/DirKeyDiTu_64").GetComponent <Image>(); image_DirCountDown = transform.Find("m_FightButtonRoot/DirObj/DirCountDown").GetComponent <Image>(); image_DirBtn3 = transform.Find("m_FightButtonRoot/DirObj/DirBtn3").GetComponent <Image>(); button_DirBtn3 = transform.Find("m_FightButtonRoot/DirObj/DirBtn3").GetComponent <Button>(); image_DirBtn2 = transform.Find("m_FightButtonRoot/DirObj/DirBtn2").GetComponent <Image>(); button_DirBtn2 = transform.Find("m_FightButtonRoot/DirObj/DirBtn2").GetComponent <Button>(); image_DirBtn1 = transform.Find("m_FightButtonRoot/DirObj/DirBtn1").GetComponent <Image>(); button_DirBtn1 = transform.Find("m_FightButtonRoot/DirObj/DirBtn1").GetComponent <Button>(); image_DirBtn0 = transform.Find("m_FightButtonRoot/DirObj/DirBtn0").GetComponent <Image>(); button_DirBtn0 = transform.Find("m_FightButtonRoot/DirObj/DirBtn0").GetComponent <Button>(); loopverticalscrollrect_SkillInfoList = transform.Find("m_SkillInfoRoot/SkillInfoList").GetComponent <LoopVerticalScrollRect>(); image_CountDownroundBottom_1 = transform.Find("m_Countdown/CountDownroundBottom_1").GetComponent <Image>(); image_CountDownLine_2 = transform.Find("m_Countdown/CountDownLine_2").GetComponent <Image>(); image_CountDownBright_circle_3 = transform.Find("m_Countdown/CountDownBright_circle_3").GetComponent <Image>(); image_CountDownDark_circles_4 = transform.Find("m_Countdown/CountDownDark_circles_4").GetComponent <Image>(); image_CountDownCircle_5 = transform.Find("m_Countdown/CountDownCircle_5").GetComponent <Image>(); image_CountDownThird_7 = transform.Find("m_Countdown/CountDownThird_7").GetComponent <Image>(); image_CountDownFirst_8 = transform.Find("m_Countdown/CountDownFirst_8").GetComponent <Image>(); image_CountDownSecond_9 = transform.Find("m_Countdown/CountDownSecond_9").GetComponent <Image>(); image_CountDownThird_10 = transform.Find("m_Countdown/CountDownThird_10").GetComponent <Image>(); image_guangzhu = transform.Find("m_Countdown/guangzhu").GetComponent <Image>(); go_m_MatchListRoot = transform.Find("m_MatchListRoot").gameObject; go_templateMatchItem = transform.Find("m_MatchListRoot/templateMatchItem").gameObject; go_m_MatchList = transform.Find("m_MatchListRoot/m_MatchList").gameObject; go_m_MatchListRect = transform.Find("m_MatchListRoot/m_MatchList").GetComponent <RectTransform>(); button_MatchListOpen = transform.Find("m_MatchListRoot/m_MatchList/MatchListOpen").GetComponent <Button>(); image_MatchJianTou = transform.Find("m_MatchListRoot/m_MatchList/MatchJianTou").GetComponent <Image>(); trans_RankingMatchList_Content = transform.Find("m_MatchListRoot/m_MatchList/Viewport/Content"); trans_RankingMatchList_ContentRect = transform.Find("m_MatchListRoot/m_MatchList/Viewport/Content").GetComponent <RectTransform>(); go_m_CountDownNode = transform.Find("m_MatchGroundNode/m_GroundState/m_CountDownNode").gameObject; go_m_MatchGroundNode = transform.Find("m_MatchGroundNode").gameObject; go_m_GroundState = transform.Find("m_MatchGroundNode/m_GroundState").gameObject; recttrans_m_GroundState = transform.Find("m_MatchGroundNode/m_GroundState").GetComponent <RectTransform>(); go_m_FightSkillRoot = transform.Find("m_FightSkillRoot").gameObject; go_m_FightSkillSkill0 = transform.Find("m_FightSkillRoot/Skill0").gameObject; go_m_FightSkillSkill1 = transform.Find("m_FightSkillRoot/Skill1").gameObject; go_m_FightSkillSkill2 = transform.Find("m_FightSkillRoot/Skill2").gameObject; go_m_FightButtonRoot = transform.Find("m_FightButtonRoot").gameObject; go_m_DirKeyGroup = transform.Find("m_FightButtonRoot/m_DirKeyGroup").gameObject; go_m_DirList = transform.Find("m_FightButtonRoot/m_DirKeyGroup/m_DirList").gameObject; go_m_SkillInfoRoot = transform.Find("m_SkillInfoRoot").gameObject; go_m_Countdown = transform.Find("m_Countdown").gameObject; go_HeadInSceneTemplate = transform.Find("HeadInSceneTemplate").gameObject; go_AllHeadInSceneRoot = transform.Find("AllHeadInSceneRoot").gameObject; go_SkillBuffNode = transform.Find("SkillBuffNode").gameObject; go_LogoNode = transform.Find("LogoNode").gameObject; go_HQGJNode = transform.Find("LogoNode/HQGJNode").gameObject; go_OtherNode = transform.Find("LogoNode/OtherNode").gameObject; image_LogoImg = transform.Find("LogoNode/OtherNode/LogoImg").GetComponent <Image>(); image_NameImg = transform.Find("LogoNode/OtherNode/NameImg").GetComponent <Image>(); go_BuffTemplate = transform.Find("BuffTemplate").gameObject; go_Content = transform.Find("m_skillRoot/Viewport/Content").gameObject; go_ExplainNode = transform.Find("ExplainNode").gameObject; text_ExplainTxt = transform.Find("ExplainNode/ExplainDi/ExplainTxt").GetComponent <Text>(); trans_templateAdmissionInfo = transform.Find("templateAdmissionInfo"); trans_m_AdmissionInfo = transform.Find("m_AdmissionInfo"); go_m_AdmissionBattleInfo = transform.Find("m_AdmissionBattleInfo").gameObject; text_TextWeather = transform.Find("m_AdmissionBattleInfo/TextWeather").GetComponent <Text>(); text_TextField = transform.Find("m_AdmissionBattleInfo/TextField").GetComponent <Text>(); text_TextLength = transform.Find("m_AdmissionBattleInfo/TextLength").GetComponent <Text>(); go_m_CloseUpInfo = transform.Find("m_CloseUpInfo").gameObject; text_TextHorseName = transform.Find("m_CloseUpInfo/root_CloseUp/TextHorseName").GetComponent <Text>(); text_TextPlayerName = transform.Find("m_CloseUpInfo/root_CloseUp/TextPlayerName").GetComponent <Text>(); text_TextPower = transform.Find("m_CloseUpInfo/root_CloseUp/TextPower").GetComponent <Text>(); text_TextRoad = transform.Find("m_CloseUpInfo/root_CloseUp/TextRoad").GetComponent <Text>(); image_Horse = transform.Find("m_CloseUpInfo/root_CloseUp/HorseImage").GetComponent <Image>(); go_CombatNode = transform.Find("CombatNode").gameObject; go_CombatVSNode = transform.Find("CombatNode/VSNode").gameObject; tf_CombatLeftHead = transform.Find("CombatNode/LeftNode/HeadDi"); tf_CombatRightHead = transform.Find("CombatNode/RightNode/HeadDi"); tf_CombatLeftName = transform.Find("CombatNode/LeftNode/Text").GetComponent <Text>(); tf_CombatRightName = transform.Find("CombatNode/RightNode/Text").GetComponent <Text>(); text_CombatTitle = transform.Find("CombatNode/TopNode/Title").GetComponent <Text>(); go_PlayerBackNode = transform.Find("PlayerBackNode").gameObject; button_RecoveryBtn = transform.Find("PlayerBackNode/RecoveryBtn").GetComponent <Button>(); button_PauseBtn = transform.Find("PlayerBackNode/PauseBtn").GetComponent <Button>(); button_FastForward = transform.Find("PlayerBackNode/FastForward").GetComponent <Button>(); button_CloseBtn = transform.Find("PlayerBackNode/CloseBtn").GetComponent <Button>(); text_AddNum = transform.Find("PlayerBackNode/FastForward/AddNum").GetComponent <Text>(); go_m_DynamicRankingNode = transform.Find("m_DynamicRankingNode").gameObject; txtEnergyTxt_44 = transform.Find("m_DynamicRankingNode/EnergyTxt_44").GetComponent <Text>(); slider_SliderEnsure = transform.Find("m_DynamicRankingNode/SliderEnsure").GetComponent <Slider>(); recttrans_DyRank = transform.Find("m_DynamicRankingNode/DyRank").GetComponent <RectTransform>(); trans_DyRank = transform.Find("m_DynamicRankingNode/DyRank").GetComponent <Transform>(); go_DyRankItem = transform.Find("m_DynamicRankingNode/DyRankItem").gameObject; go_m_yindao = transform.Find("m_yindao").gameObject; go_m_tishi1 = transform.Find("m_yindao/m_tishi1").gameObject; go_m_tishi2 = transform.Find("m_yindao/m_tishi2").gameObject; button_Buttonok = transform.Find("m_yindao/m_tishi2/Buttonok").GetComponent <Button>(); }
void Awake() { layout = GetComponent <HorizontalLayoutGroup>(); }
public static void Display(List <string> Directories, List <string> Files, bool FromSearch) { // Delete all previous created GameObjects DestroyAll(); // Scroll to top if (!FromSearch) { GameObject.Find("Files").GetComponent <ScrollRect> ().verticalScrollbar.value = 1; } // Combine directories and folders List <string> results = new List <string> (Directories); int lastDirectory = results.Count; results.AddRange(Files); // Get current GameObject GameObject gameObject = GameObject.Find("FileContent"); // Create item for ech entry in results foreach (string item in results) { // Test if item is directory bool isDir = Directory.Exists(item); // Create GameObject GameObject obj = new GameObject(item); obj.transform.SetParent(gameObject.transform); // Add Horizontal Layout Group HorizontalLayoutGroup hlg = obj.AddComponent <HorizontalLayoutGroup> (); hlg.spacing = 20; hlg.childAlignment = TextAnchor.MiddleLeft; hlg.childForceExpandWidth = false; hlg.childForceExpandHeight = true; // Set RectTransform RectTransform trans = obj.GetComponent <RectTransform> (); trans.localScale = Vector3.one; // Create image GameObject GameObject goImage = new GameObject("Image"); goImage.transform.SetParent(obj.transform); // Add text TextUnicode textImage = goImage.AddComponent <TextUnicode> (); textImage.color = Settings.GetColorFromRgb(180, 180, 180); textImage.text = isDir ? IconFont.FOLDER : IconFont.MUSIC; textImage.alignment = TextAnchor.MiddleLeft; textImage.font = IconFont.font; textImage.fontSize = 30; // Add RectTransform RectTransform imageTrans = goImage.GetComponent <RectTransform> (); imageTrans.localScale = Vector3.one; // Add Layout Element LayoutElement imageLayout = goImage.AddComponent <LayoutElement> (); imageLayout.minWidth = 30; // Create text GameObject GameObject goText = new GameObject("Text"); goText.transform.SetParent(obj.transform); // Add RectTransform element RectTransform textTrans = goText.AddComponent <RectTransform> (); textTrans.pivot = new Vector2(0.5f, 0.5f); textTrans.localScale = Vector3.one; // Add Layout Element LayoutElement layoutElement = goText.AddComponent <LayoutElement> (); layoutElement.minHeight = 30; layoutElement.preferredHeight = 30; // Add Drag Handler if (!isDir) { goText.AddComponent <DragHandler> (); } // Add Button Button button = goText.AddComponent <Button> (); button.transition = Selectable.Transition.Animation; Navigation nav = new Navigation(); nav.mode = Navigation.Mode.None; button.navigation = nav; // Add OnClick Handler string currentItem = item; if (isDir) { button.onClick.AddListener(delegate { Initialize(currentItem); }); } else { string currentFile = item; button.onClick.AddListener(delegate { // Get reference to playlist object Playlist pl = GameObject.Find("PlaylistContent").GetComponent <Playlist> (); // Get file object if available FileObj file = pl.GetFile(currentItem); // Get source folder object SourceFolder sf = GameObject.Find("FileContent").GetComponent <SourceFolder> (); if (sf.DoubleClicked(goText)) { // Get drop area GameObject dropObj = GameObject.FindGameObjectWithTag("PlaylistDrop"); // Insert file DropHandler.InsertFile(currentFile, dropObj, dropObj); } }); } // Add Animator Animator animator = goText.AddComponent <Animator> (); animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController> ("Animations/MenuButtons"); // Add Text Text text = goText.AddComponent <Text> (); text.color = Color.white; text.font = Resources.Load <Font> ("Fonts/FuturaStd-Book"); text.text = Path.GetFileName(item); text.fontSize = 30; text.alignment = TextAnchor.MiddleLeft; } }
/// <summary> /// 更新渲染 /// </summary> private void _UpdateRenderer() { roots.RemoveAll(temp => temp == null);//清空空项 #region 设置显示或隐藏项 Action <UITreeNode, bool> SetNodeDisplay = null; SetNodeDisplay = (parentNode, display) => { parentNode.gameObject.SetActive(false); foreach (var item in parentNode) { SetNodeDisplay(item, display); } }; Action <UITreeNode> CheckAction = null; CheckAction = (parentNode) => { if (parentNode.IsDisplay) { parentNode.gameObject.SetActive(true); if (parentNode.IsExpand) { foreach (var item in parentNode) { CheckAction(item); } } else { foreach (var item in parentNode) { SetNodeDisplay(item, false); } } } else { SetNodeDisplay(parentNode, false); } }; foreach (UITreeNode root in roots) { CheckAction(root); } #endregion #region 将所有的对象的大小更新一下 Action <UITreeNode> UpdateNodeSize = null; UpdateNodeSize = (parentNode) => { if (parentNode.gameObject.activeSelf) { HorizontalLayoutGroup horizonTalLayoutGroup = parentNode.GetComponent <HorizontalLayoutGroup>(); if (horizonTalLayoutGroup) { horizonTalLayoutGroup.SetLayoutHorizontal(); } ContentSizeFitter contentSizeFitter = parentNode.GetComponent <ContentSizeFitter>(); contentSizeFitter.SetLayoutHorizontal(); contentSizeFitter.SetLayoutVertical(); foreach (var item in parentNode) { UpdateNodeSize(item); } } }; foreach (UITreeNode root in roots) { UpdateNodeSize(root); } #endregion #region 设置位置 float xPos = 0; float yPos = 0; float maxXPos = 0; Action <UITreeNode> SetNodePos = null; SetNodePos = (parentNode) => { if (parentNode.IsDisplay) { //设置自身位置 RectTransform rectTransform = parentNode.GetComponent <RectTransform>(); rectTransform.localPosition = new Vector2(xPos, -yPos); float thisWidth = rectTransform.rect.width; if (xPos + thisWidth > maxXPos) { maxXPos = xPos + thisWidth; } yPos += rectTransform.rect.height; //设置子节点位置 if (parentNode.IsExpand) { xPos += indent; foreach (var item in parentNode) { try { SetNodePos(item); } catch { } } xPos -= indent; } } }; foreach (UITreeNode root in roots) { SetNodePos(root); } Vector2 offsetMin = rendererPanel.offsetMin; Vector2 offsetMax = rendererPanel.offsetMax; float width = rendererPanel.rect.width; float height = rendererPanel.rect.height; float offsetWidth = maxXPos - width; float offsetHeight = yPos - height; offsetMax.x += offsetWidth; offsetMin.y -= offsetHeight; rendererPanel.offsetMin = offsetMin; rendererPanel.offsetMax = offsetMax; #endregion }
/// <summary> /// Creates new line column object. /// </summary> /// <param name="parent">Parent.</param> /// <param name="content">Content.</param> /// <param name="isLeft">If set to <c>true</c> is left.</param> /// <param name="style">The style.</param> private void CreateLineColumn(Transform parent, string content, bool isLeft, UITooltipLines.LineStyle style) { // Create the game object GameObject obj = new GameObject("Column", typeof(RectTransform), typeof(CanvasRenderer)); obj.layer = this.gameObject.layer; obj.transform.SetParent(parent); // Set the pivot to top left (obj.transform as RectTransform).pivot = new Vector2(0f, 1f); // Set a fixed size for attribute columns if (style == UITooltipLines.LineStyle.Attribute) { VerticalLayoutGroup vlg = this.gameObject.GetComponent <VerticalLayoutGroup>(); HorizontalLayoutGroup phlg = parent.gameObject.GetComponent <HorizontalLayoutGroup>(); LayoutElement le = obj.AddComponent <LayoutElement>(); le.preferredWidth = (this.m_Rect.sizeDelta.x - vlg.padding.horizontal - phlg.padding.horizontal) / 2f; } // Prepare the text component Text text = obj.AddComponent <Text>(); text.text = content; text.supportRichText = true; text.alignment = (isLeft) ? TextAnchor.LowerLeft : TextAnchor.LowerRight; // Prepare some style properties TextEffectType effect = TextEffectType.None; Color effectColor = Color.white; Vector2 effectDistance = new Vector2(1f, -1f); bool effectUseAlpha = true; switch (style) { case UITooltipLines.LineStyle.Title: text.font = this.m_TitleFont; text.fontStyle = this.m_TitleFontStyle; text.fontSize = this.m_TitleFontSize; text.lineSpacing = this.m_TitleFontLineSpacing; text.color = this.m_TitleFontColor; effect = this.m_TitleTextEffect; effectColor = this.m_TitleTextEffectColor; effectDistance = this.m_TitleTextEffectDistance; effectUseAlpha = this.m_TitleTextEffectUseGraphicAlpha; break; case UITooltipLines.LineStyle.Attribute: text.font = this.m_AttributeFont; text.fontStyle = this.m_AttributeFontStyle; text.fontSize = this.m_AttributeFontSize; text.lineSpacing = this.m_AttributeFontLineSpacing; text.color = this.m_AttributeFontColor; effect = this.m_AttributeTextEffect; effectColor = this.m_AttributeTextEffectColor; effectDistance = this.m_AttributeTextEffectDistance; effectUseAlpha = this.m_AttributeTextEffectUseGraphicAlpha; break; case UITooltipLines.LineStyle.Description: text.font = this.m_DescriptionFont; text.fontStyle = this.m_DescriptionFontStyle; text.fontSize = this.m_DescriptionFontSize; text.lineSpacing = this.m_DescriptionFontLineSpacing; text.color = this.m_DescriptionFontColor; effect = this.m_DescriptionTextEffect; effectColor = this.m_DescriptionTextEffectColor; effectDistance = this.m_DescriptionTextEffectDistance; effectUseAlpha = this.m_DescriptionTextEffectUseGraphicAlpha; break; } // Add text effect component if (effect == TextEffectType.Shadow) { Shadow s = obj.AddComponent <Shadow>(); s.effectColor = effectColor; s.effectDistance = effectDistance; s.useGraphicAlpha = effectUseAlpha; } else if (effect == TextEffectType.Outline) { Outline o = obj.AddComponent <Outline>(); o.effectColor = effectColor; o.effectDistance = effectDistance; o.useGraphicAlpha = effectUseAlpha; } }
public void InitItem(Callback.CallbackV callback = null) { RectTransform container = gameObject.GetComponent <RectTransform> (); container.localPosition += new Vector3(_containerDefaultX + _containerGapX * 0, 0f, 0f); float gapX = 0f; float gapY = 0f; bool isControlSize = false; if (_isHorizontal) { HorizontalLayoutGroup layout = container.GetComponent <HorizontalLayoutGroup> (); gapX = layout.spacing; if (true == layout.childControlWidth && true == layout.childControlHeight) { isControlSize = true; } } else { VerticalLayoutGroup layout = container.GetComponent <VerticalLayoutGroup> (); gapY = layout.spacing; if (true == layout.childControlWidth && true == layout.childControlHeight) { isControlSize = true; } } bool isNeedReset = !string.IsNullOrEmpty(_pathBtnReset); GameObject prefab = _itemPrefab; string iconFormat = _iconFormat; Vector3 itemScale = _itemScale; Vector3 itemPosOffset = _itemPosOffset; int count = _itemCount; if (true == isNeedReset) { count++; } int countAdd = 0; Vector2 containerSize = Vector2.zero; for (int j = 0; j < count; j++) { GameObject item = Instantiate(prefab) as GameObject; int index = j; if (false == isNeedReset) { index++; } RectTransform itemRT = item.GetComponent <RectTransform> (); UIButton ktButton = item.AddComponent <UIButton> (); ktButton._effectType = UIButton.EffectType.NONE; ktButton._eventType = UIButton.EventType.CLICK; //ktButton._clickSoundPath = GameResPath.SFX_ITEM_SELECT; item.GetComponent <Toggle> ().onValueChanged.AddListener((bool isOn) => { if (!isOn) { if (null != _animKTButtonSeq) { _animKTButtonSeq.Kill(); _animKTButtonSeq = null; } ktButton.StopTouchAnim(); itemRT.localScale = itemScale; // Debug.Log("itemRT.localScale:"+itemRT.localScale); return; } Sequence seq = DOTween.Sequence(); _animKTButtonSeq = seq; float time = 0.25f; float scaleChange = 0.2f; seq.Append(itemRT.DOScale(new Vector3(itemScale.x + scaleChange, itemScale.y - scaleChange, 1f), time)); seq.Append(itemRT.DOScale(new Vector3(itemScale.x - scaleChange, itemScale.y + scaleChange, 1f), time)); seq.Append(itemRT.DOScale(new Vector3(itemScale.x + scaleChange, itemScale.y + scaleChange, 1f), time)); seq.AppendCallback(() => { LockItemKit lockKit = itemRT.GetComponent <LockItemKit> (); if (null != lockKit && lockKit.IsLock()) { lockKit.Unlock(); return; } OnClickEvent.Invoke(index); }); // AudioManager.Instance.PlaySoundEffect (GameResPath.SFX_ITEM_SELECT); // ktButton.PlayTouchAnim (()=>{ // }); }); itemRT.SetParent(container); item.GetComponent <Toggle> ().isOn = false; item.GetComponent <Toggle> ().group = container.GetComponent <ToggleGroup> (); // Vector2 bigScale = itemScale + new Vector3 (0.2f, 0.2f, 0f); // ktButton.SetScaleDefault (bigScale.x, bigScale.y); AddLock(itemRT, index); Vector3 pos = itemRT.localPosition; itemRT.localPosition = new Vector3(pos.x, pos.y, 0); itemRT.localScale = itemScale; RectTransform iconRT = itemRT.GetChild(0) as RectTransform; RectTransform checkerRT = itemRT.GetChild(1) as RectTransform; Image iconImage = iconRT.GetComponent <Image> (); string url = null; if (true == isNeedReset && 0 == j) { url = _pathBtnReset; } else { url = string.Format(iconFormat, index); } countAdd++; ResourcesManager.LoadSpriteFromPrefab(url, iconImage, (bool isDone) => { Vector2 size = iconImage.rectTransform.sizeDelta; size.x *= itemScale.x; size.y *= itemScale.y; checkerRT.sizeDelta = size; if (false == isControlSize) { itemRT.sizeDelta = size; } if (_isHorizontal) { containerSize.x += itemRT.sizeDelta.x + gapX; containerSize.y = itemRT.sizeDelta.y; } else { containerSize.x = itemRT.sizeDelta.x; containerSize.y += itemRT.sizeDelta.y + gapY; } iconRT.localPosition += itemPosOffset; checkerRT.localPosition += itemPosOffset; }); if (countAdd == count) { container.sizeDelta = containerSize; if (null != callback) { callback(); } } } }
public void UpdateFactoryInfo(string Category, float Value, float StandardValue) { Text CompanyValueText = LeftPanel.transform.GetChild(1).GetChild(0).GetChild(0).GetChild(1).gameObject.GetComponent <Text>(); Image CompanyValueStateImage = LeftPanel.transform.GetChild(1).GetChild(0).GetChild(0).GetChild(2).GetChild(0).gameObject.GetComponent <Image>(); Text ElectricityCurrentValueText = LeftPanel.transform.GetChild(1).GetChild(0).GetChild(2).GetChild(1).GetChild(0).gameObject.GetComponent <Text>(); Text ElectricityStandardValueText = LeftPanel.transform.GetChild(1).GetChild(0).GetChild(2).GetChild(1).GetChild(1).gameObject.GetComponent <Text>(); Text WarehouseCurrentValueText = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(1).GetChild(0).gameObject.GetComponent <Text>(); Text WarehouseStandardValueText = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(1).GetChild(1).gameObject.GetComponent <Text>(); Text EmployeeCurrentValueText = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(2).GetChild(1).GetChild(0).gameObject.GetComponent <Text>(); Text EmployeeStandardValueText = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(2).GetChild(1).GetChild(1).gameObject.GetComponent <Text>(); HorizontalLayoutGroup WarehouseValueCarrierLayoutGroup = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(1).gameObject.GetComponent <HorizontalLayoutGroup>(); HorizontalLayoutGroup EmployeeValueCarrierLayoutGroup = LeftPanel.transform.GetChild(1).GetChild(1).GetChild(2).GetChild(1).gameObject.GetComponent <HorizontalLayoutGroup>(); if (Category == "CompanyValue") { int PreviousValue = Mathf.CeilToInt(StandardValue); int CurrentValue = Mathf.CeilToInt(Value); if (PreviousValue == CurrentValue) { CompanyValueText.text = CurrentValue.ToString(); CompanyValueStateImage.sprite = Resources.Load <Sprite>("GameSystem/InGameUI/Sprite/FixedValue"); } else { CompanyValueText.text = CurrentValue.ToString(); if (PreviousValue < CurrentValue) { CompanyValueStateImage.sprite = Resources.Load <Sprite>("GameSystem/InGameUI/Sprite/UpArrow"); } else { CompanyValueStateImage.sprite = Resources.Load <Sprite>("GameSystem/InGameUI/Sprite/DownArrow"); } } } else if (Category == "Electricity") { ElectricityCurrentValueText.text = (Mathf.CeilToInt(Value * 10) * 0.1f).ToString() + " "; ElectricityStandardValueText.text = "/ " + (Mathf.CeilToInt(StandardValue * 10) * 0.1f).ToString(); if (Value < StandardValue) { ElectricityCurrentValueText.color = new Color(0, 1f, 0, 1f); } else if (Value > StandardValue) { ElectricityCurrentValueText.color = new Color(1f, 0, 0, 1f); } else { ElectricityCurrentValueText.color = new Color(1f, 1f, 1f, 1f); } } else if (Category == "Warehouse") { WarehouseCurrentValueText.text = Value.ToString() + " "; WarehouseStandardValueText.text = "/ " + StandardValue.ToString(); if (Value > StandardValue) { WarehouseCurrentValueText.color = new Color(1f, 0, 0, 1f); } else if (Value < StandardValue) { WarehouseCurrentValueText.color = new Color(0, 1f, 0, 1f); } else { WarehouseCurrentValueText.color = new Color(1f, 1f, 1f, 1f); } } else if (Category == "Employee") { EmployeeCurrentValueText.text = Value.ToString() + " "; EmployeeStandardValueText.text = "/ " + StandardValue.ToString(); if (Value > StandardValue) { EmployeeCurrentValueText.color = new Color(0, 1f, 0, 1f); } else if (Value < StandardValue) { EmployeeCurrentValueText.color = new Color(1f, 0, 0, 1f); } else { EmployeeCurrentValueText.color = new Color(1f, 1f, 1f, 1f); } } Canvas.ForceUpdateCanvases(); ContentSizeFitterReseter(LeftPanel.transform.GetChild(1).GetChild(0).GetChild(2).GetChild(1).gameObject); ContentSizeFitterReseter(LeftPanel.transform.GetChild(1).GetChild(1).GetChild(0).GetChild(1).gameObject); ContentSizeFitterReseter(LeftPanel.transform.GetChild(1).GetChild(1).GetChild(2).GetChild(1).gameObject); }
protected override void Awake() { base.Awake(); if (m_virtualContent == null) { return; } m_virtualContentTransformChangeListener = m_virtualContent.GetComponent <RectTransformChangeListener>(); m_virtualContentTransformChangeListener.RectTransformChanged += OnVirtualContentTransformChaged; UpdateVirtualContentPosition(); if (m_useGrid) { LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is GridLayoutGroup)) { DestroyImmediate(layoutGroup); } GridLayoutGroup gridLayout = m_virtualContent.GetComponent <GridLayoutGroup>(); if (gridLayout == null) { gridLayout = m_virtualContent.gameObject.AddComponent <GridLayoutGroup>(); } gridLayout.cellSize = ContainerPrefab.rect.size; gridLayout.childAlignment = TextAnchor.UpperLeft; gridLayout.startCorner = GridLayoutGroup.Corner.UpperLeft; gridLayout.spacing = m_gridSpacing; if (m_mode == VirtualizingMode.Vertical) { gridLayout.startAxis = GridLayoutGroup.Axis.Horizontal; gridLayout.constraint = GridLayoutGroup.Constraint.FixedColumnCount; } else { gridLayout.startAxis = GridLayoutGroup.Axis.Vertical; gridLayout.constraint = GridLayoutGroup.Constraint.FixedRowCount; } m_gridLayoutGroup = gridLayout; } else { if (m_mode == VirtualizingMode.Horizontal) { //In horizontal mode we destroy VerticalLayoutGroup or GridLayoutGroup if exists LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is HorizontalLayoutGroup)) { DestroyImmediate(layoutGroup); } // Create HorizontalLayoutGroup if does not exists HorizontalLayoutGroup horizontalLayout = m_virtualContent.GetComponent <HorizontalLayoutGroup>(); if (horizontalLayout == null) { horizontalLayout = m_virtualContent.gameObject.AddComponent <HorizontalLayoutGroup>(); } // Setup HorizontalLayoutGroup behavior to arrange ui containers correctly horizontalLayout.childControlHeight = true; horizontalLayout.childControlWidth = false; horizontalLayout.childForceExpandWidth = false; m_layoutGroup = horizontalLayout; } else { //In horizontal mode we destroy HorizontalLayoutGroup or GridLayoutGroup if exists LayoutGroup layoutGroup = m_virtualContent.GetComponent <LayoutGroup>(); if (layoutGroup != null && !(layoutGroup is VerticalLayoutGroup)) { DestroyImmediate(layoutGroup); } // Create VerticalLayoutGroup if does not exists VerticalLayoutGroup verticalLayout = m_virtualContent.GetComponent <VerticalLayoutGroup>(); if (verticalLayout == null) { verticalLayout = m_virtualContent.gameObject.AddComponent <VerticalLayoutGroup>(); } // Setup VerticalLayoutGroup behavior to arrange ui containers correctly verticalLayout.childControlWidth = true; verticalLayout.childControlHeight = false; verticalLayout.childForceExpandHeight = false; m_layoutGroup = verticalLayout; } } // Set ScrollSensitivity to be exactly the same as ContainerSize scrollSensitivity = ContainerSize;// * ContainersPerGroup; }
void Awake() { rect = GetComponent <RectTransform>(); layoutGroup = GetComponent <HorizontalLayoutGroup>(); }