Version: 2017.2

ScrollRect.onValueChanged

Cambiar al Manual
public UI.ScrollRect.ScrollRectEvent onValueChanged ;

Descripción

Callback executed when the position of the child changes.

onValueChanged is used to watch for changes in the ScrollRect object. The onValueChanged call will use the UnityEvent.AddListener API to watch for changes. When changes happen script code provided by the user will be called. The UnityEvent.AddListener API for ScrollRect.onValueChanged takes a Vector2.

Note: The editor allows the onValueChanged value to be set up manually. For example the value can be set to run only a runtime. The object and script function to call are also provided here.

The onValueChanged variable can be alternatively set-up at runtime. The script example below shows how this can be done. The script is attached to the ScrollRect object.

using UnityEngine;
using UnityEngine.UI;

public class ExampleScript : MonoBehaviour { static ScrollRect scrollRect;

void Start() { scrollRect = GetComponent<ScrollRect>(); scrollRect.onValueChanged.AddListener(ListenerMethod); }

public void ListenerMethod(Vector2 value) { Debug.Log("ListenerMethod: " + value); } }