Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by Raphael · Mar 30, 2010 at 06:17 PM · debugpolygon-count

poly and vertex counting at runtime

Hi all,

I'm trying to display at runtime (deployed app runtime) on the GUI the poly and vertex count visible on the camera and i came up with this:

using UnityEngine; using System.Collections;

public class GFXStats : MonoBehaviour { public GameObject[] allObjects; public float totalPoly; public int totalVertex;

 // Use this for initialization
 void Start()
 {
     allObjects = (GameObject[]) GameObject.FindObjectsOfType(typeof(GameObject));
 }

 void OnGUI()
 {
     string display = "polys: " + totalPoly.ToString() + " / vertex: " + totalVertex.ToString();
     Vector2 dimensao = GUI.skin.label.CalcSize(new GUIContent(display));
     GUI.Label(new Rect(Screen.width / 2 - dimensao.x / 2, Screen.height - 30, dimensao.x, 30), display);
 }

 // Update is called once per frame
 void Update()
 {
     float polyCount = 0;
     int vertCount = 0;
     foreach (GameObject obj in allObjects)
     {
         Renderer rend = obj.GetComponent<Renderer>();
         if (rend && rend.isVisible)
         {
             MeshFilter mf = obj.GetComponent<MeshFilter>();
             if (mf)
             {
                 polyCount += mf.mesh.triangles.Length/3;
                 vertCount += mf.mesh.vertexCount;
             }
         }
     }
     totalPoly = polyCount;
     totalVertex = vertCount;
 }

}

But the code is only counting the meshes totals. I was looking for the rendering totals (reflections, projectors, etc, increase those values) Any idea ?

Thanks in advance!

Comment
Add comment · Show 1
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 · Oct 18, 2011 at 07:27 PM 0
Share

I wonder if they would be so proud of the Profiler in the PRO edition if this was possible just by scripting. As I see it Profiler is one of their sellingpoints for a PRO license.

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Dreamora 1 · Oct 18, 2010 at 01:27 AM

There is no way to extract these information in the player at least not without installing NVIDIA PerfHUD and checking them there

Comment
Add comment · Show 1 · 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 yoyo · Jan 09, 2011 at 09:56 PM 0
Share

PerfHUD and similar tools are a great way to benchmark, and they will give you much more info than just a vertex count. http://developer.nvidia.com/object/nvperfhud_home.html

avatar image
0

Answer by duck · Mar 30, 2010 at 08:09 PM

You're aware of the Rendering Statistics Window in the Game View, right? It does all this. It's not available in your built version though, but since you haven't specifically mentioned that you're aware of it, and you also haven't mentioned built vs. editor runtime, I've just got to check!

Comment
Add comment · Show 1 · 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 Raphael · Mar 30, 2010 at 08:25 PM 0
Share

sure, i'm aware about the stats window in the editor. I was looking to display those info in the deployed app runtime. Sorry, it is really confusing. I'm editing the question. Thanks anyway ;)

avatar image
0

Answer by lustu · Oct 18, 2011 at 06:18 PM

I'm also interrested by this answer, and to be more specific, by the number of polygons actually displayed by the graphical card (i.e. including frustum culling)

Comment
Add comment · 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
0

Answer by FiveFingers · Apr 16, 2013 at 05:42 PM

Blitz3D a directx7 basic metalanguage used in far 2000 that costed 100$ had total vertices and triangles count in 2 simple api call. I can't get why Unity doesn't have such calls.

Comment
Add comment · 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
0

Answer by sendmailtonani · Nov 18, 2021 at 02:27 AM

alt text


display-mesh-triangles-in-ui.png (150.8 kB)
Comment
Add comment · 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
  • 1
  • 2
  • ›

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Shooting AI problem 2 Answers

setting your own masterserver up 2 Answers

Debug.Log doesn't get called when Unity freezes? 2 Answers

Assigning breakpoints properties in MonoDevelop? 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