コード例 #1
0
    protected override void RowGUI(RowGUIArgs args)
    {
        Event evt = Event.current;

        extraSpaceBeforeIconAndLabel = 18f;

        // GameObject isStatic toggle
        PrefabsTreeItem item = args.item as PrefabsTreeItem;

        Rect toggleRect = args.rowRect;

        toggleRect.x    += GetContentIndent(item);
        toggleRect.width = 16;

        // Ensure row is selected before using the toggle (usability)
        if (evt.type == EventType.MouseDown && toggleRect.Contains(evt.mousePosition))
        {
            SelectionClick(item, false);
        }
        EditorGUI.BeginChangeCheck();
        bool isStatic = EditorGUI.Toggle(toggleRect, item.defaultSelect);

        if (EditorGUI.EndChangeCheck())
        {
            Utils.SelectedDic[item.id] = isStatic;
            EventManager.Dispatch <int, bool>("UISelectEvent", item.id, isStatic);
        }
        // Text
        base.RowGUI(args);
    }
コード例 #2
0
    protected override TreeViewItem BuildRoot()
    {
        PrefabsTreeItem item = new PrefabsTreeItem(1, -1, "root");

        this.AddChildItem();
        SetupParentsAndChildrenFromDepths(item, this.listItem);
        return(item);
    }
コード例 #3
0
    private PrefabsTreeItem CreateItem(Transform transform, int id)
    {
        int             depth = transform.GetComponentsInParent <Transform>(true).Length <= 0 ? 1 : transform.GetComponentsInParent <Transform>(true).Length;
        PrefabsTreeItem item  = new PrefabsTreeItem(id, depth, transform.name);

        if (Utils.SelectedDic.ContainsKey(id))
        {
            item.defaultSelect = Utils.SelectedDic[id];
        }
        else
        {
            Utils.SelectedDic.Add(id, item.defaultSelect);
        }
        return(item);
    }
コード例 #4
0
    protected override TreeViewItem BuildRoot()
    {
        //if(this.parentTransform != null)
        //{
        //    treeItem = new PrefabsTreeItem(this.parentTransform.GetInstanceID(), -1, this.parentTransform.name);
        //}
        PrefabsTreeItem item = new PrefabsTreeItem(1, -1, "root");

        this.AddChildItem();
        // if(this.listItem != null)
        {
            SetupParentsAndChildrenFromDepths(item, this.listItem);
        }
        return(item);
    }
コード例 #5
0
    public void RefhreshSelectedState()
    {
        int count = this.listItem.Count;

        for (int i = 0; i < count; ++i)
        {
            PrefabsTreeItem item = this.listItem[i] as PrefabsTreeItem;
            bool            isSelect;
            if (Utils.SelectedDic.TryGetValue(item.id, out isSelect) == false)
            {
                isSelect = false;
            }
            item.defaultSelect = isSelect;
        }
    }
コード例 #6
0
    private void AddChildItem()
    {
        List <TreeViewItem> rows = new List <TreeViewItem>();

        if (this.parentTransform != null)
        {
            GameObject[] transforms = Utils.GetAllUIChild(this.parentTransform.gameObject);
            for (int i = 0; i < transforms.Length; i++)
            {
                PrefabsTreeItem item = this.CreateItem(transforms[i].transform, i);
                rows.Add(item);
                this.SetExpanded(i, true);
            }
        }
        this.listItem = rows;
    }