public static void ShowWindow(StarsSpaceGeneratorEditor targ)
        {
            SaveToTextureStarsSpaceWindow win = GetWindow <SaveToTextureStarsSpaceWindow>(false, "Save To Texture", true);

            win.target       = targ;
            win.basefilename = targ.target.name;
            win.basepath     = Application.dataPath;
        }
        void SaveFiles(SaveType selected = SaveType.All)
        {
            StarsSpaceGenerator tTarget = ((StarsSpaceGenerator)target.target);

            StarsSpaceGeneratorEditor.UpdateTexturesCubeMap(tTarget);
            Texture2D[] textures = tTarget.GetTextures();
            for (int i = 0; i < 6; i++)
            {
                if (textures[i] == null)
                {
                    break;
                }
                string pref = prefix[i];
                if (NamePrefix == PrefixName.Num)
                {
                    pref = i.ToString();
                }
                string toPath = Path.Combine(basepath, basefilename + AddSpacer(pref) + "." + Type.ToString().ToLower());
                if (selected != SaveType.Material)
                {
                    byte[] bytes = new byte[0];
                    if (Type == ImageType.PNG)
                    {
                        bytes = textures[i].EncodeToPNG();
                    }
                    if (Type == ImageType.JPG)
                    {
                        bytes = textures[i].EncodeToJPG(quality);
                    }
                    File.WriteAllBytes(toPath, bytes);
                    AssetDatabase.Refresh();
                }
                toPath               = toPath.Replace(Application.dataPath, "Assets");
                textures[i]          = (Texture2D)AssetDatabase.LoadAssetAtPath(toPath, typeof(Texture2D));
                textures[i].wrapMode = TextureWrapMode.Clamp;
            }
            if (selected != SaveType.Textures)
            {
                Material mat = new Material(tTarget.GetMaterial());
                for (int i = 0; i < 6; i++)
                {
                    mat.SetTexture(StarsSpaceGenerator.MaterialTextureNames[i], textures[i]);
                }
                string toPathMaterial = Path.Combine(basepath, basefilename + ".mat");
                toPathMaterial = toPathMaterial.Replace(Application.dataPath, "Assets");
                AssetDatabase.CreateAsset(mat, toPathMaterial);
            }
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }