Version: 5.6
public UI.ScrollRect.ScrollRectEvent onValueChanged ;

설명

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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961