Exemplo n.º 1
0
    void InitIfNeeded()
    {
        if (!m_Initialized)
        {
            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }

            bool firstInit   = m_MultiColumnHeaderState == null;
            var  headerState = MultiColumnTreeView.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width);
            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            }
            m_MultiColumnHeaderState = headerState;

            var multiColumnHeader = new MyMultiColumnHeader(headerState);
            if (firstInit)
            {
                multiColumnHeader.ResizeToFit();
            }

            var treeModel = new TreeModel <MyTreeElement>(GetData());

            m_TreeView = new MultiColumnTreeView(m_TreeViewState, multiColumnHeader, treeModel);

            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

            m_Initialized = true;
        }
    }
Exemplo n.º 2
0
    void InitIfNeeded ()
    {
        if (!m_Initialized)
        {
            // Check if it already exists (deserialized from window layout file or scriptable object)
            if (m_TreeViewState == null)
                m_TreeViewState = new TreeViewState();

            bool firstInit = m_MultiColumnHeaderState == null;
            var headerState = MultiColumnTreeView.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width);
            if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
                MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
            m_MultiColumnHeaderState = headerState;
            var multiColumnHeader = new MultiColumnHeader(headerState);
            multiColumnHeader.canSort = false;
            if (firstInit)
                multiColumnHeader.ResizeToFit ();

            var treeModel = new TreeModel<ParticleSystemElement>(particleSystemElements);
            m_TreeView = new MultiColumnTreeView(m_TreeViewState, multiColumnHeader, treeModel);
            
            m_Initialized = true;
        }
    }