public void Load (string id, View view) { if (activeContainer == null) { // Initialize if this is the first time loading a view activeContainer = container1; activeContainer.LoadView (id, view); activeContainer.SetInputEnabled (); inactiveContainer = container2; inactiveContainer.RectTransform.SetAnchoredPositionX (canvasWidth); } else { inactiveContainer.LoadView (id, view); // Trigger the slide animation // If the new screen and previous screen have a transition override specified, use that // Otherwise, use the default behaviour bool slideIn; if (transitionOverrides.TryGetValue (prevId + " " + id, out slideIn)) { if (slideIn) { SlideIn (); } else { SlideOut (); } } else { if (inactiveContainer.TemplateIsBefore (id, prevId)) { SlideOut (); } else { SlideIn (); } } } prevId = id; }
void Slide(float to) { if (anim.Animate(new UIAnimator.Slide(slideTime, to, () => { // Normalize positions inactiveContainer.RectTransform.SetAnchoredPositionX(0f); activeContainer.RectTransform.SetAnchoredPositionX(-to); RectTransform.SetAnchoredPositionX(0f); // Unload the previous view activeContainer.UnloadView(); // Swap the active and inactive containers UpdateActiveContainer(); // Inform the newly active container that the animation has finished & input is being accepted activeContainer.SetInputEnabled(); // Enable the raycaster so that input is accepted again (small pause so that players don't accidently 'double press' buttons) Co.WaitForSeconds(0.05f, () => { Raycaster.enabled = true; }); }))) { // Disable the raycaster while animating so that the user can't "double press" buttons Raycaster.enabled = false; inactiveContainer.RectTransform.SetAnchoredPositionX(-to); } }
public void Load(string id, View view) { if (activeContainer == null) { // Initialize if this is the first time loading a view activeContainer = container1; activeContainer.LoadView(id, view); activeContainer.SetInputEnabled(); inactiveContainer = container2; inactiveContainer.RectTransform.SetAnchoredPositionX(canvasWidth); } else { inactiveContainer.LoadView(id, view); // Trigger the slide animation // If the new screen and previous screen have a transition override specified, use that // Otherwise, use the default behaviour bool slideIn; if (transitionOverrides.TryGetValue(prevId + " " + id, out slideIn)) { if (slideIn) { SlideIn(); } else { SlideOut(); } } else { if (inactiveContainer.TemplateIsBefore(id, prevId)) { SlideOut(); } else { SlideIn(); } } } prevId = id; }