Search Unity

Feature Request Accessing to entities windows

Discussion in 'Entity Component System' started by Tony_Max, Mar 17, 2023.

  1. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    In my system https://github.com/Antoshidza/NSprites I want to debug users entity composition and inform him if system detect any issues. To do so I validate
    EntityArchetype
    , then I pring issue report as
    Debug.LogError
    .

    The problem is I can't refer problematic
    EntityArchetype
    more handy than just printing it's hex hash, so user than should go Window -> Entities -> Archetypes and find manually or user search bar, so he could inspect archetype which my system described as problematic. This is already possible to rapidly copy past hash and inspect archetype, yes, we can end right here. But I want to make it a little bit handy: open / get new Archetypes window and fill search bar. The latter I believe can be done by accessing window's root element and just searching for search element by name we can know by debugging UI in editor. Though I can't access most unity built-in windows.

    Please, let us at least control windows's selection / search bars / etc, all things which can only be touched by user's input.
    If anybody knows smart way of accessing built-in window please let me know :)
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    It’s pretty simple, you just get assembly where it lies and get ArchetypesWindow class by it’s name. As far as you have required type you can do whatever you want - show window, get uxml DOM and query/modify elements etc.
    upload_2023-3-18_14-23-46.png

    Code (CSharp):
    1. [MenuItem("DNO/Archetypes")]
    2. public static void ArchetypesWindowGetter()
    3. {
    4.     var archetypesWindowType = typeof(Unity.Entities.Editor.ExtraTypesProvider).Assembly.GetType("Unity.Entities.Editor.ArchetypesWindow");
    5.     var archetypesWindow = EditorWindow.GetWindow(archetypesWindowType);
    6.     var searchInput = archetypesWindow.rootVisualElement.Q<TextField>(name: "search-element-text-field-search-string");
    7.     searchInput.value = "My search string value";
    8. }
    upload_2023-3-18_14-23-39.png
     
    Tony_Max likes this.
  3. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    353
    ExtraTypesProvider
    is private as any type else in it's assembly, so I guess I should access to assembly different way, maybe just filtering all assemblies by name
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    Ah they've hide many types in 1.0 (we're on 0.51)
     
    Tony_Max likes this.