/// <summary> /// Initialise this Page object and attach it to its parent PagedRect. /// </summary> /// <param name="pagedRect"></param> public void Initialise(PagedRect pagedRect) { if (Initialised) { return; } initialPosition = this.transform.localPosition; Initialised = true; _pagedRect = pagedRect; UpdateDimensions(); if (Application.isPlaying) { if (!pagedRect.UsingScrollRect) { Animator = this.GetComponent <Animator>(); if (Animator == null) { // setup the animator for this page Animator = this.gameObject.AddComponent <Animator>(); } Animator.runtimeAnimatorController = Instantiate(pagedRect.AnimationControllerTemplate) as RuntimeAnimatorController; } else { Animator = this.GetComponent <Animator>(); if (Animator != null) { Animator.enabled = false; } } if (pagedRect.ShowPagePreviews) { PagedRectTimer.DelayedCall(0, () => { if (pagedRect.CurrentPage != this.PageNumber) { ShowOverlay(); } }, this); } } }
public void Initialise(Page page, PagedRect pagedRect) { m_page = page; m_pagedRect = pagedRect; var rectTransform = this.transform as RectTransform; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.one; rectTransform.localScale = Vector3.one; Image.color = m_pagedRect.PagePreviewOverlayNormalColor; Image.sprite = m_pagedRect.PagePreviewOverlayImage; }
public override void OnBeginDrag(PointerEventData eventData) { if (DisableDragging) { return; } ResetDragOffset = false; if (notifyPagedRect && PagedRect != null) { PagedRect.OnBeginDrag(eventData); } base.OnBeginDrag(eventData); isBeingDragged = true; }
public override void OnDrag(PointerEventData eventData) { if (DisableDragging) { return; } if (!isBeingDragged) { return; } // If this is a horizontal PagedRect, only accept horizontal drag events, and vice versa if this is a Vertical PagedRect var analysis = AnalyseDragEvent(eventData); if (this.horizontal && analysis.DragPlane != DragEventAnalysis.eDragPlane.Horizontal) { return; } if (this.vertical && analysis.DragPlane != DragEventAnalysis.eDragPlane.Vertical) { return; } if (ResetDragOffset) { notifyPagedRect = false; OnEndDrag(eventData); OnBeginDrag(eventData); notifyPagedRect = true; } if (PagedRect != null) { PagedRect.OnDrag(eventData); } base.OnDrag(eventData); }
public override void OnEndDrag(PointerEventData eventData) { if (DisableDragging) { return; } if (!isBeingDragged) { return; } // we're no longer being dragged isBeingDragged = false; // Notify PagedRect (so it can handle any OnEndDrag events if necessary) if (notifyPagedRect && PagedRect != null) { PagedRect.OnEndDrag(eventData); } base.OnEndDrag(eventData); }
public void Initialise(PagedRect pagedRect) { this._pagedRect = pagedRect; }