private void HierarchyView() { int num5; if ((Event.current.type == EventType.MouseDown) || (Event.current.type == EventType.KeyDown)) { this.m_StillWantsNameEditing = false; } bool hasFocus = base.m_Parent.hasFocus; Hashtable hashtable = new Hashtable(); foreach (int num in Selection.instanceIDs) { hashtable.Add(num, null); } IHierarchyProperty newHierarchyProperty = this.GetNewHierarchyProperty(); float top = 0f; int num4 = 0; num4 = newHierarchyProperty.CountRemaining(this.m_ExpandedArray); newHierarchyProperty.Reset(); Rect viewRect = new Rect(0f, 0f, 1f, num4 * m_RowHeight); if (this.m_EditNameMode == NameEditMode.PreImportNaming) { viewRect.height += m_RowHeight; } if (base.hasSearchFilter) { this.m_ScrollPositionFiltered = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPositionFiltered, viewRect); num5 = Mathf.RoundToInt(this.m_ScrollPositionFiltered.y) / Mathf.RoundToInt(m_RowHeight); } else { this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect); num5 = Mathf.RoundToInt(this.m_ScrollPosition.y) / Mathf.RoundToInt(m_RowHeight); } this.EditName(); if ((Event.current.type == EventType.ExecuteCommand) || (Event.current.type == EventType.ValidateCommand)) { this.ExecuteCommandGUI(); if (Event.current.type == EventType.ValidateCommand) { GUI.EndScrollView(); return; } } this.KeyboardGUI(); if (Event.current.type == EventType.Layout) { GUI.EndScrollView(); } else { int num6 = this.ControlIDForProperty(null); bool flag2 = false; top = num5 * m_RowHeight; float num7 = (this.m_ScreenRect.height + top) + 16f; newHierarchyProperty.Skip(num5, this.m_ExpandedArray); bool flag3 = false; Rect position = new Rect(0f, 0f, 0f, 0f); Vector2 mousePosition = Event.current.mousePosition; GUIContent content = new GUIContent(); Event current = Event.current; int activeInstanceID = Selection.activeInstanceID; if (!this.NamingAsset()) { this.m_EditNameMode = NameEditMode.None; } GUIStyle style = (base.m_HierarchyType != HierarchyType.Assets) ? ms_Styles.hiLabel : ms_Styles.label; Color[] colorArray = (EditorGUIUtility.skinIndex != 1) ? s_HierarchyColors : s_DarkColors; while (newHierarchyProperty.Next(this.m_ExpandedArray) && (top <= num7)) { Rect rect3 = new Rect(0f, top, GUIClip.visibleRect.width, m_RowHeight); if (((this.m_EditNameMode == NameEditMode.PreImportNaming) && !flag2) && (newHierarchyProperty.instanceID == this.m_NewAssetSortInstanceID)) { flag2 = true; top += m_RowHeight; rect3 = new Rect(0f, top, GUIClip.visibleRect.width, m_RowHeight); this.DrawPreImportedIcon(top); } int instanceID = newHierarchyProperty.instanceID; int controlID = this.ControlIDForProperty(newHierarchyProperty); float num11 = 17f + (16f * newHierarchyProperty.depth); if (((current.type == EventType.MouseUp) || (current.type == EventType.KeyDown)) && ((activeInstanceID == instanceID) && (Selection.instanceIDs.Length == 1))) { this.m_NameEditString = newHierarchyProperty.name; this.m_NameEditRect = new Rect((rect3.x + num11) + this.IconWidth, rect3.y, rect3.width - num11, rect3.height); this.m_EditNameInstanceID = instanceID; if ((this.m_EditNameMode == NameEditMode.None) && newHierarchyProperty.isMainRepresentation) { this.m_EditNameMode = NameEditMode.Found; } } if ((this.m_EditNameMode == NameEditMode.Renaming) && (this.m_EditNameInstanceID == instanceID)) { this.m_NameEditRect = new Rect((rect3.x + num11) + this.IconWidth, rect3.y, rect3.width - num11, rect3.height); } if ((current.type == EventType.ContextClick) && rect3.Contains(current.mousePosition)) { this.m_NameEditRect = new Rect((rect3.x + num11) + this.IconWidth, rect3.y, rect3.width - num11, rect3.height); this.m_EditNameInstanceID = instanceID; this.m_NameEditString = newHierarchyProperty.name; if ((this.m_EditNameMode == NameEditMode.None) && newHierarchyProperty.isMainRepresentation) { this.m_EditNameMode = NameEditMode.Found; } } if (Event.current.type == EventType.Repaint) { if (base.m_HierarchyType == HierarchyType.GameObjects) { int colorCode = newHierarchyProperty.colorCode; Color color = colorArray[colorCode & 3]; Color color2 = colorArray[(colorCode & 3) + 4]; if (colorCode >= 4) { color.a = color2.a = 0.6f; } else { color.a = color2.a = 1f; } style.normal.textColor = color; style.focused.textColor = color; style.hover.textColor = color; style.active.textColor = color; style.onNormal.textColor = color2; style.onHover.textColor = color2; style.onActive.textColor = color2; style.onFocused.textColor = color2; } bool flag4 = (this.m_DropData != null) && (this.m_DropData.dropPreviousControlID == controlID); bool isHover = (this.m_DropData != null) && (this.m_DropData.dropOnControlID == controlID); content.text = newHierarchyProperty.name; content.image = newHierarchyProperty.icon; style.padding.left = (int) num11; bool flag6 = this.m_CurrentDragSelectionIDs.Contains(instanceID); bool on = (((this.m_CurrentDragSelectionIDs.Count == 0) && hashtable.Contains(instanceID)) || flag6) || (((flag6 && (current.control || current.shift)) && hashtable.Contains(instanceID)) || ((flag6 && hashtable.Contains(instanceID)) && hashtable.Contains(this.m_CurrentDragSelectionIDs))); if ((this.m_EditNameMode == NameEditMode.Renaming) && (instanceID == this.m_EditNameInstanceID)) { content.text = string.Empty; on = false; } style.Draw(rect3, content, isHover, isHover, on, hasFocus); if (flag4) { flag3 = true; position = new Rect(rect3.x + num11, rect3.y - m_RowHeight, rect3.width - num11, rect3.height); } } Rect selectionRect = rect3; selectionRect.x += num11; selectionRect.width -= num11; if ((base.m_HierarchyType == HierarchyType.Assets) && (EditorApplication.projectWindowItemOnGUI != null)) { EditorApplication.projectWindowItemOnGUI(newHierarchyProperty.guid, selectionRect); } if ((base.m_HierarchyType == HierarchyType.GameObjects) && (EditorApplication.hierarchyWindowItemOnGUI != null)) { EditorApplication.hierarchyWindowItemOnGUI(newHierarchyProperty.instanceID, selectionRect); } if (newHierarchyProperty.hasChildren && !base.hasSearchFilter) { bool flag8 = newHierarchyProperty.IsExpanded(this.m_ExpandedArray); GUI.changed = false; Rect rect5 = new Rect((17f + (16f * newHierarchyProperty.depth)) - 14f, top, 14f, m_RowHeight); flag8 = GUI.Toggle(rect5, flag8, GUIContent.none, ms_Styles.foldout); if (GUI.changed) { this.EndNameEditing(); if (Event.current.alt) { this.SetExpandedRecurse(instanceID, flag8); } else { this.SetExpanded(instanceID, flag8); } } } if (((current.type == EventType.MouseDown) && (Event.current.button == 0)) && rect3.Contains(Event.current.mousePosition)) { if (Event.current.clickCount == 2) { AssetDatabase.OpenAsset(instanceID); if ((base.m_HierarchyType != HierarchyType.Assets) && (SceneView.lastActiveSceneView != null)) { SceneView.lastActiveSceneView.FrameSelected(); } GUIUtility.ExitGUI(); } else { this.EndNameEditing(); this.m_CurrentDragSelectionIDs = this.GetSelection(newHierarchyProperty, true); GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = 0; DragAndDropDelay stateObject = (DragAndDropDelay) GUIUtility.GetStateObject(typeof(DragAndDropDelay), controlID); stateObject.mouseDownPosition = Event.current.mousePosition; } current.Use(); } else if ((current.type == EventType.MouseDrag) && (GUIUtility.hotControl == controlID)) { DragAndDropDelay delay2 = (DragAndDropDelay) GUIUtility.GetStateObject(typeof(DragAndDropDelay), controlID); if (delay2.CanStartDrag()) { this.StartDrag(newHierarchyProperty); GUIUtility.hotControl = 0; } current.Use(); } else if ((current.type == EventType.MouseUp) && (GUIUtility.hotControl == controlID)) { if (rect3.Contains(current.mousePosition)) { if ((newHierarchyProperty.isMainRepresentation && (Selection.activeInstanceID == newHierarchyProperty.instanceID)) && (((Time.realtimeSinceStartup - this.m_FocusTime) > 0.5f) && !HasHolddownKeyModifiers(current))) { this.m_StillWantsNameEditing = true; EditorApplication.CallDelayed(new EditorApplication.CallbackFunction(this.BeginMouseEditing), 0.5f); } else { this.SelectionClick(newHierarchyProperty); } GUIUtility.hotControl = 0; } this.m_CurrentDragSelectionIDs.Clear(); current.Use(); } else if ((current.type == EventType.ContextClick) && rect3.Contains(current.mousePosition)) { if (base.m_HierarchyType == HierarchyType.Assets) { this.SelectionClickContextMenu(newHierarchyProperty); ProjectWindowUtil.s_PreferredProjectWindow = this as ProjectWindow; EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), "Assets/", null); current.Use(); } else { this.SelectionClickContextMenu(newHierarchyProperty); GenericMenu menu = new GenericMenu(); menu.AddItem(EditorGUIUtility.TextContent("HierarchyPopupCopy"), false, new GenericMenu.MenuFunction(this.CopyGO)); menu.AddItem(EditorGUIUtility.TextContent("HierarchyPopupPaste"), false, new GenericMenu.MenuFunction(this.PasteGO)); menu.AddItem(EditorGUIUtility.TextContent("HierarchyPopupDuplicate"), false, new GenericMenu.MenuFunction(this.DuplicateGO)); menu.AddSeparator(string.Empty); if ((this.m_EditNameMode == NameEditMode.Found) && !base.hasSearchFilter) { menu.AddItem(EditorGUIUtility.TextContent("HierarchyPopupRename"), false, new GenericMenu.MenuFunction2(this.RenameGO), newHierarchyProperty.pptrValue); } else { menu.AddDisabledItem(EditorGUIUtility.TextContent("HierarchyPopupRename")); } menu.AddSeparator(string.Empty); menu.AddItem(EditorGUIUtility.TextContent("HierarchyPopupDelete"), false, new GenericMenu.MenuFunction(this.DeleteGO)); base.Focus(); menu.DropDown(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f)); current.Use(); } } else if ((current.type == EventType.DragUpdated) || (current.type == EventType.DragPerform)) { Rect rect6 = rect3; rect6.yMin -= m_DropNextToAreaHeight * 2f; if (rect6.Contains(mousePosition)) { if ((mousePosition.y - rect3.y) < m_DropNextToAreaHeight) { this.DragElement(newHierarchyProperty, false); } else { this.DragElement(newHierarchyProperty, true); } GUIUtility.hotControl = 0; } } top += m_RowHeight; } if (flag3) { GUIStyle insertion = ms_Styles.insertion; if (current.type == EventType.Repaint) { insertion.Draw(position, false, false, false, false); } } if ((this.m_EditNameMode == NameEditMode.PreImportNaming) && (this.m_NewAssetSortInstanceID == 0)) { this.DrawPreImportedIcon(top + 16f); } if (this.m_PingTimeStart > -1f) { float num13 = (Time.realtimeSinceStartup - this.m_PingTimeStart) * 16f; if ((num13 > 0f) && (num13 < 64f)) { GUIStyle ping = ms_Styles.ping; int left = ping.padding.left; ping.padding.left = this.m_PingIndent; Matrix4x4 matrix = GUI.matrix; if (num13 < 2f) { float x = 2f - Mathf.Abs((float) (1f - num13)); Vector2 pos = new Vector2(this.m_PingTargetRect.x + (ping.CalcSize(this.m_PingContent).x * 0.5f), this.m_PingTargetRect.y + (this.m_PingTargetRect.height * 0.5f)); Matrix4x4 matrixx2 = GUI.matrix; Vector2 vector3 = GUIClip.Unclip(pos); Matrix4x4 matrixx3 = Matrix4x4.TRS((Vector3) vector3, Quaternion.identity, new Vector3(x, x, 1f)) * Matrix4x4.TRS((Vector3) -vector3, Quaternion.identity, Vector3.one); GUI.matrix = matrixx3 * matrixx2; } Color color3 = GUI.color; if (num13 > 56f) { float num16 = (64f - num13) / 8f; GUI.color = new Color(color3.r, color3.g, color3.b, color3.a * num16); } if (((ping != null) && (this.m_PingContent != null)) && (current.type == EventType.Repaint)) { ping.Draw(this.m_PingTargetRect, this.m_PingContent, false, false, false, false); } ping.padding.left = left; GUI.matrix = matrix; GUI.color = color3; } else { this.m_PingTimeStart = -1f; } base.Repaint(); } GUI.EndScrollView(); switch (current.type) { case EventType.DragUpdated: if (!(base.m_SearchFilter == string.Empty)) { if (this.m_DropData == null) { this.m_DropData = new DropData(); } this.m_DropData.dropOnControlID = 0; this.m_DropData.dropPreviousControlID = 0; return; } this.DragElement(null, true); return; case EventType.DragPerform: this.m_CurrentDragSelectionIDs.Clear(); this.DragElement(null, true); return; case EventType.DragExited: this.m_CurrentDragSelectionIDs.Clear(); this.DragCleanup(true); return; case EventType.ContextClick: if ((base.m_HierarchyType == HierarchyType.Assets) && this.m_ScreenRect.Contains(current.mousePosition)) { EditorUtility.DisplayPopupMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 0f, 0f), "Assets/", null); current.Use(); } return; case EventType.MouseDown: if ((current.button == 0) && this.m_ScreenRect.Contains(current.mousePosition)) { GUIUtility.hotControl = num6; Selection.activeObject = null; this.EndNameEditing(); current.Use(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == num6) { GUIUtility.hotControl = 0; current.Use(); } break; case EventType.KeyDown: if ((this.m_EditNameMode == NameEditMode.Found) && ((((current.keyCode == KeyCode.Return) || (current.keyCode == KeyCode.KeypadEnter)) && (Application.platform == RuntimePlatform.OSXEditor)) || ((current.keyCode == KeyCode.F2) && (Application.platform == RuntimePlatform.WindowsEditor)))) { this.BeginNameEditing(Selection.activeInstanceID); current.Use(); } break; } } }