Beispiel #1
0
        /// <summary>
        /// Tries to add the UI Element as a scrollable. Returns true if it succeeded, false if it didn't.
        /// </summary>
        public bool AddScrollable(UIElement uiElement)
        {
            if (uiElement is IScrollable scrollable)
            {
                Scrollables.Add(scrollable);

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a UI Element and makes it interactable if it implements <see cref="IInteractable"/> and scrollable if it implements <see cref="IScrollable"/>.
        /// </summary>
        /// <typeparam name="T">UIElement descendant of type T.</typeparam>
        /// <param name="uiElement">The UI Element to add.</param>
        /// <returns>Returns the craeted UI Element.</returns>
        public T AddUIElement <T>(T uiElement) where T : UIElement
        {
            UIElements.Add(uiElement);

            if (uiElement is IInteractable interactable)
            {
                Interactables.Add(interactable);
            }

            if (uiElement is IScrollable scrollable)
            {
                Scrollables.Add(scrollable);
            }

            return(uiElement);
        }