S
S
Senture2018-08-26 23:24:28
Game development
Senture, 2018-08-26 23:24:28

How to change max size of texture in unity via script?

Hello, I had a need to change the value of the size (max size) of the textures through the script:
5b830c340c9fc751135644.png
or change the number of repetitions of the texture of the terrain, also through the script:
5b830c5e1271a566884388.png
Please tell me how to do this? If at all possible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-08-27
@Senture

Texture settings can only be changed in the editor using the TextureImporter . Call AssetImporter.GetAtPath on the desired file and get the importer, then change maxTextureSize and save with AssetImporter.SaveAndReimport .
Terrain was written a long time ago and has not been updated since then, so editing it from a script is quite expensive. If nothing was found in the public API, then, most likely, this is done only through reflection and crutches. You can read the source code on github , maybe you will find something suitable.
UPD: Found something similar that might work. Get Terrain.terrainData , it has splatPrototypes, apparently, these are brushes. I think if you twist SplatPrototype.tileSize , you can get the desired result.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question