private void Start() { canvasScalerExt = GetComponentInParent <CanvasScalerExt>(); if (canvasScalerExt == null) { } if (canvasScalerExt != null) { previousMatchWidthOrHeightValue = canvasScalerExt.matchWidthOrHeight; canvasScalerExt.matchWidthOrHeight = OverrideMatchWidthOrHeightValue; } }
private void placeControlsAboveTray() { if (ControlOverlayTransform != null) { if (controlOverlayParentCanvasScaler == null) { controlOverlayParentCanvasScaler = ControlOverlayTransform.GetComponentInParent<CanvasScalerExt>(); } float num = controlOverlayParentCanvasScaler.referenceResolution.y * (1f / controlOverlayParentCanvasScaler.ScaleModifier) * myTrayHeightNoKB; ControlOverlayTransform.sizeDelta = new Vector2(1f, num); ControlOverlayTransform.anchoredPosition = new Vector2(0f, num / 2f + OverlayOffset); } }
public void Awake() { canvas = GetComponent <Canvas>(); canvasScalerExt = GetComponent <CanvasScalerExt>(); manipulatableObject = GetComponentInParent <ManipulatableObject>(); decorationInventoryService = Service.Get <DecorationInventoryService>(); confirmButtonImage = ConfirmButton.GetComponent <Image>(); duplicateButtonImage = DuplicateButton.GetComponent <Image>(); baseCamera = SceneRefs.Get <BaseCamera>(); BaseCamera obj = baseCamera; obj.Moved = (System.Action)Delegate.Combine(obj.Moved, new System.Action(OnCameraMoved)); Service.Get <EventDispatcher>().AddListener <InputEvents.ZoomEvent>(onInputZoom); IsInitialized = false; isDecorationSet = false; hide(); }
protected void showPopup(GameObject popup, bool destroyPopupOnBackPressed = false, bool scaleToFit = true, string accessibilityTitleToken = null) { if (!scaleToFit) { CanvasScalerExt component = GetComponent <CanvasScalerExt>(); if (component != null) { component.enabled = false; } } popup.transform.SetParent(base.transform, worldPositionStays: false); popup.SetActive(value: true); if (destroyPopupOnBackPressed) { popup.gameObject.AddComponent <DestroyPopupOnBackPressed>(); } playAccessibilityTitle(accessibilityTitleToken); }
public void SetPosition(Vector2 position) { CanvasScalerExt component = GetComponentInParent <Canvas>().GetComponent <CanvasScalerExt>(); Vector2 vector = new Vector2(component.ReferenceResolutionY / (float)Screen.height, component.ReferenceResolutionY / (float)Screen.height); vector *= 1f / component.ScaleModifier; GetComponent <RectTransform>().anchoredPosition = new Vector2(Mathf.Clamp(position.x, ScreenPadding, (float)Screen.width - ScreenPadding), position.y); float num = Bubble.GetComponent <RectTransform>().sizeDelta.x * 0.5f; float x = GetComponent <RectTransform>().anchoredPosition.x; float num2 = (float)Screen.width * vector.x - GetComponent <RectTransform>().anchoredPosition.x; if (x < num) { Bubble.GetComponent <RectTransform>().anchoredPosition = new Vector2(num - x, Bubble.GetComponent <RectTransform>().anchoredPosition.y); } else if (num2 < num) { Bubble.GetComponent <RectTransform>().anchoredPosition = new Vector2(0f - (num - num2), Bubble.GetComponent <RectTransform>().anchoredPosition.y); } }
private GameObject showTooltip(TutorialTooltip tooltip, RectTransform target, Vector2 offset, bool fullScreenClose) { if (currentTooltip != null) { currentTooltip.GetComponent <TutorialTooltip>().Hide(); } Vector2 vector = Vector2.zero; if (target != null) { vector = new Vector2(target.position.x, target.position.y); Canvas componentInParent = target.GetComponentInParent <Canvas>(); if (componentInParent.renderMode == RenderMode.ScreenSpaceCamera) { vector = RectTransformUtility.WorldToScreenPoint(componentInParent.worldCamera, vector); } } CanvasScalerExt component = GetComponentInParent <Canvas>().GetComponent <CanvasScalerExt>(); Vector2 vector2 = new Vector2(component.ReferenceResolutionY / (float)Screen.height, component.ReferenceResolutionY / (float)Screen.height); vector2 *= 1f / component.ScaleModifier; vector = new Vector2((vector.x + offset.x) * vector2.x, (vector.y + offset.y) * vector2.y); if (tooltip == null) { GameObject gameObject = Object.Instantiate(tooltipPrefab); tooltip = gameObject.GetComponent <TutorialTooltip>(); } tooltip.transform.SetParent(base.transform, worldPositionStays: false); tooltip.SetPosition(vector); tooltip.SetDefaultTextPrefab(defaultTextPrefab); tooltip.Show(); currentTooltip = tooltip.gameObject; FullScreenButton.SetActive(fullScreenClose); Service.Get <EventDispatcher>().DispatchEvent(new TutorialUIEvents.OnTooltipCreated(tooltip)); return(tooltip.gameObject); }
public void SetHighlight(DTutorialOverlay overlayData) { data = overlayData; Vector3 worldPoint = Vector3.zero; highlightSize = Vector2.zero; if (data.Target != null) { RectTransform component = data.Target.GetComponent <RectTransform>(); if (component != null) { Canvas componentInParent = data.Target.GetComponentInParent <Canvas>(); worldPoint = component.position; if (componentInParent.renderMode == RenderMode.ScreenSpaceCamera) { worldPoint = RectTransformUtility.WorldToScreenPoint(componentInParent.worldCamera, worldPoint); } if (data.AutoSize) { highlightSize = component.rect.size; } } else { worldPoint = Camera.main.WorldToScreenPoint(data.Target.transform.position); } } CanvasScalerExt component2 = GetComponentInParent <Canvas>().GetComponent <CanvasScalerExt>(); Vector2 a = new Vector2(component2.ReferenceResolutionY / (float)Screen.height, component2.ReferenceResolutionY / (float)Screen.height); a *= 1f / component2.ScaleModifier; int num = 0; DataEntityHandle entityByType = Service.Get <CPDataEntityCollection>().GetEntityByType <SystemBarsData>(); if (!entityByType.IsNull) { SystemBarsData component3 = Service.Get <CPDataEntityCollection>().GetComponent <SystemBarsData>(entityByType); num = component3.CurrentNavigationBarHeight; } if (data.Target != null) { highlightPosition = new Vector2((data.Position.x + worldPoint.x) * a.x, (data.Position.y - (float)num + worldPoint.y) * a.y); } else { highlightPosition = new Vector2((float)Screen.width * data.Position.x * a.x, (float)Screen.height * (data.Position.y - (float)num) * a.y); } highlightSize += data.Size; Color color = new Color(1f, 1f, 1f, Mathf.Clamp(data.Opacity, 0f, 1f)); BackgroundShape.GetComponent <Image>().sprite = getShapeSprite(data.Shape); BackgroundShape.GetComponent <Image>().color = color; LeftBG.GetComponent <Image>().color = color; RightBG.GetComponent <Image>().color = color; TopBG.GetComponent <Image>().color = color; BottomBG.GetComponent <Image>().color = color; updateBackground(); updatePopup(); isShowing = true; base.gameObject.SetActive(value: true); if (data.DisableUI) { Service.Get <EventDispatcher>().DispatchEvent(default(UIDisablerEvents.DisableAllUIElements)); Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.DisableUIElement("Joystick")); if (data.Target != null && data.EnableTarget) { UIElementDisabler component4 = data.Target.GetComponent <UIElementDisabler>(); if (component4 != null) { Service.Get <EventDispatcher>().DispatchEvent(new UIDisablerEvents.EnableUIElement(component4.UIElementID)); } } } UpdateHighlightOutline(data.ShowHighlightOutline); enableUIElementsOnClose = data.DisableUI; GetComponent <CanvasGroup>().blocksRaycasts = data.BlocksRaycast; Service.Get <BackButtonController>().Add(onBackClicked); }
private void Start() { scaler = GetComponentInParent <CanvasScalerExt>(); Service.Get <EventDispatcher>().AddListener <AccessibilityEvents.AccessibilityScaleModifierRemoved>(onAccessibilityModifierRemoved); modifyCanvasAccessibilityScale(); }