PDA

View Full Version : [Q/A] texture method


SoFahim
15/02/2017, 04:38 AM
Best method for texture scripting

Method 1 :
SetObjectMeterial(CreateObject(),....);
SetObjectMeterial(CreateObject(),....);

Method 2 :
new Texture;
Texture =CreateObject();
SetObjectMeterial(Texture,...);
Texture =CreateObject();
SetObjectMeterial(Texture,...);



Method 3 :
new Texture[2];
Texture[0] =CreateObject();
SetObjectMeterial(Texture[0],...);
Texture[1] =CreateObject();
SetObjectMeterial(Texture[1],...);



Please let me know, which one will be good and why?

DRIFT_HUNTER
15/02/2017, 04:55 AM
With first method you can change only one texture on a single object.
Second will create only one variable so it will be faster than third which is allocating more variables.

So at the end best method is second one, but it makes no difference as all three works and there is no performance impact (you create objects only at startup).

PrO.GameR
15/02/2017, 06:59 AM
The thing is, whatever memory it'd use it's still created locally, which means it's (usually) part of the OnGmInit and only done once and doesn't really matter, so I'd suggest you to use whatever generated code a map editor gives you.

Gammix
15/02/2017, 07:20 AM
All the 3 methods have their own uses.

If you just want to set the texture once: Method 1
If you want to set the texture multiple times and while creating the object only: Method 2
If you want to change textures for specific objects later on: Method 3

You can use all the methods together according to your need.

SoFahim
15/02/2017, 12:42 PM
Well, I mostly use method 2. Just for making myself sure, I asked it here.