バージョン: 2021.3 以降
バインディングパスを使う代わりに BindProperty() を呼び出して、要素を SerializedProperty オブジェクトに直接バインドすることができます。この例は BindProperty() を使ってバインドする方法を紹介します。
この例ではカスタムエディターウィンドウを作成して、ゲームオブジェクトの名前を変更します。
この例で作成するすべてのファイルは、GitHub リポジトリ にあります。
This guide is for developers familiar with the Unity Editor, UI Toolkit, and C# scripting. You are recommended to have a basic understanding of the following:
BindProperty() を使ってバインドするC# で、TextField を持つカスタムのエディターウィンドウを作成します。ゲームオブジェクトの name プロパティを検索し、BindProperty() メソッドを使用してプロパティに直接バインドします。
Project ウィンドウに、bind-without-binding-path という名前のフォルダーを作成し、ファイルを保存してください。
bind-without-binding-path フォルダー内に、Editor という名前のフォルダーを作成します。
Editor フォルダーに、SimpleBindingPropertyExample.cs という名の C# スクリプトを作成し、そのコンテンツを以下と置き換えます。 
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UIToolkitExamples
{
    public class SimpleBindingPropertyExample : EditorWindow
    {
        TextField m_ObjectNameBinding;
        [MenuItem("Window/UIToolkitExamples/Simple Binding Property Example")]
        public static void ShowDefaultWindow()
        {
            var wnd = GetWindow<SimpleBindingPropertyExample>();
            wnd.titleContent = new GUIContent("Simple Binding Property");
        }
        
        public void CreateGUI()
        {
            m_ObjectNameBinding = new TextField("Object Name Binding");
            rootVisualElement.Add(m_ObjectNameBinding);
            OnSelectionChange();
        }
        public void OnSelectionChange()
        {
            GameObject selectedObject = Selection.activeObject as GameObject;
            if (selectedObject != null)
            {
                // Create the SerializedObject from the current selection
                SerializedObject so = new SerializedObject(selectedObject);
                // Note: the "name" property of a GameObject is actually named "m_Name" in serialization.
                SerializedProperty property = so.FindProperty("m_Name");
                // Bind the property to the field directly
                m_ObjectNameBinding.BindProperty(property);
            }
            else
            {
                // Unbind any binding from the field
                m_ObjectNameBinding.Unbind();
            }
        }
    }
}