示例#1
0
    /// <summary>
    /// 实际对接设备信息用
    /// </summary>
    /// <param name="component"></param>
    /// <param name="item"></param>
    private void ChangeFactoryDevValue(TreeViewComponent component, ListNode <TreeViewItem> item)
    {
        FacilityDevTreeItem DevItem = component.GetComponent <FacilityDevTreeItem>();

        if (DevItem)
        {
            DevItem.Init(item.Node.Item.Tag, component.Text);
        }
        float         offset  = item.Depth * component.PaddingPerLevel;
        LayoutElement element = component.Text.GetComponent <LayoutElement>();

        if (item.Node.Nodes != null && item.Node.Nodes.Count != 0)
        {
            element.preferredWidth = NormalTextWidth - offset;
        }
        else
        {
            float toggleSize = 0;
            if (item.Depth != 0)
            {
                toggleSize = component.Toggle.GetComponent <LayoutElement>().preferredWidth;
            }
            element.preferredWidth = NormalTextWidth - offset + toggleSize;
        }
    }
示例#2
0
    /// <summary>
    /// 模拟数据用
    /// </summary>
    /// <param name="component"></param>
    /// <param name="item"></param>
    private void ChangeItemValue(TreeViewComponent component, ListNode <TreeViewItem> item)
    {
        FacilityDevTreeItem DevItem = component.GetComponent <FacilityDevTreeItem>();

        if (DevItem)
        {
            DevItem.SetValue(item.Node.Item.Tag as FacilitySystem);
        }
        float offset = item.Depth * component.PaddingPerLevel;
        //if (offset == 0) return;
        LayoutElement element = component.Text.GetComponent <LayoutElement>();

        //Debug.Log(item.Node.Item.Name+" Nodes: "+item.Node.Nodes.Count);
        if (item.Node.Nodes != null && item.Node.Nodes.Count != 0)
        {
            element.preferredWidth = NormalTextWidth - offset;
        }
        else
        {
            float toggleSize = component.Toggle.GetComponent <LayoutElement>().preferredWidth;
            element.preferredWidth = NormalTextWidth - offset + toggleSize;
        }
    }