Esempio n. 1
0
        private static Sprite HandleExternalDrag(bool perform)
        {
            if (DragAndDrop.paths.Length == 0)
            {
                return(null);
            }
            string text = DragAndDrop.paths[0];

            if (!SpriteUtility.ValidPathForTextureAsset(text))
            {
                return(null);
            }
            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            if (!perform)
            {
                return(null);
            }
            string text2 = AssetDatabase.GenerateUniqueAssetPath(Path.Combine("Assets", FileUtil.GetLastPathNameComponent(text)));

            if (text2.Length <= 0)
            {
                return(null);
            }
            FileUtil.CopyFileOrDirectory(text, text2);
            SpriteUtility.ForcedImportFor(text2);
            return(SpriteUtility.GenerateDefaultSprite(AssetDatabase.LoadMainAssetAtPath(text2) as Texture2D));
        }
Esempio n. 2
0
 private static void HandleExternalDrag(string[] paths, bool perform, ref List <Sprite> result)
 {
     for (int i = 0; i < paths.Length; i++)
     {
         string text = paths[i];
         if (SpriteUtility.ValidPathForTextureAsset(text))
         {
             DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
             if (perform)
             {
                 string text2 = AssetDatabase.GenerateUniqueAssetPath(Path.Combine("Assets", FileUtil.GetLastPathNameComponent(text)));
                 if (text2.Length > 0)
                 {
                     FileUtil.CopyFileOrDirectory(text, text2);
                     SpriteUtility.ForcedImportFor(text2);
                     Sprite sprite = SpriteUtility.GenerateDefaultSprite(AssetDatabase.LoadMainAssetAtPath(text2) as UnityEngine.Texture2D);
                     if (sprite != null)
                     {
                         result.Add(sprite);
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        private static bool PathsAreValidTextures(string[] paths)
        {
            bool result;

            if (paths == null || paths.Length == 0)
            {
                result = false;
            }
            else
            {
                for (int i = 0; i < paths.Length; i++)
                {
                    string path = paths[i];
                    if (!SpriteUtility.ValidPathForTextureAsset(path))
                    {
                        result = false;
                        return(result);
                    }
                }
                result = true;
            }
            return(result);
        }