Version: 2021.3
public SerializedProperty GetEndProperty ();
public SerializedProperty GetEndProperty (bool includeInvisible);

描述

检索定义此属性起始范围的 SerializedProperty。

这是除此属性子孙属性之外的第一个属性。 借助端点属性,可使用 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<GetEndPropertyExample>(); 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) &amp;&amp; !SerializedProperty.EqualContents(property, endOfChildrenIteration)) { Debug.Log(property.propertyPath + " : " + property.floatValue); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961