Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question What is "Serialized Data Mode Controller" in a UI ToolKit Editor Window instance?

Discussion in 'UI Toolkit' started by vonchor, Jan 28, 2023.

  1. vonchor

    vonchor

    Joined:
    Jun 30, 2009
    Posts:
    238
    I'm trying to debug a strange problem and came across the fields shown in the image. Is this something to do with the persisted view data? Do I need to do anything with the Data Mode selection? (This has nothing to do with what I'm trying to troubleshoot, more like what is it?)

    I can't find any documentation about this so I assume it's ignorable for editor windows...

    Clipboard01.png
     
  2. loonyq

    loonyq

    Joined:
    Feb 24, 2019
    Posts:
    2
    If you are using Odin, this is my fix for OdinEditorWindow.

    Code (CSharp):
    1. using Sirenix.OdinInspector.Editor;
    2. using UnityEditor;
    3.  
    4. public class OdinEditorWindowFixed : OdinEditorWindow
    5. {
    6.      private SerializedObject _serializedObject;
    7.      private PropertyTree _propertyTree;
    8.      protected override void OnEnable()
    9.      {
    10.          base.OnEnable();
    11.          _serializedObject = new SerializedObject(this);
    12.          _propertyTree = PropertyTree.Create(_serializedObject);
    13.      }
    14.    
    15.      protected override void OnGUI()
    16.      {
    17.          EditorGUI.BeginChangeCheck();
    18.          _propertyTree.UpdateTree();
    19.          foreach (var property in _propertyTree.EnumerateTree())
    20.          {
    21.              if (!property.PrefabModificationPath.Contains("m_SerializedDataModeController"))
    22.              {
    23.                  property.Draw();
    24.              }
    25.          }
    26.          if (EditorGUI.EndChangeCheck())
    27.          {
    28.              _propertyTree.ApplyChanges();
    29.          }
    30.      }
    31.      protected override void OnDisable()
    32.      {
    33.          base.OnDisable();
    34.          _propertyTree.Dispose();
    35.      }
    36. }