由于需要获取显卡信息,但是unity的自带函数,只能输出1个显卡

c#倒是可以但是引用了一个下载的dll   System.Management.dll

这个dll放到unity用不了,因为mono不支持

所以先用vs写个外部exe程序

using System;
using System.Management; public class Sample
{
public static void Main(string[] args)
{
string Gname = ""; ManagementObjectSearcher objvide = new ManagementObjectSearcher("select * from Win32_VideoController"); foreach (ManagementObject obj in objvide.Get())
{
Gname += ("Name - " + obj["Name"] + "</br>");
//System.Console.WriteLine("Name - " + obj["Name"] + "</br>");
//System.Console.WriteLine("DeviceID - " + obj["DeviceID"] + "</br>");
//System.Console.WriteLine("AdapterRAM - " + obj["AdapterRAM"] + "</br>");
//System.Console.WriteLine("AdapterDACType - " + obj["AdapterDACType"] + "</br>");
//System.Console.WriteLine("Monochrome - " + obj["Monochrome"] + "</br>");
//System.Console.WriteLine("InstalledDisplayDrivers - " + obj["InstalledDisplayDrivers"] + "</br>");
//System.Console.WriteLine("DriverVersion - " + obj["DriverVersion"] + "</br>");
//System.Console.WriteLine("VideoProcessor - " + obj["VideoProcessor"] + "</br>");
//System.Console.WriteLine("VideoArchitecture - " + obj["VideoArchitecture"] + "</br>");
//System.Console.WriteLine("VideoMemoryType - " + obj["VideoMemoryType"] + "</br>"); //Console.WriteLine("=====================================================");
} Console.WriteLine(Gname);
Console.WriteLine("=====================================================");
//Console.ReadKey();
}
}

然后生成运行下

Unity代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine; public class GetSystemInfo : MonoBehaviour { string a = ""; // Use this for initialization
void Start () { //这种方法可以
GetStr(); //这种方法也可以
//OpenEXE("C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe", "");
} /// <summary>
///
/// </summary>
/// <param name="_exePathName">路径</param>
/// <param name="_exeArgus">启动参数</param>
public void OpenEXE(string _exePathName, string _exeArgus)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(_exePathName, _exeArgus);
myprocess.StartInfo = startInfo;
myprocess.StartInfo.CreateNoWindow = true;
myprocess.StartInfo.UseShellExecute = false;
myprocess.StartInfo.RedirectStandardOutput = true;
//myprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myprocess.Start();
a += myprocess.StandardOutput.ReadLine();//只能读取1行
UnityEngine.Debug.Log(a);
myprocess.WaitForExit();
}
catch (Exception ex)
{
UnityEngine.Debug.Log("出错原因:" + ex.Message);
}
} public void GetStr()
{
try
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
//proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//这句会让unity卡死
proc.Start();
string fingerprint = proc.StandardOutput.ReadLine();
UnityEngine.Debug.Log(fingerprint);
proc.WaitForExit();
}
catch (Exception)
{ throw;
} } /********************************unity获取设备信息*******************************/
string systemInfo;
public void GetUnityInfo()
{
systemInfo = "\tTitle:当前系统基础信息:\n设备模型:" + SystemInfo.deviceModel + "\n设备名称:" + SystemInfo.deviceName + "\n设备类型:" + SystemInfo.deviceType +
"\n设备唯一标识符:" + SystemInfo.deviceUniqueIdentifier + "\n显卡标识符:" + SystemInfo.graphicsDeviceID +
"\n显卡设备名称:" + SystemInfo.graphicsDeviceName + "\n显卡厂商:" + SystemInfo.graphicsDeviceVendor +
"\n显卡厂商ID:" + SystemInfo.graphicsDeviceVendorID + "\n显卡支持版本:" + SystemInfo.graphicsDeviceVersion +
"\n显存(M):" + SystemInfo.graphicsMemorySize + "\n显卡像素填充率(百万像素/秒),-1未知填充率:" + SystemInfo.graphicsPixelFillrate +
"\n显卡支持Shader层级:" + SystemInfo.graphicsShaderLevel + "\n支持最大图片尺寸:" + SystemInfo.maxTextureSize +
"\nnpotSupport:" + SystemInfo.npotSupport + "\n操作系统:" + SystemInfo.operatingSystem +
"\nCPU处理核数:" + SystemInfo.processorCount + "\nCPU类型:" + SystemInfo.processorType +
"\nsupportedRenderTargetCount:" + SystemInfo.supportedRenderTargetCount + "\nsupports3DTextures:" + SystemInfo.supports3DTextures +
"\nsupportsAccelerometer:" + SystemInfo.supportsAccelerometer + "\nsupportsComputeShaders:" + SystemInfo.supportsComputeShaders +
"\nsupportsGyroscope:" + SystemInfo.supportsGyroscope + "\nsupportsImageEffects:" + SystemInfo.supportsImageEffects +
"\nsupportsInstancing:" + SystemInfo.supportsInstancing + "\nsupportsLocationService:" + SystemInfo.supportsLocationService +
"\nsupportsRenderTextures:" + SystemInfo.supportsRenderTextures + "\nsupportsRenderToCubemap:" + SystemInfo.supportsRenderToCubemap +
"\nsupportsShadows:" + SystemInfo.supportsShadows + "\nsupportsSparseTextures:" + SystemInfo.supportsSparseTextures +
"\nsupportsStencil:" + SystemInfo.supportsStencil + "\nsupportsVertexPrograms:" + SystemInfo.supportsVertexPrograms +
"\nsupportsVibration:" + SystemInfo.supportsVibration + "\n内存大小:" + SystemInfo.systemMemorySize;
}
void OnGUI()
{
GUILayout.Label(systemInfo);
}
/************************************************************************/ // Update is called once per frame
void Update () { }
}

===========

改良下

    public void GetStr()
{
try
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "C://Users/zts/source/repos/ConsoleApp9/ConsoleApp9/bin/Debug/ConsoleApp9.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
//proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//这句会让unity卡死
proc.Start();
a += proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
proc.Close();
UnityEngine.Debug.Log(a);
}
catch (Exception)
{ throw;
} }

unity 读取外部exe程序控制台信息的更多相关文章

  1. spring(读取外部数据库配置信息、基于注解管理bean、DI)

    ###解析外部配置文件在resources文件夹下,新建db.properties(和数据库连接相关的信息) driverClassName=com.mysql.jdbc.Driverurl=jdbc ...

  2. 如何用DELPHI编程修改外部EXE文件的版本信

    右击里面有修改 点开直接修改就可以了吧. DELPHI 里程序的版本信息怎么是灰色的,无法更改 耐心读以下说明,应该能解决你的问题,如果不能解决,请Hi我~ 如何给自己的dll文件添加版本信息呢? 首 ...

  3. 直接读取修改exe文件

    1. 前言 配置器的编写有很多的方式,主要是直接修改原始的受控端的程序,有的方式是把受控端和配置信息都放到控制端程序的内部,在需要配置受控端的时候直接输入配置信息,生成受控端:也有的方式是在外部直接修 ...

  4. Unity3D移动平台动态读取外部文件全解析

    前言: 一直有个想法,就是把工作中遇到的坑通过自己的深挖,总结成一套相同问题的解决方案供各位同行拍砖探讨.眼瞅着2015年第一个工作日就要来到了,小匹夫也休息的差不多了,寻思着也该写点东西活动活动大脑 ...

  5. windows下调用外部exe程序 SHELLEXECUTEINFO

    本文主要介绍两种在windows下调用外部exe程序的方法: 1.使用SHELLEXECUTEINFO 和 ShellExecuteEx SHELLEXECUTEINFO 结构体的定义如下: type ...

  6. C#和asp.net执行外部EXE程序

    这两天研究下.Net的执行外部EXE程序问题,就是在一个程序里通过按钮或其他操作运行起来另外一个程序,需要传入参数,如用户名.密码之类(实际上很类似单点登录,不过要简单的多的多):总结如下: 1.CS ...

  7. (转)Unity3D移动平台动态读取外部文件全解析

    Unity3D移动平台动态读取外部文件全解析 c#语言规范 阅读目录 前言: 假如我想在editor里动态读取文件 移动平台的资源路径问题 移动平台读取外部文件的方法 补充: 回到目录 前言: 一直有 ...

  8. Spring读取外部属性-properties

    概述 在Spring中处理外部值最简常用的方法就是外部创建name.properties文件,并在其中声明变量值,供Java进行读取.比如数据源信息配置,Java固定属性位置等.读取的方式一般由三种: ...

  9. sas通过IMPORT过程读取外部文件数据

    SAS通过IMPORT过程读取外部文件数据 使用IMPORT过程导入带分隔符的文件外,Microsoft Access数据库文件.Miscrosft Excel工作簿. dBase文件.JMP文件.S ...

随机推荐

  1. yum使用,使用rpm指令安装rpm,使用dpkg指令安装deb

    yum安装时如果报错提示安装失败,缺少库文件,可以使用: yum whatprovides 库名 之后安装提供的程序 yum remove xxx卸载 yum update 更新 解决 Require ...

  2. laravel中使用mgirations创建和迁移数据库

    使用php artisan make:migration create_links_table命令 编辑2016_04_11_095342_create_links_table public func ...

  3. Delphi Cookie获取及使用

    以下方法为网上搜集整理,留做备份,随时更新 一:通过URL获取 CanGetIECookie(URL,g_cookie); function   CanGetIECookie(const   URL: ...

  4. win10与子系统Ubuntu 相关配置

    系统间 文件访问: 1. 在win10环境下访问Ubuntu文件系统的home目录:C:\Users\xxx\AppData\Local\Packages\CanonicalGroupLimited. ...

  5. Slq怎么样获取首条记录和最后一条记录

    sql如何查询表的第一条记录和最后一条记录 方法一:使用top select TOP 1 * from apple;TOP 1 表示表apple中的第一条数据 select TOP 1 * from ...

  6. 二十二、Node.js-get&post

    get: 前台代码: <body> <h1>登录</h1> <form action="/dologin" method="ge ...

  7. animal与@keyframe

    .test1 { width: 90px; height: 60px; -webkit-animation-name: skyset; -webkit-animation-duration: 2000 ...

  8. Python3之collections模块

    简介 collections是Python内建的一个集合模块,提供了许多有用的集合类. namedtuple namedtuple 是一个函数,它用来创建一个自定义的元组对象,并且规定了元组元素的个数 ...

  9. loj6570 毛毛虫计数(生成函数FFT)

    link 巨佬olinr的题解 <-- olinr很强 考虑生成函数 考虑直径上点数>=4的毛毛虫的直径,考虑直径中间那些节点以及他上面挂的那些点的EGF \(A(x)=\sum_{i\g ...

  10. 2016级算法第四次上机-E.Bamboo and the Ancient Spell

    Bamboo and the Ancient Spell 分析 可能英文读题难度比较大,但是只要看到全大写的 "THE LONGEST COMMON SUBSEQUENCE !"应 ...