Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

What format will allow me to copy a texture on Android in real time?

Discussion in 'Scripting' started by Reverend-Speed, Jan 18, 2019.

  1. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hey folks,

    I'm building a simple painting app for Android and want to be able to copy from a default texture to a new texture and then write my paint to it using a Render Texture.

    Everything is working just great in editor, but the atlas texture (Default, read/write enabled, RGBA 32 bit) is not displaying correctly on the model (a house) when in Android.

    Code (CSharp):
    1.  baseMaterial.maintexture = new Texture2D(houseTexture.width, houseTexture.height, houseTexture.format, true);
    2. Graphics.CopyTexture(houseTexture, baseMaterial.mainTexture);
    Does anybody know what kind of texture format I should be using to ensure it displays in Unity Android? Have tried all options available under Format in the image import Inspector, and I'm just getting a grey box with seemingly random lines, or the object is covered in one of the main colours (a pastel peach) from the texture (suggesting a UV issue?).

    I'm honestly baffled, and if somebody has experience with this I'd be most grateful.

    (Bonus question: Does anybody know why VS2017 wouldn't be able to see my USB-attached Samsung TabA via debugger tools?)

    EDIT: So, I'm running my .apk with the Logcat settings found on [this page][1] and all I'm getting are standard errors, no suggestions of what's causing the problems - I thought I might find something indicating that Graphics.CopyTexture isn't working, but no dice.

    The current import settings for the 2D texture atlas are Read/Write Enable == true, with the format as RGBA 32 bit - and all I'm getting is just a grey/white texture on my model (which, ideally, should display a copy of the original house texture). Again, this all works in-editor.
     
    Last edited: Jan 19, 2019
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,936
    Why don't you just reassign your Render Texture work in progress texture to the material used to render the house, which I presume is a MeshRenderer pushing out a 3D object?
     
  3. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    That might have worked! As it is, I solved the issue by using GetPixels32 on the textures, making sure to call .Apply() on the destination texture. Thanks...!