internal void SetSelection(AH_TreeViewWithTreeModel treeview, IList <int> selectedIds)
        {
            multiColumnHeader = (AH_MultiColumnHeader)(treeview.multiColumnHeader);
            selection         = new List <AH_TreeviewElement>();

            foreach (var itemID in selectedIds)
            {
                selection.Add(treeview.treeModel.Find(itemID));
            }

            hasSelection = (selection.Count > 0);

            //If we have more, select the assets in project view
            if (hasSelection)
            {
                if (selection.Count > 1)
                {
                    UnityEngine.Object[] selectedObjects = new UnityEngine.Object[selection.Count];
                    for (int i = 0; i < selection.Count; i++)
                    {
                        selectedObjects[i] = AssetDatabase.LoadMainAssetAtPath(selection[i].RelativePath);
                    }
                    Selection.objects = selectedObjects;
                }
                else
                {
                    Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(selection[0].RelativePath);
                }

                AH_Utils.PingObjectAtPath(selection[selection.Count - 1].RelativePath, false);
            }
        }
Ejemplo n.º 2
0
        void InitIfNeeded()
        {
            //We dont need to do stuff when in play mode
            if (buildInfoManager && buildInfoManager.HasSelection && !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 = AH_TreeViewWithTreeModel.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width);
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
                }
                m_MultiColumnHeaderState = headerState;

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

                var treeModel = new TreeModel <AH_TreeviewElement>(buildInfoManager.GetTreeViewData());

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

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

                m_Initialized = true;
                buildInfoManager.ProjectDirty = false;
            }

            //This is an (ugly) fix to make sure we dotn loose our icons due to some singleton issues after play/stop
            if (guiContentRefresh.image == null)
            {
                initializeGUIContent();
            }
        }
Ejemplo n.º 3
0
        internal static void DumpCurrentListToFile(AH_TreeViewWithTreeModel m_TreeView)
        {
            var path = EditorUtility.SaveFilePanel(
                "Dump current list to file",
                AH_SerializationHelper.GetBuildInfoFolder(),
                "AH_Listdump_" + System.Environment.UserName,
                AH_SerializationHelper.FileDumpExtension);

            if (path.Length != 0)
            {
                List <AssetDumpData> elements = new List <AssetDumpData>();

                foreach (var element in m_TreeView.GetRows())
                {
                    populateDumpListRecursively(m_TreeView.treeModel.Find(element.id), ((AH_MultiColumnHeader)m_TreeView.multiColumnHeader).ShowMode, ref elements);
                }

                AH_ElementList objectToSave = new AH_ElementList(elements);
                AH_SerializationHelper.SerializeAndSave(objectToSave, path);
            }
        }