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.

How to delete a transition from the transition table?

Discussion in 'Open Projects' started by Arthur_Gentz, May 4, 2021.

  1. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    I've been merrily making states and actions and having a good time. Today though, i needed to delete a transition from the transition table, and whenever I click the minus icon on the table inspector/table editor, i get a bunch of NullReference exceptions while the table inspector disappears out of focus. Is this a bug? or is deletion of transitions still pending functionality?
     
  2. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    On any particular state? Or one that you made?
    I just tried and it works fine for me. Are conditions null in your case? (maybe that's the key? would be weird though)
    Maybe you can post a photo of how the transition table looks like.
     
  3. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    Then I'm doing something wrong, could you post a gif showing how you delete transitions please? Here's the transition table in the Inspector and in the Table Editor:

     
  4. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    It's really not anything different, from your screenshot I would just press the (-) button next to the wrench in the "To Sailing" transition, and it would be gone.
    What's the error you get in the console?
     
  5. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    It's a cascade of errors, brace yourself.
    First Error:
    "
    Retrieving array element that was out of bounds
    UnityEditor.SerializedProperty:get_objectReferenceValue()
    UOP1.StateMachine.Editor.TransitionTableEditor:RemoveTransition(SerializedTransition) (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:310)
    UOP1.StateMachine.Editor.TransitionDisplayHelper:Display(Rect&) (at Assets/Scripts/StateMachine/Editor/Utilities/TransitionDisplayHelper.cs:69)
    UOP1.StateMachine.Editor.TransitionTableEditor:TransitionTableGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:181)
    UOP1.StateMachine.Editor.TransitionTableEditor:OnInspectorGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)"

    Second Error:
    "
    SerializedProperty _transitions.Array.data[36].FromState has disappeared!
    UnityEditor.SerializedProperty:get_objectReferenceValue()
    UOP1.StateMachine.Editor.TransitionTableEditor:RemoveTransition(SerializedTransition) (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:310)
    UOP1.StateMachine.Editor.TransitionDisplayHelper:Display(Rect&) (at Assets/Scripts/StateMachine/Editor/Utilities/TransitionDisplayHelper.cs:69)
    UOP1.StateMachine.Editor.TransitionTableEditor:TransitionTableGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:181)
    UOP1.StateMachine.Editor.TransitionTableEditor:OnInspectorGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)"

    Third Error:
    "
    type is not a supported pptr value
    UnityEditor.SerializedProperty:get_objectReferenceValue()
    UOP1.StateMachine.Editor.TransitionTableEditor:RemoveTransition(SerializedTransition) (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:310)
    UOP1.StateMachine.Editor.TransitionDisplayHelper:Display(Rect&) (at Assets/Scripts/StateMachine/Editor/Utilities/TransitionDisplayHelper.cs:69)
    UOP1.StateMachine.Editor.TransitionTableEditor:TransitionTableGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:181)
    UOP1.StateMachine.Editor.TransitionTableEditor:OnInspectorGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    "

    Fourth Error:
    "
    NullReferenceException: Object reference not set to an instance of an object
    UOP1.StateMachine.Editor.TransitionTableEditor.RemoveTransition (UOP1.StateMachine.Editor.SerializedTransition serializedTransition) (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:310)
    UOP1.StateMachine.Editor.TransitionDisplayHelper.Display (UnityEngine.Rect& position) (at Assets/Scripts/StateMachine/Editor/Utilities/TransitionDisplayHelper.cs:69)
    UOP1.StateMachine.Editor.TransitionTableEditor.TransitionTableGUI () (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:181)
    UOP1.StateMachine.Editor.TransitionTableEditor.OnInspectorGUI () (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <8d21067e8d9c494db25a2b2485216e63>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    "

    Fifth Error:
    "
    type is not a supported pptr value
    UnityEditor.SerializedProperty:get_objectReferenceValue()
    UOP1.StateMachine.Editor.TransitionTableEditor:TransitionTableGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:105)
    UOP1.StateMachine.Editor.TransitionTableEditor:OnInspectorGUI() (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    "

    Sixth Error:
    "
    NullReferenceException: Object reference not set to an instance of an object
    UOP1.StateMachine.Editor.TransitionTableEditor.TransitionTableGUI () (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:105)
    UOP1.StateMachine.Editor.TransitionTableEditor.OnInspectorGUI () (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:59)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <8d21067e8d9c494db25a2b2485216e63>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    "
     
    cirocontinisio likes this.
  6. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    Ignore the emojis, they are "colon [Some letter]" characters in the logs that the forum frontend formatted, not me.
     
  7. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    I'm not too sure, as I didn't make the tool. @deivsky do you have any idea?

    In any case, you could try debugging. Like, taking the first error, last function call, and see if in the place where the error occurs the data is how you expect it.

    UOP1.StateMachine.Editor.TransitionTableEditor:RemoveTransition(SerializedTransition) (at Assets/Scripts/StateMachine/Editor/TransitionTableEditor.cs:310)


    Check for instance if the name of the transition that's about to be deleted is correct, or the length of that array, etc.
     
  8. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    Okay, I'll dive in during the weekend -foreseeing too much "life" for the rest of the week. Then I'll report on my findings. Cheers.
     
    cirocontinisio likes this.
  9. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Always give "life" priority!
     
    Arthur_Gentz likes this.
  10. Arthur_Gentz

    Arthur_Gentz

    Joined:
    Jan 11, 2021
    Posts:
    22
    It turns out i just need to have another transition below the one i intend to delete. If you try to delete the current transition which also happens to be the "last" transition from that state, it blows up.
    E.g. say you have two transitions from some 'Run' state. The first being 'Run' -> 'Jump', and below it you have 'Run' -> 'Attack' . If you tried to delete 'Run' -> 'Attack' (the second transition), then it blows up. Though, if you tried to delete 'Run' -> 'Jump', it deletes successfully. So just make sure that whichever transition you want to delete is NOT THE LAST transition from that state.
     
  11. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Thanks a lot for the investigation, @Arthur_Gentz! We will try to fix the tool as we can, but it's also useful to work around the issue for now. @Amel-Unity, you might find the above interesting!

    Thanks again, Arthur!
     
    Arthur_Gentz and Amel-Unity like this.
  12. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
    I think I found the root of the problem -- the editor is trying to get the name of the transition's "From" state from an object that has already been deleted. That error cascades into a bunch of others. Simple fix is to grab that string before the deletion happens.

    Take my patch for a spin and let me know if it's fixed for you? https://github.com/pointfivetee/open-project-1/tree/bugfix-delete-transition

    (NB: If you have it open, you might need to close the transition table editor and then reopen it after the repo is updated.)
     
    Amel-Unity and cirocontinisio like this.
  13. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Nice! Can you open a PR for it? It's easier for us to try, and if it works, pull it in (and then you pop up as a collaborator too). Thanks!
     
  14. randomscribe

    randomscribe

    Joined:
    Jun 14, 2021
    Posts:
    29
  15. Amel-Unity

    Amel-Unity

    Unity Technologies

    Joined:
    Jan 30, 2020
    Posts:
    62
    As I mentioned on Github, the PR fixes the issue and I just merged it. Thanks @randomscribe :)
     
    randomscribe and cirocontinisio like this.