Skip to content

Commit

Permalink
unity get local ip address
Browse files Browse the repository at this point in the history
  • Loading branch information
jdibenes committed Nov 15, 2022
1 parent 78c4bf8 commit f13c8c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hl2ss/hl2ss/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="eaaf3af3-1402-4e5b-b6a1-5d0fbb7c1ba8"
Publisher="CN=jcds"
Version="1.0.11.0" />
Version="1.0.12.0" />
<mp:PhoneIdentity PhoneProductId="eaaf3af3-1402-4e5b-b6a1-5d0fbb7c1ba8" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>hl2ss</DisplayName>
Expand Down
4 changes: 2 additions & 2 deletions hl2ss/plugin/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 19 additions & 4 deletions unity/hl2ss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.")]
Expand All @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit f13c8c4

Please sign in to comment.