private void Start() { m_Transition = GetComponent<ShowAndHidePanel>(); m_AudioSource = GetComponent<AudioSource>(); m_CanvasGroup = GetComponent<CanvasGroup>(); m_CanvasGroup.alpha = 0; m_FaderPanel = transform.GetChild(0).GetComponent<RectTransform>(); m_UserPanel = transform.GetChild(1).GetComponent<RectTransform>(); m_NameInputValue = m_UserPanel.GetChild(1).GetChild(0).GetComponent<InputField>(); m_EmailInputValue = m_UserPanel.GetChild(1).GetChild(1).GetComponent<InputField>(); m_PasswordInputValue = m_UserPanel.GetChild(1).GetChild(2).GetComponent<InputField>(); m_CancelButton = m_UserPanel.GetChild(2).GetComponent<Button>(); m_CancelButton.onClick.RemoveAllListeners(); m_CancelButton.onClick.AddListener(delegate { Cancel(); }); m_RegisterButton = m_UserPanel.GetChild(3).GetComponent<Button>(); m_RegisterButton.onClick.RemoveAllListeners(); m_RegisterButton.onClick.AddListener(delegate { Register(); }); m_FaderPanel.gameObject.SetActive(false); m_UserPanel.gameObject.SetActive(false); }
/// <summary> /// <para>Flips the horizontal and vertical axes of the RectTransform size and alignment, and optionally its children as well.</para> /// </summary> /// <param name="rect">The RectTransform to flip.</param> /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param> /// <param name="recursive">Flip the children as well?</param> public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive) { if (rect != null) { if (recursive) { for (int i = 0; i < rect.childCount; i++) { RectTransform child = rect.GetChild(i) as RectTransform; if (child != null) { FlipLayoutAxes(child, false, true); } } } rect.pivot = GetTransposed(rect.pivot); rect.sizeDelta = GetTransposed(rect.sizeDelta); if (!keepPositioning) { rect.anchoredPosition = GetTransposed(rect.anchoredPosition); rect.anchorMin = GetTransposed(rect.anchorMin); rect.anchorMax = GetTransposed(rect.anchorMax); } } }
void Start() { PlayerMovment playermovment = player.GetComponent<PlayerMovment>(); Vector3 trans = this.transform.position; CameraStartPosition = Camera.main.transform.position; CameraStartRotation = Camera.main.transform.rotation; CameraTargetPosition = new Vector3(trans.x, trans.y + playermovment.p_CamZoomYFromPlayer, trans.z); CameraTargetRotation = Quaternion.Euler(new Vector3(90,0,0)); canvas = Instantiate(StartCanvas, StartCanvas.position, StartCanvas.rotation) as RectTransform; title = canvas.GetChild(0).GetComponent<Text>(); title.text = LevelName; paragraph = canvas.GetChild(1).GetComponent<Text>(); paragraph.text = ""; //subscribe to events ResourceManager.playerFound += GameOver; ResourceManager.playerClearedLevel += LevelClear; StartCoroutine(TextType(trans)); //text type triggers LerpCamera, LerpCamera spawns player when complete }
private void Convert(RectTransform transform) { var entity = GetPrimaryEntity(transform); DstEntityManager.AddComponentData(entity, new DotsUI.Core.RectTransform() { AnchorMin = transform.anchorMin, AnchorMax = transform.anchorMax, Pivot = transform.pivot, Position = transform.anchoredPosition, SizeDelta = transform.sizeDelta, }); DstEntityManager.AddComponent(entity, typeof(WorldSpaceRect)); DstEntityManager.AddComponent(entity, typeof(WorldSpaceMask)); DstEntityManager.RemoveComponent(entity, typeof(Translation)); DstEntityManager.RemoveComponent(entity, typeof(Rotation)); DstEntityManager.RemoveComponent(entity, typeof(NonUniformScale)); if (transform.childCount != 0) { var childBuffer = DstEntityManager.AddBuffer <Child>(entity); for (int i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); if (child is RectTransform rectChild) { childBuffer.Add(new Child { Value = GetPrimaryEntity(rectChild) }); } } } if (HasPrimaryEntity(transform.parent)) { DstEntityManager.AddComponentData(entity, new PreviousParent() { Value = GetPrimaryEntity(transform.parent) }); } }
protected void Populate(RectTransform container, GameObject prefab, int count) { if (container.childCount < count) { int nbToCreate = count - container.childCount; Transform tr; for (int i = 0; i < nbToCreate; ++i) { tr = Instantiate(prefab).transform; tr.SetParent(container); tr.SetAsLastSibling(); } } else if (container.childCount > count) { int nbToDelete = container.childCount - count; for (int i = 0; i < nbToDelete; ++i) { DestroyImmediate(container.GetChild(0).gameObject); } } }
public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive) { bool flag = rect == null; if (!flag) { if (recursive) { for (int i = 0; i < rect.childCount; i++) { RectTransform rectTransform = rect.GetChild(i) as RectTransform; bool flag2 = rectTransform != null; if (flag2) { RectTransformUtility.FlipLayoutOnAxis(rectTransform, axis, false, true); } } } Vector2 pivot = rect.pivot; pivot[axis] = 1f - pivot[axis]; rect.pivot = pivot; if (!keepPositioning) { Vector2 anchoredPosition = rect.anchoredPosition; anchoredPosition[axis] = -anchoredPosition[axis]; rect.anchoredPosition = anchoredPosition; Vector2 anchorMin = rect.anchorMin; Vector2 anchorMax = rect.anchorMax; float num = anchorMin[axis]; anchorMin[axis] = 1f - anchorMax[axis]; anchorMax[axis] = 1f - num; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; } } }
void Start() { modalWindowSCR = GameObject.FindGameObjectWithTag("ModalWindowManager").GetComponent<ModalWindowManager>(); tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> (); tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>(); for (int i = 0; i < 8; i++) { shopInventory.Add(databaseSCR.GetItem(0)); } for (int i = 0; i < 8; i++) { shopInventoryStacks.Add(0); } addItemResult = AddItem(3, 1); addItemResult = AddItem(6, 1); }
//build the popup from the given list of descriptors //also receives the component that this popup will edit and the type of component used to find the descriptors public void buildPopup(GameRuleDesignComponent cr, List<GameRuleDesignComponentDescriptor> pd, System.Type describedType) { //instead of Start(), this is the place where stuff will get initialized //store a bunch of size information for positioning things RectTransform iconArea = (RectTransform)(transform.GetChild(1)); iconAreaBottomLeft = iconArea.offsetMin; iconAreaTopRight = iconArea.offsetMax; //x and y are both negative for an inset corner iconAreaTotalBounds = iconAreaBottomLeft - iconAreaTopRight; iconContainer = (RectTransform)(transform.GetChild(2)); //throw the container out to under the canvas so that it renders over the whole rule iconContainer.SetParent(GameRuleDesigner.instance.uiCanvas); RectTransform iconContainerSpacing = (RectTransform)(iconContainer.GetChild(0)); iconContainerSpacingSize = iconContainerSpacing.sizeDelta; //we only needed these to get their size, we can get rid of them now Destroy(iconArea.gameObject); Destroy(iconContainerSpacing.gameObject); //now we can build the popup transform.SetParent(GameRuleDesigner.instance.iconContainerTransform); //setting the parent screwed up the scale so fix it transform.localScale = new Vector3(1.0f, 1.0f); componentRepresented = cr; popupDescriptors = pd; //go through all the descriptors and add their icon to this popup foreach (GameRuleDesignComponentDescriptor descriptor in popupDescriptors) { RectTransform popupIcon; //int descriptors don't have icon prefabs, so we have to construct the icons if (descriptor is GameRuleDesignComponentIntDescriptor) { List<GameObject> iconList = new List<GameObject>(); int i = ((GameRuleDesignComponentIntDescriptor)descriptor).intDescribed; if (i >= 0) { if (describedType == typeof(GameRulePointsPlayerEffect)) iconList.Add(GameRuleIconStorage.instance.charPlusIcon); GameRuleIconStorage.instance.addDigitIcons(i, iconList); } else { iconList.Add(GameRuleIconStorage.instance.charMinusIcon); GameRuleIconStorage.instance.addDigitIcons(-i, iconList); } //make a gameobject to hold all of the icons popupIcon = groupIcons(iconList); //almost all other descriptors we can construct normally //if it doesn't have an icon then it's a special case we know about } else if (descriptor.displayIcon == null) { if (descriptor is GameRuleDesignComponentClassDescriptor) { System.Type otherType = ((GameRuleDesignComponentClassDescriptor)descriptor).typeDescribed; //a points effect shows up as "+?" if (otherType == typeof(GameRulePointsPlayerEffect)) popupIcon = groupIcons(new List<GameObject>(new GameObject[] { GameRuleIconStorage.instance.charPlusIcon, GameRuleIconStorage.instance.charQmarkIcon })); else throw new System.Exception("Bug: no special popup icon cases for type " + otherType); } else throw new System.Exception("Bug: no special popup icon cases for " + descriptor); //it has an icon, it's probably normal } else popupIcon = componentRepresented.getIconMaybeOpponent(descriptor); popupIcon.SetParent(iconContainer); popupIcons.Add(popupIcon); } //we add a "cancel" icon at the end to ensure there's room to cancel out of the popup RectTransform cancelIcon = instantiateIcon(GameRuleDesigner.instance.cancelIconPopupPrefab); cancelIcon.SetParent(iconContainer); popupIcons.Add(cancelIcon); //if we're doing a points effect, default to the "+1" choice if (describedType == typeof(GameRulePointsPlayerEffect)) cr.assignDescriptor(popupDescriptors[ GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MASK - GameRulePointsPlayerEffect.POINTS_SERIALIZATION_MAX_VALUE + 1]); //if we're doing a fixed duration, default to the rule generator min value else if (describedType == typeof(GameRuleActionFixedDuration)) cr.assignDescriptor(popupDescriptors[GameRuleGenerator.ACTION_DURATION_SECONDS_SHORTEST]); else cr.assignDescriptor(popupDescriptors[0]); }
/// <summary> /// <para>Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well.</para> /// </summary> /// <param name="rect">The RectTransform to flip.</param> /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param> /// <param name="recursive">Flip the children as well?</param> /// <param name="axis">The axis to flip along. 0 is horizontal and 1 is vertical.</param> public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive) { if (rect != null) { if (recursive) { for (int i = 0; i < rect.childCount; i++) { RectTransform child = rect.GetChild(i) as RectTransform; if (child != null) { FlipLayoutOnAxis(child, axis, false, true); } } } Vector2 pivot = rect.pivot; pivot[axis] = 1f - pivot[axis]; rect.pivot = pivot; if (!keepPositioning) { Vector2 anchoredPosition = rect.anchoredPosition; anchoredPosition[axis] = -anchoredPosition[axis]; rect.anchoredPosition = anchoredPosition; Vector2 anchorMin = rect.anchorMin; Vector2 anchorMax = rect.anchorMax; float num2 = anchorMin[axis]; anchorMin[axis] = 1f - anchorMax[axis]; anchorMax[axis] = 1f - num2; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; } } }
void Awake() { transform = GetComponent<RectTransform>(); beltLeft = transform.GetChild(0) as RectTransform; beltRight = transform.GetChild(1) as RectTransform; }
// Use this for initialization void Start() { inventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>(); tempInventorySCR = GameObject.FindGameObjectWithTag("Inventory").GetComponent<TempInventory>(); databaseSCR = GameObject.FindGameObjectWithTag ("ItemDatabase").GetComponent<ItemDatabase> (); tooltip = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").transform.GetChild (0).GetComponent<RectTransform>(); tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> (); tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>(); for (int i = 0; i < 5; i++) { heroInventory.Add (databaseSCR.GetItem(0)); } for (int i = 0; i < heroInventory.Count; i++) { heroInventoryStacks.Add(0); } }
public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive) { if (rect == null) { return; } if (recursive) { for (int i = 0; i < rect.childCount; i++) { RectTransform rectTransform = rect.GetChild(i) as RectTransform; if (rectTransform != null) { RectTransformUtility.FlipLayoutAxes(rectTransform, false, true); } } } rect.pivot = RectTransformUtility.GetTransposed(rect.pivot); rect.sizeDelta = RectTransformUtility.GetTransposed(rect.sizeDelta); if (keepPositioning) { return; } rect.anchoredPosition = RectTransformUtility.GetTransposed(rect.anchoredPosition); rect.anchorMin = RectTransformUtility.GetTransposed(rect.anchorMin); rect.anchorMax = RectTransformUtility.GetTransposed(rect.anchorMax); }
// Initialise l'inventaire // Remplit l'inventaire d'objets vides void Start() { tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> (); // Récupération du parent du tooltip tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>(); // Récupération du tooltip tempInventorySlotContainer.SetActive(false); // Masque l'inventaire temporaire InitializeInventory(); // Initialise l'inventaire StartCoroutine(DisplayInventory()); }
// Initialise l'inventaire // Remplit l'inventaire d'objets vides void Start() { tooltipParent = GameObject.FindGameObjectWithTag ("ItemTooltipPanel").GetComponent<RectTransform> (); tooltip = tooltipParent.GetChild (0).GetComponent<RectTransform>(); itemHeroSelection = itemHeroSelectionParent.GetChild (0).GetComponent<RectTransform>(); modalWindowSCR = GameObject.FindGameObjectWithTag("ModalWindowManager").GetComponent<ModalWindowManager>(); shopManagerSCR = GameObject.FindGameObjectWithTag("ShopManager").GetComponent<ShopManager>(); for (int i = 0; i < inventorySize; i++) { inventory.Add(databaseSCR.GetItem(0)); } for (int i = 0; i < inventory.Count; i++) { inventoryStacks.Add(0); } }
IEnumerator SignBubbleTimer(RectTransform PlayerSignBubble) { yield return new WaitForSeconds(PlayerSignBubbleStayTime); for (int i = PlayerSignBubble.childCount; i > 0; i--) { Destroy(PlayerSignBubble.GetChild(i-1).gameObject); } PlayerSignBubble.gameObject.SetActive(false); }
public SurveyProjectButton(SurveyProject sProject, RectTransform buttonTemplate,float fromTop) { surveyProject = sProject; rectTransform = (RectTransform)Instantiate(buttonTemplate); name = sProject.projectName; rectTransform.gameObject.SetActive(true); rectTransform.name = name; ((Text)rectTransform.GetChild(0).GetComponent<Text>()).text = name; rectTransform.parent = buttonTemplate.parent; rectTransform.SetDefaultScale(); rectTransform.SetSize(buttonTemplate.GetSize()); rectTransform.SetPivotAndAnchors(Vector2.zero); rectTransform.SetLeftTopPosition(new Vector2(-(rectTransform.GetWidth()*0.5f), fromTop)); Button button = rectTransform.GetComponent<Button>(); button.onClick.AddListener(OnUse); }
private void BlockDecoration(RectTransform blockPrefab, Block block) { Color color = new Color(); string name = ""; if (block is LandBlock) { color = new Color(0x00 / 255f, 0xB0 / 255f, 0x06 / 255f); name = (block as LandBlock).land.name; } else if (block is ChanceBlock) { color = new Color(0xFF / 255f, 0x28 / 255f, 0x28 / 255f); name = "Chance"; } else if(block is DestinyBlock) { color = new Color(0xFF / 255f, 0xCC / 255f, 0x1F / 255f); name = "Destiny"; } blockPrefab.GetComponent<RawImage>().color = color; blockPrefab.GetChild(0).GetComponent<Text>().text = name; }
// Use this for initializatiowon void Start() { Application.targetFrameRate = 60; if (Application.loadedLevelName == "SceneOne") { isSceneOne = true; UITools.StartFadeEffect(fadeBackground, FadingType.In, 2f, EffectEndType.Callback, () => { Debug.Log("Background Finished Fading In"); }); UITools.StartPulseEffect(pulsingButton, 1.2f, 0.8f, delay: 4f); progressBar.slider.maxValue = 10f; progressBar.slider.minValue = 0f; progressBar.slider.value = 0f; } else { scrollPanel = GameObject.FindObjectOfType<ScrollRect>().transform.GetChild(0).GetComponent<RectTransform>(); expandParent = scrollPanel.GetChild(0).GetComponent<ExpandItemParent>(); expandItemHeight = expandParent.allExpandingItems[1].maskRect.rect.height; //needed for the calculation of the Y coordinate expandedItemHeight = expandParent.allExpandingItems[1].itemRect.rect.height - expandItemHeight; //That heigh is used in case you are adding items to the scroller while there is already expanded items. scrollerItems = expandParent.childs.Count - 1; //Child with zero index is actually the item we are instatiating.It doesnt' need to get in to the calculations of the new added items coordinates. } }
/// <summary> /// <para>Flips the alignment of the RectTransform along the horizontal or vertical axis, and optionally its children as well.</para> /// </summary> /// <param name="rect">The RectTransform to flip.</param> /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param> /// <param name="recursive">Flip the children as well?</param> /// <param name="axis">The axis to flip along. 0 is horizontal and 1 is vertical.</param> public static void FlipLayoutOnAxis(RectTransform rect, int axis, bool keepPositioning, bool recursive) { if ((Object) rect == (Object) null) return; if (recursive) { for (int index = 0; index < rect.childCount; ++index) { RectTransform child = rect.GetChild(index) as RectTransform; if ((Object) child != (Object) null) RectTransformUtility.FlipLayoutOnAxis(child, axis, false, true); } } Vector2 pivot = rect.pivot; pivot[axis] = 1f - pivot[axis]; rect.pivot = pivot; if (keepPositioning) return; Vector2 anchoredPosition = rect.anchoredPosition; anchoredPosition[axis] = -anchoredPosition[axis]; rect.anchoredPosition = anchoredPosition; Vector2 anchorMin = rect.anchorMin; Vector2 anchorMax = rect.anchorMax; float num = anchorMin[axis]; anchorMin[axis] = 1f - anchorMax[axis]; anchorMax[axis] = 1f - num; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; }
private void PerformLayoutCalculation(RectTransform rect, UnityAction<Component> action) { if ((UnityEngine.Object) rect == (UnityEngine.Object) null) return; List<Component> list = ListPool<Component>.Get(); rect.GetComponents(typeof (ILayoutElement), list); LayoutRebuilder.StripDisabledBehavioursFromList(list); if (list.Count > 0) { for (int index = 0; index < rect.childCount; ++index) this.PerformLayoutCalculation(rect.GetChild(index) as RectTransform, action); for (int index = 0; index < list.Count; ++index) action(list[index]); } ListPool<Component>.Release(list); }
/// <summary> /// <para>Flips the horizontal and vertical axes of the RectTransform size and alignment, and optionally its children as well.</para> /// </summary> /// <param name="rect">The RectTransform to flip.</param> /// <param name="keepPositioning">Flips around the pivot if true. Flips within the parent rect if false.</param> /// <param name="recursive">Flip the children as well?</param> public static void FlipLayoutAxes(RectTransform rect, bool keepPositioning, bool recursive) { if ((Object) rect == (Object) null) return; if (recursive) { for (int index = 0; index < rect.childCount; ++index) { RectTransform child = rect.GetChild(index) as RectTransform; if ((Object) child != (Object) null) RectTransformUtility.FlipLayoutAxes(child, false, true); } } rect.pivot = RectTransformUtility.GetTransposed(rect.pivot); rect.sizeDelta = RectTransformUtility.GetTransposed(rect.sizeDelta); if (keepPositioning) return; rect.anchoredPosition = RectTransformUtility.GetTransposed(rect.anchoredPosition); rect.anchorMin = RectTransformUtility.GetTransposed(rect.anchorMin); rect.anchorMax = RectTransformUtility.GetTransposed(rect.anchorMax); }
void Start() { mMiddlePanel = transform.FindChild("Middle").GetComponent<RectTransform>(); mTweenPanel = mMiddlePanel.FindChild("TweenTypesPanel").GetComponent<RectTransform>(); mTweenPanelArrow = mTweenPanel.FindChild("Arrow").GetComponent<RectTransform>(); mCreditsPanelArrow = mMiddlePanel.FindChild("CreditsPanel/Arrow").GetComponent<RectTransform>(); mInstructionsPanel = mMiddlePanel.FindChild("Instructions").GetComponent<RectTransform>(); mMoveDot = mInstructionsPanel.FindChild("MoveDot").GetComponent<RectTransform>(); mDot = mInstructionsPanel.FindChild("Instructions/Juice/Dot").GetComponent<CanvasGroup>(); Juice.Instance.PulseGroup(mDot, 2, 0, 1); Juice.Instance.Delay(2f, () => { for (int i = 0; i < mMoveDot.childCount; i++) { Transform dot = mMoveDot.GetChild(i).transform; Juice.Instance.Delay(i / 10f, () => { MoveDot(dot); }); } }); }
public ActionSelectableButton(RectTransform source, ActionSelectorMenu menu,WorkType wType, PointObjectPrefab poType) { if (source == null) { DebugOutput.Shout("KABLAM!"); } workType = wType; pointObjectType = poType; SelectorMenu = menu; rectTransform = (RectTransform)Instantiate(source); rectTransform.name = wType.Description; ((Text)rectTransform.GetChild(0).GetComponent<Text>()).text = poType.Name; rectTransform.SetParent(source.parent); rectTransform.localScale = source.localScale; Button button = rectTransform.GetComponent<Button>(); button.onClick.AddListener(OnUse); }