i want to set up a simple card game, searching for the best method of texturing the different card fronts. i was wondering if it would be the best to put all the different card front pictures (which should be placed randomly later) in one big texture an then show only one part of the texture in the material (like masking). is this the best way and if so - how could i do that!?
:-)
thnx!
edited: just for the record: if i want to change the Offset of a texture in a material, how could i do that?
Grouping textures is generally good practice to reduce memory requirements but mostly for things like particle or flare effects. A way to randomise textures for cards would be to set up an array containing all your card textures, you can do this by declaring an array called var cardMats: material[]; then you can assign any number of them manually in the inspector.
Then when you want to apply a material you'd generate a random number to pick one from the array, something like this:
mat = Random.Range(0, cardMats.length)
static function Range (min : int, max
: int) : int Description Returns a
random integer number between min
[inclusive] and max [exclusive] (Read
Only).
If max equals min, min will be returned. The returned value will never be max unless min equals max. So you wont have to worry about array out of bounds this this method.
You assign the material to the renderer with this: