ChangePageAction.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using FairyGUI.Utils;
  2. namespace FairyGUI
  3. {
  4. public class ChangePageAction : ControllerAction
  5. {
  6. public string objectId;
  7. public string controllerName;
  8. public string targetPage;
  9. public ChangePageAction()
  10. {
  11. }
  12. override protected void Enter(Controller controller)
  13. {
  14. if (string.IsNullOrEmpty(controllerName))
  15. return;
  16. GComponent gcom;
  17. if (!string.IsNullOrEmpty(objectId))
  18. gcom = controller.parent.GetChildById(objectId) as GComponent;
  19. else
  20. gcom = controller.parent;
  21. if (gcom != null)
  22. {
  23. Controller cc = gcom.GetController(controllerName);
  24. if (cc != null && cc != controller && !cc.changing)
  25. {
  26. if (this.targetPage == "~1")
  27. {
  28. if (controller.selectedIndex < cc.pageCount)
  29. cc.selectedIndex = controller.selectedIndex;
  30. }
  31. else if (this.targetPage == "~2")
  32. cc.selectedPage = controller.selectedPage;
  33. else
  34. cc.selectedPageId = this.targetPage;
  35. }
  36. }
  37. }
  38. override public void Setup(ByteBuffer buffer)
  39. {
  40. base.Setup(buffer);
  41. objectId = buffer.ReadS();
  42. controllerName = buffer.ReadS();
  43. targetPage = buffer.ReadS();
  44. }
  45. }
  46. }