ilih

Untitled

Dec 30th, 2021 (edited)
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace UIWidgets.Issues
  2. {
  3.     using UIWidgets;
  4.     using UnityEngine;
  5.     using UnityEngine.EventSystems;
  6.  
  7.     public class TreeViewMoveDown : MonoBehaviour
  8.     {
  9.         public TreeView TreeView;
  10.  
  11.         protected virtual void Start()
  12.         {
  13.             TreeView.ItemsEvents.Move.AddListener(ProcessMove);
  14.         }
  15.  
  16.         void ProcessMove(int nodeIndex, ListViewItem instance, AxisEventData eventData)
  17.         {
  18.             if (eventData.moveDir == MoveDirection.Down)
  19.             {
  20.                 var node = TreeView.DataSource[nodeIndex].Node;
  21.                 if (!node.IsExpanded)
  22.                 {
  23.                     node.IsExpanded = true;
  24.                     var next_instance = TreeView.GetItemComponent(nodeIndex + 1);
  25.                     if (next_instance != null)
  26.                     {
  27.                         EventSystem.current.SetSelectedGameObject(next_instance.gameObject);
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }
RAW Paste Data Copied