Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug GraphView features broken on Unity 2022.3.13f1

Discussion in 'Scripting' started by Sadyk, Apr 26, 2024.

  1. Sadyk


    Feb 2, 2014

    I was unsure about where I should put this thread, I putted it here since I didn't really found a more suitable place.

    I have a GraphView based utility that I developed for a project a few years ago. This utility works great, it is based on the experimental package GraphView and it allows me to create complex narrative structures. The project I made it for was from 2021.3.13f1.

    I am currently working on a new project on 2022.3.13f1 and tried to import this utility and at the beginning it was flawless, until I tried to create nodes that have extra output ports.

    It seems it just doesn't create them at all, instead it shows some elements bad placed and doesn't even create the ports. What used to look like this:

    Now looks like this:

    The code is exactly the same, here I can show you the code I am using to create new options:

    Code (CSharp):
    1.         public void AddChoicePort(string portText = "")
    2.         {
    3.             var generatedPort = GetPortInstance(this, Direction.Output, Port.Capacity.Multi);
    4.             var portLabel = generatedPort.contentContainer.Q<Label>("type");
    5.             generatedPort.contentContainer.Remove(portLabel);
    7.             var outputPortCount = outputContainer.Query("connector").ToList().Count();
    8.             var outputPortName = $"Option{outputPortCount}";
    11.             var textField = new TextField()
    12.             {
    13.                 name = "TextField",
    14.                 value = (portText.Equals("")) ? outputPortName : portText
    15.             };
    16.             textField.RegisterValueChangedCallback(evt => generatedPort.portName = evt.newValue);
    17.             generatedPort.contentContainer.Add(new Label("  "));
    18.             generatedPort.contentContainer.Add(textField);
    19.             var deleteButton = new Button(() => RemovePort(generatedPort))
    20.             {
    21.                 text = "X"
    22.             };
    23.             generatedPort.contentContainer.Add(deleteButton);
    24.             generatedPort.portName = outputPortName;
    25.    = outputPortName;
    26.             outputContainer.Add(generatedPort);
    27.             RefreshPorts();
    28.             RefreshExpandedState();
    29.         }
    It is really frustrating since documentation doesn't show any reason why this might happen, there is almost no resources online about this and there is no error or issue with the code, since it is implemented following the documentation and it worked perfectly on 2021 version.

    - Is there a change I am unaware of that I need to take into account to make this work?
    - Is my only solution to downgrade the project? Since remaking a narrative tool from scratch seems like an overkill.

    I have checked the current docs and don't see a reason why this shouldn't work.

    I appreciate your time, any insight that might help me look on the right direction will be really apreciated.

  2. CodeSmile


    Apr 10, 2014
    This looks like a styling issue. Perhaps general changes made to UI Toolkit affect this.
    Since you aren't on the latest patch release I'd try updating first (25f1 I believe is the most recent).
    And if the issue persists, use the UI Toolkit debugger to analyze that node's elements and styles, ideally compare it with the 2021.3 version to look for any differences that you can straighten out yourself.
  3. Sadyk


    Feb 2, 2014
    Hi CodeSmile,
    I've tried to upgrade as you said but it didnt make a difference.
    I've been also inspecting through the debugger but cant really figure out nothing wrong:


    All the output section is displaced, but all elements that are inside of the OptionsNode have max-width:none and width:auto, so as far as I know everything should be in place. And even on other elements that dont use the output as much but have the data in other parts dont have any problem and scale nicely. Whatever the issue seems to be with the #output element... If it really is a styling issue I cant figure out what parameter is breaking it.
  4. Sadyk


    Feb 2, 2014
    Okey, after tweeking some time I figured out that by adding the following:

    Code (CSharp):
    1. OptionsNode #output, EventSwitchNode #output {
    2.     max-width: 75%;
    3. }
    4. OptionsNode #TextField, EventSwitchNode #TextField  {
    5.     max-width: 50%;
    6. }
    Now looks as intended. Still I am not sure what caused the issue, but this workaround works for me.