Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BerggreenDK · Sep 18, 2011 at 09:03 PM · c#webplayercounttrisverts

Calc tris and verts pr. frame in webplayer

Hi there, I have some people who says parts of a level is slowing the FPS down. As the users can build the levels themselfs, I would like to examine the FPS and verts/tris in certain areas/levels.

I have a FPS running now, but how do I calculate the verts/tris run-time in a scene?

I cant find anything in script reference, so I guess its gotta be manually somehow. Is it "for each child gameobject in scene, calc verts/tris and check every child within too recursively" ?

if so, where do I find the verts and tris?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Sep 18, 2011 at 10:09 PM

The Mesh-class has all you need. Every mesh is made up of vertices and triangles. With Mesh.vertexCount you can get the vertex count of this Mesh. The triangle count can only be queried by reading the length of the Mesh.triangles array and divide it by 3.

To get the overall vertex / triangle count in the scene just use this:

 // C#:
 
 int vertices = 0;
 int tris = 0;
 
 MeshFilter[] allMeshFilters = (MeshFilter[])FindObjectsOfType(typeof(MeshFilter));
 SkinnedMeshRenderer[] allSkinnedMeshes = (SkinnedMeshRenderer[])FindObjectsOfType(typeof(SkinnedMeshRenderer));
 
 foreach(MeshFilter MF in allMeshFilters)
 {
     vertices += MF.sharedMesh.vertexCount;
     tris += MF.sharedMesh.triangles.Length / 3;
 }
 foreach(SkinnedMeshRenderer SMR in allSkinnedMeshes)
 {
     vertices += SMR.sharedMesh.vertexCount;
     tris += SMR.sharedMesh.triangles.Length / 3;
 }
 
 Debug.Log("Vertex count: " + vertices + "   triangle count:" + tris);

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BerggreenDK · Sep 18, 2011 at 10:19 PM 0
Share

awesome! I found another script that did some calculations too, but it doesnt count all my dualsided alpha leafs I think or something else, because the editor shows one thing and the counter another... strange! Will try this one now. Thanks!

avatar image BerggreenDK · Sep 18, 2011 at 10:27 PM 0
Share

still get different stats from the view inside the editor and then this script. any clues to why?

avatar image Bunny83 · Sep 19, 2011 at 02:02 AM 0
Share

Well, the statistics in the editor are the true vertices and tris that are send to the graphics-device. Frustum-culling and occlusion culling will reduce the vert / tris count. On the other hand there are some things you almost can't track: the GUI!

Every GUI element have at least one drawcall, a button usually have two, one for the background-image and one for the text / image.

There are even other things that causes draw-calls like particles, cloth, GUITextures...

I'm not sure what you want to achieve? The vertex or tris count doesn't say anything about performance. Draw calls are the real problem. If Unity can batch a lot stuff into just a few drawcalls you can have millions of vertices. Also very important is what shaders you're using. If you have a bad combination of transparent shaders you will have a high fillrate (due to many overdraws)

avatar image BerggreenDK · Sep 19, 2011 at 07:57 AM 0
Share

drawcalls? batch... oh crap! I have around 500 drawcalls because our world is build up of small instatiated objects that grouped with a section parent.

avatar image BerggreenDK · Sep 19, 2011 at 07:59 AM 0
Share

yes, we have some bad(expensive) dual-sided alpha planes used for leafs on trees. Have thought of doing them as a "face the cam" plane ins$$anonymous$$d and reducing the numbers.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

In my game, the tris count is 70k and verts count is 130k and with 120 draw calls... how to optimize it. to make to run on low end android devices 1 Answer

How do I implement a third party API into Unity 3D? For Flash. 0 Answers

How to optimize the build game for unity webplayer? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges