Away









How do I use Away
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ScrollSnapBase.cs Copy
192   internal void UpdateVisible()
193   {
194    //If there are no objects in the scene or a mask, exit
195             if (!MaskArea || ChildObjects == null || ChildObjects.Length < 1 || _screensContainer.childCount < 1)
196    {
197     return;
198    }
199
200    _maskSize = _isVertical ? MaskArea.rect.height : MaskArea.rect.width;
201    _halfNoVisibleItems = (int)Math.Round(_maskSize / (_childSize * MaskBuffer), MidpointRounding.AwayFromZero) / 2;
202    _bottomItem = _topItem = 0;
203    //work out how many items below the current page can be visible
204             for (int i = _halfNoVisibleItems + 1; i > 0; i--)
205    {
206     _bottomItem = _currentPage - i < 0 ? 0 : i;
207     if (_bottomItem > 0) break;
208    }
209
210    //work out how many items above the current page can be visible
211             for (int i = _halfNoVisibleItems + 1; i > 0; i--)
212    {
213     _topItem = _screensContainer.childCount - _currentPage - i < 0 ? 0 : i;
214     if (_topItem > 0) break;
215    }
216
217    //Set the active items active
218             for (int i = CurrentPage - _bottomItem; i < CurrentPage + _topItem; i++)
219    {
220     try
221     {
222      ChildObjects[i].SetActive(true);
223     }
224     catch
225     {
226      Debug.Log("Failed to setactive child [" + i + "]");
227     }
228    }
229
230    //Deactivate items out of visibility at the bottom of the ScrollRect Mask (only on scroll)
231    if (_currentPage > _halfNoVisibleItems) ChildObjects[CurrentPage - _bottomItem].SetActive(false);
232    //Deactivate items out of visibility at the top of the ScrollRect Mask (only on scroll)
233    if (_screensContainer.childCount - _currentPage > _topItem) ChildObjects[CurrentPage + _topItem].SetActive(false);
234   }

Away 131 lượt xem

Gõ tìm kiếm nhanh...