文档

Unity Engine

Unity Engine

FindProperty(string)

Find serialized property by name.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor
public SerializedProperty FindProperty(string propertyPath)

Parameters

propertyPath

Returns

Type

Description

SerializedProperty

Remarks

You can use this to find a specific property in the target object.

Examples

using UnityEngine;using UnityEditor;public class MyObject : ScriptableObject{ public int myInt = 42;}public class SerializedPropertyTest : MonoBehaviour{ void Start() { MyObject obj = ScriptableObject.CreateInstance<MyObject>(); SerializedObject serializedObject = new UnityEditor.SerializedObject(obj); SerializedProperty serializedPropertyMyInt = serializedObject.FindProperty("myInt"); Debug.Log("myInt " + serializedPropertyMyInt.intValue); }}