Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by BTCallahan · Mar 03, 2017 at 05:49 PM · materialtexture2dsetpixels32

calling Texture2DArray.SetPixels32 results in an "Invalid texture format: 12" error

So I have a script that take several Texture2D objects and uses the data to create a Texture2DArray. The problem is that whenever it get to the SetPixels32 method I get two error messages that both say "Invalid texture format: 12" followed by another error that says "Image invalid format!", followed by another two "Invalid texture format: 12" errors, and so on until It's given me sixteen of the "Invalid texture format: 12" errors and eight of the "Image invalid format!" errors. The documentation hasn't been helpful in determining the cause. It can't be a null reference error because I've made sure that none of the textures are empty in the editor.

I'm pretty much stuck at this point. Here's the code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
  
 public class TextureArrayTesting : MonoBehaviour {
  
     public Material ArrayMaterial;
  
     public Texture2D AOTex1, AOTex2, AOTex3, AOTex4, NormTex1, NormTex2, NormTex3, NormTex4;
  
     private void makeTextureArray(string arrayName, params Texture2D[] texs){
  
         Texture2DArray new2darray = new Texture2DArray (texs [0].width, texs [0].height, texs.Length, texs [0].format, true);
  
         for (int i = 0; i < texs.Length; i++) {
             //texs [i].mipmapCount
  
             new2darray.SetPixels32 (texs [i].GetPixels32 (), i);//this is where the problem is
  
             //new2darray.SetPixels32 (texs [i].GetPixels32 (0), i, 0);
             //new2darray.SetPixels (texs [i].GetPixels (), i);
         }
  
         ArrayMaterial.SetTexture (arrayName, new2darray);
     }
  
     // Use this for initialization
     void Start () {
  
         makeTextureArray ("_BumpMapArray", NormTex1, NormTex2, NormTex3, NormTex4);
         makeTextureArray ("_AO_Array", AOTex1, AOTex2, AOTex3, AOTex4);
  
         ArrayMaterial.SetVector("_BlendingValues", new Vector4(0.2f, 0.6f, 0.35f, 0.42f));
  
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by helpautism2 · May 22, 2017 at 10:34 PM

Have you made sure the texture is in RGBA32, ARGB32 formats? You can change that in the inspector of the texture file.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BTCallahan · May 23, 2017 at 12:00 AM 0
Share

I can set it to RGBA 32 bit, but that almost quadruples the size. I haven't tested it out yet, I'll do it as soon as I get a chance.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

100 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change Texture in editor 0 Answers

How to get Color32 block from a runtime generated Texture2D? 0 Answers

Texture drawing on the wrong side of a mesh 0 Answers

Unity seems to be in 2D, but I want it in 3D 1 Answer

How do I use a sliced 2D sprite as the repeating texture on a 3D object? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges