Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Graph Port API OnConnect/Disconnect are internal??

Discussion in 'UI Toolkit' started by LaneFox, Jul 28, 2022.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    upload_2022-7-28_14-50-4.png

    Is there a valid reason why these are not public? Deliberately disabling the ability to easily know when connection changes occur seems like a backwards design decision.
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    I've located a similar thread but it directs to
    GraphView.graphViewChanged
    which does not supply a comparable solution.

    Code (csharp):
    1.   public struct GraphViewChange
    2.   {
    3.     public List<GraphElement> elementsToRemove;
    4.     public List<Edge> edgesToCreate;
    5.     public List<GraphElement> movedElements;
    6.     public Vector2 moveDelta;
    7.   }
    Why is there no simple way to get a callback when an port is connected or disconnected? This seems like an extremely basic ask, with an extremely obscure and unwieldly alternative for no apparent reason.
     
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
  4. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    The only reason GraphView was made public is for packages built by Unity, like Shader Graph and Visual Effect Graph.
    We purposefully made the API envelope limited to what these products needed access to.

    The main reason we use internal by default is that documentation and maintenance of API is very expensive, even when only used by packages maintained by Unity.

    Of course you can use the trick demonstrated above. When you do you are making a conscious decision to cross that bridge. It's fine if you can plan for upgrades and API breakage - but it's really an advanced workflow that we don't recommended everyone use.
     
  5. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Well that's news.

    Is the intention to make the Graph API more accessible to users in the future? In other words, when planning for "API breakage", should I be planning for Unity to continue to obscure basic API from users when it is no longer in an experimental state?

    I was under the impression that the this all would eventually be considered a standard part of Unity, and usage would be promoted for editor extensions.
     
  6. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    There a separate project now that is aimed at replacing GraphView and offer something to the general user base:
    https://forum.unity.com/threads/graph-tool-foundation.1057667/
     
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Which creates a circular reference back to the Graph API since it is no longer being developed (or at least publicly).
     
    SolarianZ and awesomedata like this.
  8. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Would you mind giving more details?

    Are you saying that we should be using the old 'experimental' tech instead of planning for a new version of the Graph Tools Foundation?

    I'm not sure I'm following. Did the GTF team get laid off too or something??
     
  9. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    I am not suggesting any of that, sorry I wasn't clear.
    I was mentioning that Unity is working on Graph Tools Foundation as a more broadly available framework than GraphView ever was.

    I was trying to give some perspective as to why the GraphView is still experimental and largely undocumented.
     
  10. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Ah, I see. You had me going for a second.

    So, if I'm understanding correctly, what you're saying is that its scope is more akin to UI Toolkit and UI Elements now, rather than a more specific implementation of just graph-based tooling?
     
  11. antoine-unity

    antoine-unity

    Unity Technologies

    Joined:
    Sep 10, 2015
    Posts:
    771
    awesomedata likes this.