示例#1
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var paths            = DragAndDrop.paths;
            var objectReferences = DragAndDrop.objectReferences;

            if (objectReferences == null || objectReferences.Length == 0)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            for (var i = 0; i < objectReferences.Length; i++)
            {
                var monoBehaviour = objectReferences[i] as MonoBehaviour;
                if (monoBehaviour == null)
                {
                    continue;
                }

                var monoScript = MonoScript.FromMonoBehaviour(monoBehaviour);
                if (monoScript == null)
                {
                    continue;
                }

                objectReferences[i] = monoScript;
            }

            var assetsPaths = ReferencesFinder.GetSelectedAssets(objectReferences);

            if (assetsPaths.Length == 0)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            if (Event.current.type == EventType.DragPerform)
            {
                EditorApplication.delayCall += () => { ReferencesFinder.AddToSelectionAndRun(assetsPaths.ToArray()); };
                DragAndDrop.AcceptDrag();
            }

            return(DragAndDropVisualMode.Generic);
        }
示例#2
0
        public static void FindComponentReferences(MenuCommand command)
        {
            var scriptPath = CSObjectTools.GetScriptPathFromObject(command.context);

            ReferencesFinder.AddToSelectionAndRun(scriptPath);
        }