From f13c8c4abbf123d7887f1f17e5b39ed0a51ea8b2 Mon Sep 17 00:00:00 2001 From: jdibenes <58836755+jdibenes@users.noreply.github.com> Date: Tue, 15 Nov 2022 11:30:33 -0500 Subject: [PATCH] unity get local ip address --- hl2ss/hl2ss/Package.appxmanifest | 2 +- hl2ss/plugin/configuration.h | 4 ++-- unity/hl2ss.cs | 23 +++++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/hl2ss/hl2ss/Package.appxmanifest b/hl2ss/hl2ss/Package.appxmanifest index bd1605218..1faa3c453 100644 --- a/hl2ss/hl2ss/Package.appxmanifest +++ b/hl2ss/hl2ss/Package.appxmanifest @@ -9,7 +9,7 @@ + Version="1.0.12.0" /> hl2ss diff --git a/hl2ss/plugin/configuration.h b/hl2ss/plugin/configuration.h index 4e7ea877c..38507540d 100644 --- a/hl2ss/plugin/configuration.h +++ b/hl2ss/plugin/configuration.h @@ -2,7 +2,7 @@ #pragma once #define HL2SS_ENABLE_RM 1 -#define HL2SS_ENABLE_MC 2 -#define HL2SS_ENABLE_PV 4 +#define HL2SS_ENABLE_PV 2 +#define HL2SS_ENABLE_MC 4 #define HL2SS_ENABLE_SI 8 #define HL2SS_ENABLE_RC 16 diff --git a/unity/hl2ss.cs b/unity/hl2ss.cs index 4cf33b712..6c06b0eb4 100644 --- a/unity/hl2ss.cs +++ b/unity/hl2ss.cs @@ -23,6 +23,8 @@ public class hl2ss : MonoBehaviour private static extern void MQ_Restart(); [DllImport("hl2ss")] private static extern void SI_Update(); + [DllImport("hl2ss")] + private static extern void GetLocalIPv4Address(byte[] data, int size); #else private void InitializeStreams(uint enable) { @@ -54,6 +56,11 @@ private void MQ_Restart() private void SI_Update() { } + + private void GetLocalIPv4Address(byte[] data, int size) + { + + } #endif [Tooltip("Must be enabled if InitializeStreams is called from the cpp code and disabled otherwise.")] @@ -62,15 +69,18 @@ private void SI_Update() [Tooltip("Enable Research Mode sensors streams. Has no effect if InitializeStreams is called from the cpp code.")] public bool enableRM = true; - [Tooltip("Enable Microphone stream. Has no effect if InitializeStreams is called from the cpp code.")] - public bool enableMC = true; - [Tooltip("Enable Front Camera stream. Has no effect if InitializeStreams is called from the cpp code.")] public bool enablePV = true; + [Tooltip("Enable Microphone stream. Has no effect if InitializeStreams is called from the cpp code.")] + public bool enableMC = true; + [Tooltip("Enable Spatial Input stream. Allowed only if InitializeStreams is called from the cpp code and must be disabled otherwise.")] public bool enableSI = false; + [Tooltip("Enable Remoce Configuration. Has no effect if InitializeStreams is called from the cpp code.")] + public bool enableRC = true; + [Tooltip("Set to BasicMaterial to support semi-transparent primitives.")] public Material m_material; @@ -88,7 +98,12 @@ void Start() m_loop = false; m_mode = false; - if (!skipInitialization) { InitializeStreams((enableRM ? 1U : 0U) | (enableMC ? 2U : 0U) | (enablePV ? 4U : 0U)); } + if (!skipInitialization) { InitializeStreams((enableRM ? 1U : 0U) | (enablePV ? 2U : 0U) | (enableMC ? 4U : 0U) | (enableRC ? 16U : 0U)); } + + byte[] ipaddress = new byte[16 * 2]; + GetLocalIPv4Address(ipaddress, ipaddress.Length); + string ip = System.Text.Encoding.Unicode.GetString(ipaddress); + DebugMessage(string.Format("UNITY: Local IP Address is: {0}", ip)); } // Update is called once per frame