Help,unity performance problem

Hi,why is my project’s fps very low in touch,about 15-25?I don’t used more model in it(just more than 100 triangles per model,and 9 models total in project).Follow is my state:
player object(the model about 120 triangles): capsule collider ,js
enamy object(the model about 120 triangles): capsule collider,js,enamy
terrain object(2 triangles):
camera object :behind the player and look at the target(transform.LookAt(target);).
3 guiTexture were used to control,5 guiText were used to show the data
the fps use guiText to show and use 1/Time.detalTime to count

272780--9808--$and22270and29255_14_108.png

you have 21 draw calls and a lot of animations, which is straining. Especially on the pre-3GS generation, this will definitely have an impact, the “low” tris usage (50% of the static budget), does not compensate for it in this case as you put a lot of work on the cpu and VFP end.

Fllow is the demo penelope’s state,it is run in touch about 30 fps,why is my project run slower than the penelope? [/img]

272804--9812--$and22270and29255_16_142.png

Looks like you have 10 visible skinned meshes, skinning can take a lot of power if you do it wrong.

Check out the max bones per vertex weight (the “quality” on Skinned Mesh Renderer) on your models and clamp that to 1 or max 2.

br,
Sami

I thought on iPhone it was locked to 1 anyway?

But yes, 10 visible skins = death. Notice, Penelope had 0 :slight_smile:

Thanks for your help!But I don’t just have one enamy.A enamy object have a FBX object and then have a skinned mesh.So,more than one enamy object,how can I just use one skinned mesh?

if I have several characters how can I use only one skinned mesh? the sample penelope only have one moving object.

you can’t, 10 objects are just 10 objects

but the drawcalls can be reduced through dynamic batching, to use that though your meshes must use 300 or less vertices

I didn’t mean that you have to clamp the number of meshes to one, but instead the weight per vertex to one.

Anyway, 10 skinned meshes is a lot on iPhone, unless the meshes have very few polygons.

br,
Sami

Regarding number of drawcells, how does one overcome this if their app is ALL GUITextures based? I looked at one of my scene and it had (on pressing play in the editor):

Emulated Draw Cells: 58 batched: 0 (can’t batch GUITextures??)
Editor Draw Cells: 56

I’m VERY worried >< >< Please help!

Sprite Manager 2.0

or your own variant of it. you can always use model-pacakge generated flat planes, or code-generated ones.

SM2 doesn’t support GUITextures.

As I said above, I**'m using GUITextures.** Not planes, nor cubes or anything else meshy.

@groovfruit

You kinda gave your own answer. :wink:

SM2 doesn’t support GUITextures, because as you correctly guessed GUITextures cannot be batched. There is a hint somewhere in the docs that advises to be careful with GUITextures on the iPhone because of this.

Your only options are to

a) reduce your graphics to use far less GUITextures
or
b) use very simple textured Meshobjects instead of GUITextures to achieve batched 2D-Graphics. If you want to make your life easier you can use SM2 for that.
or
c) reasonable combination of options a and b.

Heheh; sorry I’ll be a little more helpful now.

If you dont want to make use of SM2 for whatever reason, the method for creating “A 2D screen on top of your 3D world” is to create a new Camera and set it to Orthographic. have it render in front of everything else and set its culling to your own specific GUI layer. As for batching, the more stuff you can cram onto a single texture/material the better off you’ll be.

The way i work with GUI-related elements in iPhone is to create a single quad (thats 2 triangles) in a 3D package (lightwave in my case), UV it, and make it “one by one units” so when i drop it into Unity I know that when I scale it to some dimension it’ll end up being that many pixels in an orthographic camera.

If i have a complex GUI with weird oblong shapes (rectangles that arent power of 2 so adjusting UV’s by hand is painful) I will cram as much of it as I can into a single texture sheet and then drop it into the background of Lightwave3D and “Trace” the GUI elements borders into geometry, UV bake at 1:1 ratio, separate into layers and re-center for easy use in Unity. With this method you end up with multiple meshes that use the same material, but they can be batched and you have minimal-fuss to set it up in Unity.

SM2 simplifies all of this and is still quite efficient.

Detecting clicks on a mesh isnt so bad with Camera.ScreenPointToRay(someVector). However another method exists here where you can use Rect.Contains(someVector) and a simple if(Input.GetButton()) to detect if something got touched.

class SimpleIcon{
	var prefab : GameObject; //thing to spawn
	var texture : Texture2D;
	var relativeRect : Rect; //screen relative
	var screenRect : Rect; //screen actual
	var cost : int;
}

function CheckIcons(){
for(i in icons){
		if(i.screenRect.Contains(checkLoc)){
			// do stuff
			break;
		}
}
}

Summary: If you want performance SM2 is awesome. Or you can start using polygons :slight_smile: (which is what SM2 does anyway)