Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Problem of dragging when clicking EnumField inside GraphView Node

Discussion in 'UI Toolkit' started by kbop2000, Jun 24, 2021.

  1. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14
    https://ibb.co/2tz6R3B
    Sorry, I don't know how to post webp ..

    Using UnityEditor.Experimental.GraphView.GraphView,
    UnityEditor.Experimental.GraphView.Node class

    If you create a new node and put 'EnumField' inside, it will drag when value is changed

    Code (CSharp):
    1. // BaseNodeView is UnityEditor.Experimental.GraphView.Node
    2. public class StatusView : BaseNodeView
    3.     {
    4.         private EnumField m_StateField;
    5.         private Status m_Value;
    6.  
    7.         public override void Initialize<T>(BaseGraphView owner, T target)
    8.         {
    9.             base.Initialize(owner, target);
    10.             m_Value = target as Status;
    11.  
    12.             inputContainer.Add(this.CreatePort<BaseNode>(Direction.Input));
    13.  
    14.             m_StateField = new EnumField("State", AnimationLayerStatusType.None);
    15.             m_StateField.style.paddingLeft = new StyleLength { value = new Length(4f) };
    16.             m_StateField.style.unityTextAlign = new StyleEnum<TextAnchor> { value = TextAnchor.MiddleLeft };
    17.             m_StateField.RegisterValueChangedCallback((field) =>
    18.             {
    19.                 m_Value.State = (AnimationLayerStatusType)field.newValue;
    20.             });
    21.  
    22.             topContainer.Add(m_StateField);
    23.  
    24.             RefreshExpandedState();
    25.             SetPosition(target.Position);
    26.         }
    27.     }
    how to stopping drag for node?
     
  2. DARKHAWX

    DARKHAWX

    Joined:
    Apr 15, 2017
    Posts:
    15
    Sorry for bumping an old thread, but did you ever fix this issue? I get the same problem.
     
  3. kbop2000

    kbop2000

    Joined:
    Apr 17, 2019
    Posts:
    14