SerializedProperty.GetEndProperty

Unity · Версия 2020.3 LTS · Scripting · SerializedProperty

SerializedProperty.GetEndProperty

Объявление

public SerializedProperty GetEndProperty();

public SerializedProperty GetEndProperty(bool includeInvisible);

Описание

Получает SerializedProperty, определяющий конечный диапазон этого свойства.

Это первый ресурс, который не является дочерним или внуком этого ресурса. Свойство end можно использовать для перебора всех дочерних элементов свойства с помощью EqualContents.

using UnityEditor;
using UnityEngine;

public class GetEndPropertyExample : ScriptableObject
{
    public Vector2 m_vector2 = new Vector2(1.0f, 2.0f);
    public bool m_bool = false;

    [MenuItem("Example/SerializedProperty GetEndProperty Example")]
    static void Example()
    {
        GetEndPropertyExample obj = ScriptableObject.CreateInstance();
        SerializedObject serializedObject = new SerializedObject(obj);
        SerializedProperty property = serializedObject.FindProperty("m_vector2");

        // Visit the x, y values of the vector, stopping once m_bool is reached
        var endOfChildrenIteration = property.GetEndProperty();
        while (property.NextVisible(true) && !SerializedProperty.EqualContents(property, endOfChildrenIteration))
        {
            Debug.Log(property.propertyPath + " : " + property.floatValue);
        }
    }
}

Обновлено 17 ноября 2026 г.