Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Graph View Editor Questions

Discussion in 'Editor & General Support' started by hzekigogebakan, Jan 4, 2024.

  1. hzekigogebakan

    hzekigogebakan

    Joined:
    May 22, 2023
    Posts:
    2
    Greetings, I need to automatically create nodes in the tool I wrote and I need to sort and position these nodes in an orderly way.

    The answers I am looking for are :
    1. When I set the automatic formation of nodes to the port connection of the nodes, I realized that when the nodes are formed, the position and scale in the layout can be NaN, so I cannot perform alignment operations. What should I do to prevent this from happening ?
    2. What do I need to reference to use information such as size position of nodes, layout ? content rect ? local bound ? world bound ? what are the differences between them ?
    3. How can I handle the drawing of a node in a guaranteed way ? My current approach works as follows, when I run a method that can change the graph in any way, I make the bool
      Code (CSharp):
      1. graphicsReady = false
      in this way, then
      Code (CSharp):
      1. RegisterCallback<GeometryChangedEvent>(OnGeometryChange);
      I wait with this callback.

    Then I run a structure like below and run the actions registered to the OnGeometryChanged action and try to understand that it is ready, how can I make a more accurate solution?

    Code (CSharp):
    1. protected virtual void OnGeometryChange(GeometryChangedEvent evt)
    2.         {
    3.             if (!_isGeometryReady)
    4.             {
    5.                 _isGeometryReady = true;
    6.                 OnGeometryChanged?.Invoke(evt);        
    7.             }
    8.         }