public void ApplyTextureSettings(Texture2D texture) { if (TextureCreationOptions == null) { TextureCreationOptions = TextureCreationOptions.Default; } texture.wrapMode = TextureCreationOptions.textureWrapMode; texture.filterMode = TextureCreationOptions.filterMode; texture.alphaIsTransparency = TextureCreationOptions.alphaIsTransparency; }
/// <summary> /// Generates a 2D texture from an image file /// </summary> /// <param name="imagePath">The path to the png or jpg file</param> /// <param name="name">The name of the texture object. Defaults to the ase file name + Texture</param> /// <returns></returns> public Texture2D GenerateTexture(string imagePath, string name = null) { if (TextureCreationOptions == null) { TextureCreationOptions = TextureCreationOptions.Default; } var texture = new Texture2D(2, 2, TextureFormat.ARGB32, false); if (!texture.LoadImage(File.ReadAllBytes(imagePath))) { ctx.LogImportWarning("Texture loading not successful"); } texture.wrapMode = TextureCreationOptions.textureWrapMode; texture.filterMode = TextureCreationOptions.filterMode; texture.alphaIsTransparency = TextureCreationOptions.alphaIsTransparency; texture.name = string.IsNullOrWhiteSpace(name) ? AseFileNoExt + "Texture" : name; return(texture); }