Files
PrinceOfGlory/Assets/Scripts/Logic/Network/PicoFunc.cs
Sora丶kong 2f0862b382 修复报错
2026-03-03 11:32:30 +08:00

84 lines
3.2 KiB
C#
Raw Blame History

using BigSpace.XRCore.Base;
using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
#if PICO_SDK || PXR_SDK
using Unity.XR.PICO.TOBSupport;
#endif
public class PicoFunc : Singleton<PicoFunc>
{
public string GetCode()
{
#if PICO_SDK || PXR_SDK
if (Application.platform == RuntimePlatform.Android)
{
return PXR_Enterprise.StateGetDeviceInfo(SystemInfoEnum.EQUIPMENT_SN);
}
#endif
string mac = "";
NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adaper in nis)
{
if (adaper.Description == "en0")
{
mac = adaper.GetPhysicalAddress().ToString();
break;
}
else
{
mac = adaper.GetPhysicalAddress().ToString();
if (mac != "") break;
}
}
return mac;
}
#region <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private static AndroidJavaObject audioManager = null;
private const string currentVolume = "getStreamVolume";//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
private const string maxVolume = "getStreamMaxVolume";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private const int STREAM_SYSTEM = 1;
private float maxvo = 0;
private float nowvo = 0;
int volum = 0;
public uint GetSystemVolume()
{
if (Application.platform == RuntimePlatform.Android)
{
if (audioManager == null)
{
AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
audioManager = currentActivity.Call<AndroidJavaObject>("getSystemService", new AndroidJavaObject("java.lang.String", "audio"));
maxvo = float.Parse(audioManager.Call<int>(maxVolume, STREAM_SYSTEM).ToString());
}
nowvo = float.Parse(audioManager.Call<int>(currentVolume, STREAM_SYSTEM).ToString());
volum = Mathf.CeilToInt((nowvo / maxvo) * 100);
//Debug.Log("<22><><EFBFBD><EFBFBD>:" + volum);
return (uint)volum;
//Debug.Log("STREAM_VOICE_CALL:" + audioManager.Call<int>(currentVolume, STREAM_VOICE_CALL).ToString());
//Debug.Log("STREAM_RING:" + audioManager.Call<int>(currentVolume, STREAM_RING).ToString());
//Debug.Log("STREAM_MUSIC:" + audioManager.Call<int>(currentVolume, STREAM_MUSIC).ToString());
//Debug.Log("STREAM_ALARM:" + audioManager.Call<int>(currentVolume, STREAM_ALARM).ToString());
//Debug.Log("STREAM_NOTIFICATION:" + audioManager.Call<int>(currentVolume, STREAM_NOTIFICATION).ToString());
//Debug.Log("STREAM_DTMF:" + audioManager.Call<int>(currentVolume, STREAM_DTMF).ToString());
}
return 100;
}
public uint GetBatter()
{
#if PICO_SDK || PXR_SDK
if (Application.platform == RuntimePlatform.Android)
{
return uint.Parse(PXR_Enterprise.StateGetDeviceInfo(SystemInfoEnum.ELECTRIC_QUANTITY));
}
#endif
return 100;
}
#endregion
}