Exemple #1
0
    void OnWizardCreate()
    {
        bool valid = true;

        if (texture == null)
        {
            Debug.LogWarning("You must specify a texture");
            valid = false;
        }
        else if (outputWidth < 1)
        {
            Debug.LogWarning("Width must be greater than 0");
            valid = false;
        }
        else if (outputHeight < 1)
        {
            Debug.LogWarning("Height must be greater than 0");
            valid = false;
        }

        if (valid)
        {
            byte[] bytes = CubemapConverter.ConvertToEquirectangular(texture, outputWidth, outputHeight);

            string assetPath      = AssetDatabase.GetAssetPath(texture);
            string assetDirectory = Path.GetDirectoryName(assetPath);
            string assetName      = Path.GetFileNameWithoutExtension(assetPath) + "_equirectangular.png";
            string textureAsset   = Path.Combine(assetDirectory, assetName);
            File.WriteAllBytes(textureAsset, bytes);

            AssetDatabase.ImportAsset(textureAsset);

            Debug.Log("Equirectangular asset successfully saved to " + textureAsset);
        }
    }
Exemple #2
0
 public override TextureImporter GenerateTextureImporter(IExportContainer container)
 {
     return(CubemapConverter.GeenrateTextureImporter(container, this));
 }