private void Create(string name, IUIArguments arguments, bool swallow) { UIController controller = uIResourceAgent.Load(name); if (controller == null) { return; } if (controller.Name != name) { Debug.LogWarning($"The name of UIController '{controller.Name}' does not match the UI name '{name}'!"); } var uiInfo = new UIInfo { controller = controller, arguments = arguments, swallow = swallow, }; uiStack.Push(uiInfo); CheckSwallow(); var depth = uiStack.Count - 1; this.uIDepthAgent.SetDepth(controller.gameObject, depth); controller.OnCreate(arguments); controller.OnOpen(arguments, depth); controller.OnTop(); }
/// <summary> /// Open a UI. /// </summary> /// <param name="name">The name of the UI.</param> /// <param name="arguments">The arguments passed to the UI.</param> /// <param name="swallow">Whether the UI should swallow UIs beneath it.</param> /// <param name="duplicate">Whether the UI can be duplicated.</param> public void Open(string name, IUIArguments arguments = null, bool swallow = false, bool duplicate = false) { if (duplicate) { Create(name, arguments, swallow); } else { int index = FindUIIndex(name); if (index >= 0) { CloseTo(index, true); } else { Create(name, arguments, swallow); } } }
public override void OnOpen(IUIArguments arguments, int depth) { base.OnOpen(arguments, depth); var _args = (UIHeroDetailArguments)arguments; if (_args != null) { heroID = _args.heroID; string heroImagePath = $"Arts/UI2/HeroIcon/{heroID}/HeroSkin/{heroID}2101"; var sprites = Resources.LoadAll <Sprite>(heroImagePath); if (sprites.Length == 0) { Debug.LogWarning($"Load '{heroImagePath}' failed!"); return; } heroImage.sprite = sprites[0]; } }
public virtual void OnOpen(IUIArguments arguments, int depth) { Debug.Log($"UIController '{this.Name}' opened with arguments {arguments} and depth {depth}."); }
public virtual void OnCreate(IUIArguments arguments) { Debug.Log($"UIController '{this.Name}' created with arguments {arguments}."); }
public override void OnOpen(IUIArguments arguments, int depth) { base.OnOpen(arguments, depth); LoadHeroCards(); }