Ignition / ScrollBox
Namespace
Playniax.Ignition.UIInherits from
MonoBehaviourScript can be found in
Assets/Playniax/Framework/Ignition/Framework/UI/Scripts (MonoBehaviour)/ScrollBox.cs
Class ScrollBox
DescriptionThe scrollbox supports text, url links and images and it has its own scripting language.
Public fields | Description |
---|
TextAsset externalScript | The external script file to use for content generation. |
bool useExternalScript | Flag indicating whether to use an external script for content generation. |
string start | The starting position within the scroll box. |
string dataBreak = "&" | The character used to break data fields within the script. |
string lineBreak = "|" | The character used to break lines within the script. |
bool allCaps = false | Flag indicating whether to convert text to all capital letters. |
AssetBank assetBank | The asset bank to use for content generation. |
GameObject content | The container for scroll box content. |
float contentHeight | The height of the scroll box content. |
Public Methods | Description |
---|
GameObject Contains(string value) | Returns GameObject if it contains value. |
void SetPosition(string value) | Sets the scrollbox position by value. |
See
ScrollBox Scripting for a more in-depth explanation.
Example
Example can be found in
Assets/Playniax/Framework/Ignition/Scenes/02 - Framework UI/01 - Scrollbox/Scenes/Scrollbox Tabs.unityExample script can be found in
Assets/Playniax/Framework/Ignition/Scenes/02 - Framework UI/01 - Scrollbox/Scripts (MonoBehaviour)/SetPosition_Example.cs
using UnityEngine;
using UnityEngine.UI;
using Playniax.Ignition.UI;
public class SetPosition_Example : MonoBehaviour
{
public string text;
public Button button;
public ScrollBoxSwipe scrollBoxSwipe;
void Awake()
{
// Below some fancy code to assign the component variables:
// Try to find ScrollBoxSwipe component in the scene.
if (scrollBoxSwipe == null) scrollBoxSwipe = FindObjectOfType<>ScrollBoxSwipe>();
// Try to find the button.
if (button == null) button = GetComponent<>Button>();
// Add a listener for detecting button click.
if (button && scrollBoxSwipe && text != "") button.onClick.AddListener(OnClick);
}
void OnClick()
{
// Stop scrolling.
scrollBoxSwipe.Stop();
// Set scroll position using the button text as keyword.
if (scrollBoxSwipe.scrollBox) scrollBoxSwipe.scrollBox.SetPosition(text);
}
}