Exemple #1
0
        private void Update()
        {
            bool nowDragging = DragAndDrop.objectReferences.Length == 1;

            if (_wasDragging != nowDragging)
            {
                // detect when dragging state changes, so we force a refresh of the hierarchy
                _wasDragging = nowDragging;

                if (!nowDragging)
                {
                    _draggingHeldOver            = null;
                    _draggingShownQuickInspector = false;
                    TeneDropTarget.Hide();
                }

                // doesn't appear to refresh when starting to drag stuff
                // but works ok when finishing
                Common.HierarchyWindow.Repaint();
            }

            if (_lastHoverObject != null || _hoverObject != null)
            {
                if (_lastHoverObject != _hoverObject)
                {
                    // don't currently support plain old gameobjects
                    if (_hoverObject is GameObject)
                    {
                        if (PrefabUtility.GetCorrespondingObjectFromSource(_hoverObject) == null)
                        {
                            _hoverObject = null;
                        }
                    }
                }

                if (_lastHoverObject != _hoverObject)
                {
                    _lastHoverObject = _hoverObject;

                    TeneEnhPreviewWindow.Update(
                        Common.HierarchyWindow.position,
                        _mousePosition,
                        pAsset: _hoverObject
                        );
                }
                else
                {
                    _updateThrottle++;
                    if (_updateThrottle > 20)
                    {
                        _hoverObject = null;
                        Common.HierarchyWindow.Repaint();
                        _updateThrottle = 0;
                    }
                }
            }

            if (_draggingHeldOver != null)
            {
                if (!_draggingShownQuickInspector)
                {
                    if ((System.DateTime.Now - _draggingHeldStart).TotalSeconds >= 0.5f)
                    {
                        // user held mouse over a game object, so we can show the
                        // quick-drop popup window

                        TeneDropTarget.Update(
                            Common.HierarchyWindow.position,
                            _mousePosition,
                            _draggingHeldOver
                            );

                        _draggingShownQuickInspector = true;
                    }
                }
            }
        }