Hi there,
I am wondering if someone can help me. I am building the iOS, with a Universal build. I have built all my levels for the iPod. Now the iPad, will use the same levels, but with adjusted materials. And this is where i need help. How can I take item, object barrel for instance, and use Resources to load the correct material to it… more specifically I would imagine I would also have to adjust the UVs.
Is there an easier way to go about this? Right now I am just replacing each object in scene that uses a different material by hand and is quite tedious.
Maybe I’m missing something but I don’t understand why you would need to change your materials in this case. GUI placement is usually the big issue in multiplatform. On that note I recommend this:
http://forum.unity3d.com/threads/108637-MultiPlatform-ToolKit-Multiplatform-development-simplified.
I have adjusted any screen sizing issues by just slight adjusting the zoom on each cam. The reason I want to swap materials is because of the different devices screen resolutions. So, basically, I am doubling the size of each material for the iPad.
If your texture is the same and only the size change, you can drop material with the right texture in your resource folder and to call it this way :
gameObject.transform.renderer.material = Resource.Load(“myNewMaterialName”) as Material.
You can also deal with name keeping the low res as default mat on your object :
- mat_xxxx (default material)
- mat_xxxx_HD (material for HD from resource folder)
// for vertical screen
bool deviceHD = false;
if (Screen.width > 320) deviceHD = true;
if(deviceHD) goMyObject.transform.material = Resource.Load(goMyObject.transform.material.name + “_HD”) as Material;
I didn’t test this code but I process the same way.
Hm, thanks. That seems easy enough. How do you unload the unused material?
If it comes from Resources folder you can simply Resources.UnLoadAsset(“matName”);
Check-out the scripting documention and try to find the Resource function.
You’ll get the complete list o_<
Yes, I was having trouble with UnloadAsset before. Regardless, I thought of a solution, however, for now, I am going to skip building a manager to handle all settings of objects, their materials etc and just do each level by hand for now.
My brain has gone thru a lot of programming lately and can’t really handle much more. Besides, it is not too much work to repeat the levels the way I have set it up. Thanks.