Use the SystemInfo class to get all kinds of information about the Unity3d running device (CPU type, graphics card type, etc.)

Source: Internet
Author: User
Tags getmessage unique id

1. Overview

2. Create a demo project

3. Writing Sample Code

4. Execute code

6. Other

1. Overview

After studying the application class of Unity3d, it is time to look at the SystemInfo class. All two of these classes are in the Unityengine class.

The properties in the SystemInfo class are read-only and store information about the platform, primarily the graphics card and device information, such as the name of the device, the type of device, the type of video card, the name of the graphics card vendor (manufacturer), system memory size, memory size, number of render targets supported, and so on.

2. Create a demo project (1) Open Unity3d, create a new project, (2) Create a new C # script and bind the script to the main camera (Miancamera), and (3) Click Gameobject on the menu bar, select UI, and add a text. 3. Write the sample code (1) Double-click to open the newly created script and start editing the code (in fact the SystemInfo class is simple).

The code is written as follows:

1 usingUnityengine;2 3 usingSystem.Collections;4 5 usingSystem.Collections.Generic;6 7  Public classGamecontrollerscript:monobehaviour8 9 {Ten  One     //Specify the output text box A  -      PublicUnityEngine.UI.Text MessageText; -  the     //Storing temporary strings -  -System.Text.StringBuilder info =NewSystem.Text.StringBuilder (); -  +     //Use this for initialization -  +     voidStart () A  at     { -  -         -  -         //Empty the output text box -  inMessagetext.text =""; -  toInfo. Appendline ("Device and System Information:"); +  -   the  *         //model of the device $ Panax NotoginsengGetMessage ("Device Model", Systeminfo.devicemodel); -  the         //the name of the device +  AGetMessage ("Device Name", systeminfo.devicename); the  +         //type of device -  $GetMessage ("Device type (PC, handheld)", SystemInfo.deviceType.ToString ()); $  -         //system memory Size -  theGetMessage ("system memory size MB", SystemInfo.systemMemorySize.ToString ()); - Wuyi         //Operating System the  -GetMessage ("Operating System", Systeminfo.operatingsystem); Wu  -         //Unique identifier of the device About  $GetMessage ("Device Unique identifier", systeminfo.deviceuniqueidentifier); -  -         //Graphics device identification ID -  AGetMessage ("video Card ID", SystemInfo.graphicsDeviceID.ToString ()); +  the         //Video card name -  $GetMessage ("Video card name", systeminfo.graphicsdevicename); the  the         //video card Type the  theGetMessage ("video card Type", SystemInfo.graphicsDeviceType.ToString ()); -  in         //Graphics Supplier the  theGetMessage ("Graphics Supplier", Systeminfo.graphicsdevicevendor); About  the         //video card supply Unique ID the  theGetMessage ("video card supply Unique ID", SystemInfo.graphicsDeviceVendorID.ToString ()); +  -         //Graphics Version number the BayiGetMessage ("Graphics Version number", systeminfo.graphicsdeviceversion); the  the         //video card memory size -  -GetMessage ("Memory size MB", SystemInfo.graphicsMemorySize.ToString ()); the  the         //whether the video card supports multi-threaded rendering the  theGetMessage ("whether the video card supports multi-threaded rendering", SystemInfo.graphicsMultiThreaded.ToString ()); -  the         //number of render targets supported the  theGetMessage ("number of render targets supported", SystemInfo.supportedRenderTargetCount.ToString ());94  the   the  the  98  About   - 101  102 103  104  the         //Output106 107Messagetext.text =info. ToString ();108 109     } the 111   the 113     //Update is called once per frame the  the     voidUpdate () the 117     {118 119         //Exit - 121         if(Input.getkeyup ("Escape"))122 123         {124  the  126 127             if(Input.getkeyup ("Escape")) - 129             { the 131 application.quit (); the 133             }134 135         }136 137     }138 139     voidGetMessage (params string[] str) $ 141     {142 143         if(str. length==2)144 145         {146 147Info. Appendline (str[0]+":"+str[1]);148 149         } Max 151     }   the 153}

(2) Save the code, go to the Unity3d editor, and bind the text to the script. 4. Execute code

After executing the code, you can display some information about the running device.

(1) Results from running in the Unity3d editor:

(1) Results of running in Windows:

(1) Results of running in Android:

6. Other

If you have fun, you can check the official documentation for other properties and methods of SystemInfo, and the link is: https://docs.unity3d.com/ScriptReference/SystemInfo.html

If there is a mistake, also look correct!

Use the SystemInfo class to get all kinds of information about the Unity3d running device (CPU type, graphics card type, etc.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.