private void Update() { Debug.Log(EventSystem.current.currentSelectedGameObject); if ((transform.gameObject.activeSelf) && EventSystem.current.currentSelectedGameObject != null) { Vector3 newPosition = scrollRect.GetSnapToPositionToBringChildIntoView(EventSystem.current.currentSelectedGameObject.GetComponent <RectTransform>()); scrollRect.content.localPosition = Vector3.Lerp(scrollRect.content.localPosition, newPosition, Time.deltaTime * 2.0f); } }
private void Update() { if (selectedTransform) { scrollRect.content.localPosition = scrollRect.GetSnapToPositionToBringChildIntoView(selectedTransform); } else { scrollRect.content.localPosition = Vector3.zero; } }
public void ReactToItemHover(ItemPane itemPane) { if (selectSound != null) { SoundManager.UISound(selectSound); } scrollView.content.localPosition = new Vector2( scrollView.content.localPosition.x, scrollView.GetSnapToPositionToBringChildIntoView(itemPane.GetComponent <RectTransform>()).y ); ShowItemInfo(itemPane.storedItem); }
public void Select(RectTransform target) { if (this.target) { this.target.localScale = scale; } this.target = target; this.target.localScale = scale * selectScale; targetPos = scrollRect.GetSnapToPositionToBringChildIntoView(target); }
protected override void Start() { base.Start(); back.onClick.AddListener(MainUi.ShowMain); CurrentPageState .Where(state => state == PageState.Open) .Select(state => RxExtensions.FromAsync(CreateViews)) .Switch() .CombineWithPrevious((previous, next) => (previous, next)) .Select(combination => OnChangeLevelViews(combination.previous, combination.next)) .Select(icon => RxExtensions.FromAsync(async token => { if (icon != default) { await scrollRect .GetSnapToPositionToBringChildIntoView(icon.RectTransform, 0.6f) .ToUniTask(cancellationToken: token); } })) .Switch() .Subscribe() .AddTo(this); }
public void ReactToItemHover(ItemPane itemPane) { audioSource.PlayOneShot(audioSource.clip); scrollView.content.localPosition = scrollView.GetSnapToPositionToBringChildIntoView(itemPane.GetComponent <RectTransform>()); ShowItemInfo(itemPane.inventoryItem); }
public void SnapTo(RectTransform target) { scrollView.content.localPosition = scrollView.GetSnapToPositionToBringChildIntoView(target); }
public virtual void OnSelect(BaseEventData eventData) { scrollParent.content.localPosition = scrollParent.GetSnapToPositionToBringChildIntoView(transform); }