Beispiel #1
0
        public static Sprite LoadSprite(string SpriteTextureName, SPITE_LOCATIONS assetLocation)
        {
            string path = CreateSpritePath(SpriteTextureName, assetLocation);

            //Debug.unityLogger.Log("path of sprite to load " + path);

            return((Sprite)AssetDatabase.LoadAssetAtPath(path, typeof(Sprite)));
        }
Beispiel #2
0
        public static BitmapImage SelectImage(SPITE_LOCATIONS loc, ref string imageFileName)
        {
            BitmapImage bi = new BitmapImage();

            //open dialog box to select the image
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png";

            // Set default file extension
            dlg.DefaultExt = ".png";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                var filePathToUnityImages = ConstructImagePath(loc);
                var standAlone            = ConstructStandAlonePath(loc);

                //Move the file to the image resource location for UNITY
                if (Directory.Exists(filePathToUnityImages) || WouldYouLikeToCreateUnityFolder(filePathToUnityImages))
                {
                    Console.WriteLine("Moving file to location " + filePathToUnityImages);
                    bi = SelectImage(dlg, filePathToUnityImages, ref imageFileName);
                }
                else
                {
                    Console.WriteLine("Saving files to the StandAloneDirectory");

                    //If this directory doesn't exist as wel... Create it
                    if (!Directory.Exists(standAlone))
                    {
                        Directory.CreateDirectory(standAlone);
                    }

                    bi = SelectImage(dlg, standAlone, ref imageFileName);
                }
            }

            return(bi);
        }
Beispiel #3
0
 private static string CreateSpritePath(string textureName, SPITE_LOCATIONS location, string textureExtension = ".png")
 {
     return(AssetPaths[(int)location] + textureName + textureExtension);
 }
Beispiel #4
0
 private static string ConstructStandAlonePath(SPITE_LOCATIONS loc)
 {
     return(standAloneImageFilepath + loc.ToString() + "\\");
 }
Beispiel #5
0
 private static string ConstructImagePath(SPITE_LOCATIONS loc)
 {
     return(filePathToSprites + loc.ToString() + "\\");
 }