Search Unity

Most efficient way to load/create/serialize a texture and/or material object?

Discussion in 'Scripting' started by MNNoxMortem, Oct 13, 2019.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    What is the performance wise most efficient way to create a texture, e.g. from byte[]/file.

    Currently I am using

    Code (CSharp):
    1. var bytes   = TextureFunctions.LoadTexture(textureFileInfo);
    2. var texture = new Texture2D(1, 1);
    3. texture.LoadImage(bytes);
    and I wonder if there is no better way to do this.

    Is there a way to (de)serialize the resulting Material Object to avoid having to recreate it on the next game start?
     
    Last edited: Oct 13, 2019