Skip to content

Commit

Permalink
Update NDI plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Aug 28, 2020
1 parent 4da6782 commit 96a77d6
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 92 deletions.
108 changes: 50 additions & 58 deletions Assets/Main.unity

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions Assets/SourceSelector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using System.Linq;
using Klak.Ndi;

namespace Nsm
Expand All @@ -10,50 +11,50 @@ public class SourceSelector : MonoBehaviour
[SerializeField] Dropdown _dropdown = null;

NdiReceiver _receiver;

List<string> _sourceNames = new List<string>();
List<string> _sourceNames;
bool _disableCallback;

void Start()
{
_receiver = GetComponent<NdiReceiver>();
}
// HACK: Assuming that the dropdown has more than
// three child objects only while it's opened.
bool IsOpened => _dropdown.transform.childCount > 3;

void Start() => _receiver = GetComponent<NdiReceiver>();

void Update()
{
// HACK: Assuming that the dropdown would have more than three child
// objects while the menu is opened. Stop updating it while visible.
if (_dropdown.transform.childCount > 3) return;
// Do nothing if the menu is opened.
if (IsOpened) return;

// NDI source name retrieval
_sourceNames = NdiFinder.sourceNames.ToList();

// Retrieve the NDI source names.
NdiManager.GetSourceNames(_sourceNames);
// Currect selection
var index = _sourceNames.IndexOf(_receiver.ndiName);

// Update the current selection.
var index = _sourceNames.IndexOf(_receiver.sourceName);
// Append the current name to the list if it's not found.
if (index < 0)
{
// Append the current name to the list when it's not found.
index = _sourceNames.Count;
_sourceNames.Add(_receiver.sourceName);
_sourceNames.Add(_receiver.ndiName);
}

// We don't like to receive callback while editing options.
// Disable the callback while updating the menu options.
_disableCallback = true;

// Update the menu options.
// Menu option update
_dropdown.ClearOptions();
_dropdown.AddOptions(_sourceNames);
_dropdown.value = index;
_dropdown.RefreshShownValue();

// Resume receiving callback.
// Resume the callback.
_disableCallback = false;
}

public void OnChangeValue(int value)
{
if (_disableCallback) return;
_receiver.sourceName = _sourceNames[value];
_receiver.ndiName = _sourceNames[value];
}

public void OnClickEmptyArea()
Expand Down
23 changes: 14 additions & 9 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"dependencies": {
"com.unity.package-manager-ui": "2.1.2",
"jp.keijiro.klak.ndi": "https://github.com/keijiro/KlakNDI.git#upm",
"com.unity.modules.ui": "1.0.0"
},
"lock": {
"jp.keijiro.klak.ndi": {
"hash": "2489b981f9c740977e1db7d9601e6b52b472ba03",
"revision": "upm"
"scopedRegistries": [
{
"name": "Unity NuGet",
"url": "https://unitynuget-registry.azurewebsites.net",
"scopes": [ "org.nuget" ]
},
{
"name": "Keijiro",
"url": "https://registry.npmjs.com",
"scopes": [ "jp.keijiro" ]
}
],
"dependencies": {
"jp.keijiro.klak.ndi": "1.0.4",
"com.unity.ugui": "1.0.0"
}
}
81 changes: 81 additions & 0 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"dependencies": {
"com.unity.ugui": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0"
}
},
"jp.keijiro.klak.ndi": {
"version": "1.0.4",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.screencapture": "1.0.0",
"org.nuget.system.memory": "4.5.3"
},
"url": "https://registry.npmjs.com"
},
"org.nuget.system.buffers": {
"version": "4.4.0",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://unitynuget-registry.azurewebsites.net"
},
"org.nuget.system.memory": {
"version": "4.5.3",
"depth": 1,
"source": "registry",
"dependencies": {
"org.nuget.system.buffers": "4.4.0",
"org.nuget.system.numerics.vectors": "4.4.0",
"org.nuget.system.runtime.compilerservices.unsafe": "4.5.2"
},
"url": "https://unitynuget-registry.azurewebsites.net"
},
"org.nuget.system.numerics.vectors": {
"version": "4.4.0",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://unitynuget-registry.azurewebsites.net"
},
"org.nuget.system.runtime.compilerservices.unsafe": {
"version": "4.5.2",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://unitynuget-registry.azurewebsites.net"
},
"com.unity.modules.imageconversion": {
"version": "1.0.0",
"depth": 2,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.imgui": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
},
"com.unity.modules.screencapture": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.imageconversion": "1.0.0"
}
},
"com.unity.modules.ui": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
}
}
}
14 changes: 12 additions & 2 deletions ProjectSettings/EditorSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
serializedVersion: 9
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 1
Expand All @@ -16,10 +16,20 @@ EditorSettings:
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref
m_ProjectGenerationRootNamespace:
m_CollabEditorSettings:
inProgressEnabled: 1
m_EnableTextureStreamingInEditMode: 1
m_EnableTextureStreamingInPlayMode: 1
m_AsyncShaderCompilation: 1
m_EnterPlayModeOptionsEnabled: 0
m_EnterPlayModeOptions: 3
m_ShowLightmapResolutionOverlay: 1
m_UseLegacyProbeSampleCount: 1
m_AssetPipelineMode: 1
m_CacheServerMode: 0
m_CacheServerEndpoint:
m_CacheServerNamespacePrefix: default
m_CacheServerEnableDownload: 1
m_CacheServerEnableUpload: 1
5 changes: 4 additions & 1 deletion ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
serializedVersion: 13
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
Expand Down Expand Up @@ -33,6 +33,7 @@ GraphicsSettings:
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
Expand All @@ -57,3 +58,5 @@ GraphicsSettings:
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
m_LogWhenShaderIsCompiled: 0
m_AllowEnlightenSupportForUpgradedProject: 1
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.1.10f1
m_EditorVersionWithRevision: 2019.1.10f1 (f007ed779b7a)
m_EditorVersion: 2019.4.9f1
m_EditorVersionWithRevision: 2019.4.9f1 (50fe8a171dd9)
2 changes: 1 addition & 1 deletion ProjectSettings/UnityConnectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
UnityConnectSettings:
m_ObjectHideFlags: 0
serializedVersion: 1
m_Enabled: 1
m_Enabled: 0
m_TestMode: 0
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
Expand Down

0 comments on commit 96a77d6

Please sign in to comment.