Search Unity

help,unity performance problem

Discussion in 'iOS and tvOS' started by lonlyHunter, Mar 8, 2010.

  1. lonlyHunter

    lonlyHunter

    Joined:
    Jan 11, 2010
    Posts:
    13
    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
     

    Attached Files:

  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    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.
     
  3. lonlyHunter

    lonlyHunter

    Joined:
    Jan 11, 2010
    Posts:
    13
    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]
     

    Attached Files:

  4. Ookoohko

    Ookoohko

    Joined:
    Sep 29, 2009
    Posts:
    103
    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
     
  5. jtbentley

    jtbentley

    Joined:
    Jun 30, 2009
    Posts:
    1,397
    I thought on iPhone it was locked to 1 anyway?

    But yes, 10 visible skins = death. Notice, Penelope had 0 :)
     
  6. lonlyHunter

    lonlyHunter

    Joined:
    Jan 11, 2010
    Posts:
    13
    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?
     
  7. lonlyHunter

    lonlyHunter

    Joined:
    Jan 11, 2010
    Posts:
    13
    if I have several characters how can I use only one skinned mesh? the sample penelope only have one moving object.
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    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
     
  9. Ookoohko

    Ookoohko

    Joined:
    Sep 29, 2009
    Posts:
    103
    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
     
  10. groovfruit

    groovfruit

    Joined:
    Apr 26, 2010
    Posts:
    257
    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!
     
  11. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
    Sprite Manager 2.0

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

    groovfruit

    Joined:
    Apr 26, 2010
    Posts:
    257

    SM2 doesn't support GUITextures.

    As I said above, I'm using GUITextures. Not planes, nor cubes or anything else meshy.
     
  13. b-joe

    b-joe

    Joined:
    Sep 7, 2009
    Posts:
    48
    @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.
     
  14. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    618
    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.

    Code (csharp):
    1.  
    2.  
    3. class SimpleIcon{
    4.     var prefab : GameObject; //thing to spawn
    5.     var texture : Texture2D;
    6.     var relativeRect : Rect; //screen relative
    7.     var screenRect : Rect; //screen actual
    8.     var cost : int;
    9. }
    10.  
    11. function CheckIcons(){
    12. for(i in icons){
    13.         if(i.screenRect.Contains(checkLoc)){
    14.             // do stuff
    15.             break;
    16.         }
    17. }
    18. }
    19.  

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