private void OnAllObjectsTreeViewSelectionChanged(object sender, TreeViewEventArgs e) { if (allObjectsTreeView.SelectedNode == null) { relationshipsListView.Items.Clear(); return; } TreeNode selectedItem = allObjectsTreeView.SelectedNode; //HACK: ensure that the selection sticks when the element doesn't have focus if (m_lastSelectedTreeNode != null) { m_lastSelectedTreeNode.BackColor = SystemColors.Window; m_lastSelectedTreeNode.ForeColor = SystemColors.WindowText; } m_lastSelectedTreeNode = selectedItem; selectedItem.BackColor = SystemColors.ActiveBorder; selectedItem.ForeColor = SystemColors.HighlightText; ProjectObject selectedObject; if (ObjectDatabase.TryGetObject(selectedItem.Name, out selectedObject)) { // load the object into the inspect panel UnityObjectKey unityObjectKey; unityObjectKey = new UnityObjectKey(selectedObject.UniqueId); selectedObjectGuidTextBox.Text = unityObjectKey.AssetGuid.ToString(); selectedObjectFileIdTextBox.Text = unityObjectKey.FileId.ToString(); selectedObjectFilePathTextBox.Text = selectedObject.GetFilePath(); projectObjectTypeTextBox.Text = selectedObject.GetType().Name; if (selectedObject.ParseError != null) { viewErrorButton.Visible = true; toolTip.SetToolTip(viewErrorButton, selectedObject.ParseError.ToString()); } else { viewErrorButton.Visible = false; } } else { selectedObjectGuidTextBox.Text = ""; selectedObjectFileIdTextBox.Text = ""; selectedObjectFilePathTextBox.Text = ""; projectObjectTypeTextBox.Text = ""; } ReloadRelationships(); }
/// <summary> /// /// </summary> public UnityDefaultAsset(string documentId, UnityObjectKey key) : base(documentId, null, key) { }
/// <summary> /// Reloads the <see cref="relationshipsListView"/>. /// </summary> private void ReloadRelationships() { TreeNode selectedItem = allObjectsTreeView.SelectedNode; ProjectObject selectedObject; if (!ObjectDatabase.TryGetObject(selectedItem.Name, out selectedObject)) { relationshipsListView.Items.Clear(); return; } relationshipsListView.BeginUpdate(); relationshipsListView.Items.Clear(); foreach (ObjectRelationship relationship in ObjectDatabase.GetRelationships(selectedObject.UniqueId)) { ListViewItem listItem; ProjectObject targetObject; // populate the target object if (ObjectDatabase.TryGetObject(relationship.TargetObjectId, out targetObject)) { listItem = relationshipsListView.Items.Add( relationship.TargetObjectId, targetObject.ToString(), targetObject.GetIconKey()); } else { listItem = relationshipsListView.Items.Add( relationship.TargetObjectId, "*missing*", "DefaultAsset_Icon"); } // relationship type listItem.SubItems.Add(relationship.RelationshipType); // target object raw data UnityObjectKey objectKey = new UnityObjectKey(relationship.TargetObjectId); listItem.SubItems.Add(objectKey.AssetGuid.ToString()); listItem.SubItems.Add(objectKey.FileId.ToString()); // populate the target object's parent asset UnityObjectKey targetObjectKey = new UnityObjectKey(relationship.TargetObjectId); if (ObjectDatabase.TryGetObject(targetObjectKey.AssetGuid.ToString(), out targetObject)) { listItem.SubItems.Add(targetObject.ToString()); } else { listItem.SubItems.Add("*missing*"); } } if (relationshipsIncludeChildrenCheckbox.Checked) { //TODO: load child relationships } relationshipsListView.EndUpdate(); }