コード例 #1
0
 public override void SetSelect(params string[] path)
 {
     ClearTree();
     OnHeadSelect(0);
     Tree.TreeNode node = rootNode;
     for (int i = 0; i < path.Length; i++)
     {
         if (node.childern != null)
         {
             var child = node.GetChildItem(path[i]);
             if (child != null)
             {
                 var index = System.Array.IndexOf(node.childern, (child));
                 creater.SetSelect(index, true);
                 node = node.childern[i];
             }
             else
             {
                 break;
             }
         }
         else
         {
             break;
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 可选择项选中后,
        /// 判断是否需要继续选择,或者是触发事件
        /// </summary>
        /// <param name="key"></param>
        private void OnBodySelect(int key)
        {
            //最底层的选择逻辑
            if ((active.childern == null || active.childern.Length == 0) && active.ParentItem != null)
            {
                active = active.ParentItem;
            }

            var child = active.GetChildItem(key);

            if (child != null)
            {
                //激活当前节点
                active = child;

                if (child.childern != null && child.childern.Length > 0)
                {
                    //更新选择列表
                    ChargeBodyOption(active);
                }
                else
                {
                    Debug.Assert(active != null, "active :Null", gameObject);
                    OnSelectionChanged(child.FullPath);
                }

                //更新标头列表
                UpdateCurrentSelectFromActiveNode(active);
            }
        }