parent
650d2ee113
commit
a3365665e1
36 changed files with 0 additions and 1071 deletions
@ -1,9 +0,0 @@ |
|||||||
* -text |
|
||||||
|
|
||||||
*.cs text eol=lf diff=csharp |
|
||||||
*.shader text eol=lf |
|
||||||
*.cginc text eol=lf |
|
||||||
*.hlsl text eol=lf |
|
||||||
*.compute text eol=lf |
|
||||||
|
|
||||||
*.meta text eol=lf |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
# Windows |
|
||||||
Thumbs.db |
|
||||||
Desktop.ini |
|
||||||
|
|
||||||
# macOS |
|
||||||
.DS_Store |
|
||||||
|
|
||||||
# Code Editors |
|
||||||
.idea |
|
||||||
.vscode |
|
||||||
*.csproj |
|
||||||
*.sln |
|
||||||
*.swp |
|
||||||
|
|
||||||
# Unity |
|
||||||
/Library |
|
||||||
/Temp |
|
||||||
|
|
||||||
Assets/Plugins |
|
||||||
Assets/Plugins.meta |
|
||||||
@ -1,4 +0,0 @@ |
|||||||
.git |
|
||||||
.gitignore |
|
||||||
.gitattributes |
|
||||||
.gitmodules |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: bfb9850bc5423b54c862ff4b58e1ea25 |
|
||||||
folderAsset: yes |
|
||||||
DefaultImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,125 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
using UnityEngine; |
|
||||||
using UnityEditor; |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
|
|
||||||
namespace Klak.Spout |
|
||||||
{ |
|
||||||
[CanEditMultipleObjects] |
|
||||||
[CustomEditor(typeof(SpoutReceiver))] |
|
||||||
public class SpoutReceiverEditor : Editor |
|
||||||
{ |
|
||||||
SerializedProperty _nameFilter; |
|
||||||
SerializedProperty _targetTexture; |
|
||||||
SerializedProperty _targetRenderer; |
|
||||||
SerializedProperty _targetMaterialProperty; |
|
||||||
|
|
||||||
static GUIContent _labelProperty = new GUIContent("Property"); |
|
||||||
|
|
||||||
string[] _propertyList; // cached property list |
|
||||||
Shader _cachedShader; // shader used to cache the list |
|
||||||
|
|
||||||
// Retrieve shader from a target renderer. |
|
||||||
Shader RetrieveTargetShader(UnityEngine.Object target) |
|
||||||
{ |
|
||||||
var renderer = target as Renderer; |
|
||||||
if (renderer == null) return null; |
|
||||||
|
|
||||||
var material = renderer.sharedMaterial; |
|
||||||
if (material == null) return null; |
|
||||||
|
|
||||||
return material.shader; |
|
||||||
} |
|
||||||
|
|
||||||
// Cache properties of a given shader if it's |
|
||||||
// different from a previously given one. |
|
||||||
void CachePropertyList(Shader shader) |
|
||||||
{ |
|
||||||
if (_cachedShader == shader) return; |
|
||||||
|
|
||||||
var temp = new List<string>(); |
|
||||||
|
|
||||||
var count = ShaderUtil.GetPropertyCount(shader); |
|
||||||
for (var i = 0; i < count; i++) |
|
||||||
{ |
|
||||||
var propType = ShaderUtil.GetPropertyType(shader, i); |
|
||||||
if (propType == ShaderUtil.ShaderPropertyType.TexEnv) |
|
||||||
temp.Add(ShaderUtil.GetPropertyName(shader, i)); |
|
||||||
} |
|
||||||
|
|
||||||
_propertyList = temp.ToArray(); |
|
||||||
_cachedShader = shader; |
|
||||||
} |
|
||||||
|
|
||||||
// Material property drop-down list. |
|
||||||
void ShowMaterialPropertyDropDown() |
|
||||||
{ |
|
||||||
// Try to retrieve the target shader. |
|
||||||
var shader = RetrieveTargetShader(_targetRenderer.objectReferenceValue); |
|
||||||
|
|
||||||
if (shader != null) |
|
||||||
{ |
|
||||||
// Cache the property list of the target shader. |
|
||||||
CachePropertyList(shader); |
|
||||||
|
|
||||||
// If there are suitable candidates... |
|
||||||
if (_propertyList.Length > 0) |
|
||||||
{ |
|
||||||
// Show the drop-down list. |
|
||||||
var index = Array.IndexOf(_propertyList, _targetMaterialProperty.stringValue); |
|
||||||
var newIndex = EditorGUILayout.Popup("Property", index, _propertyList); |
|
||||||
|
|
||||||
// Update the property if the selection was changed. |
|
||||||
if (index != newIndex) |
|
||||||
_targetMaterialProperty.stringValue = _propertyList[newIndex]; |
|
||||||
} |
|
||||||
else |
|
||||||
_targetMaterialProperty.stringValue = ""; // reset on failure |
|
||||||
} |
|
||||||
else |
|
||||||
_targetMaterialProperty.stringValue = ""; // reset on failure |
|
||||||
} |
|
||||||
|
|
||||||
void OnEnable() |
|
||||||
{ |
|
||||||
_nameFilter = serializedObject.FindProperty("_nameFilter"); |
|
||||||
_targetTexture = serializedObject.FindProperty("_targetTexture"); |
|
||||||
_targetRenderer = serializedObject.FindProperty("_targetRenderer"); |
|
||||||
_targetMaterialProperty = serializedObject.FindProperty("_targetMaterialProperty"); |
|
||||||
} |
|
||||||
|
|
||||||
void OnDisable() |
|
||||||
{ |
|
||||||
_propertyList = null; |
|
||||||
_cachedShader = null; |
|
||||||
} |
|
||||||
|
|
||||||
public override void OnInspectorGUI() |
|
||||||
{ |
|
||||||
serializedObject.Update(); |
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(_nameFilter); |
|
||||||
EditorGUILayout.PropertyField(_targetTexture); |
|
||||||
EditorGUILayout.PropertyField(_targetRenderer); |
|
||||||
|
|
||||||
EditorGUI.indentLevel++; |
|
||||||
|
|
||||||
if (_targetRenderer.hasMultipleDifferentValues) |
|
||||||
{ |
|
||||||
// Show a simple text field if there are multiple values. |
|
||||||
EditorGUILayout.PropertyField(_targetMaterialProperty, _labelProperty); |
|
||||||
} |
|
||||||
else if (_targetRenderer.objectReferenceValue != null) |
|
||||||
{ |
|
||||||
// Show the material property drop-down list. |
|
||||||
ShowMaterialPropertyDropDown(); |
|
||||||
} |
|
||||||
|
|
||||||
EditorGUI.indentLevel--; |
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: e66c46a000456b34e95a2661f5d5391b |
|
||||||
timeCreated: 1492008499 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,28 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
using UnityEngine; |
|
||||||
using UnityEditor; |
|
||||||
|
|
||||||
namespace Klak.Spout |
|
||||||
{ |
|
||||||
[CanEditMultipleObjects] |
|
||||||
[CustomEditor(typeof(SpoutSender))] |
|
||||||
public class SpoutSenderEditor : Editor |
|
||||||
{ |
|
||||||
SerializedProperty _clearAlpha; |
|
||||||
|
|
||||||
void OnEnable() |
|
||||||
{ |
|
||||||
_clearAlpha = serializedObject.FindProperty("_clearAlpha"); |
|
||||||
} |
|
||||||
|
|
||||||
public override void OnInspectorGUI() |
|
||||||
{ |
|
||||||
serializedObject.Update(); |
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(_clearAlpha); |
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 4d54f6c4c801e1148b465b8fb9d50412 |
|
||||||
timeCreated: 1492008196 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,46 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
using UnityEngine; |
|
||||||
using UnityEditor; |
|
||||||
|
|
||||||
namespace Klak.Spout |
|
||||||
{ |
|
||||||
// Spout sender list window |
|
||||||
public class SpoutSenderListWindow : EditorWindow |
|
||||||
{ |
|
||||||
[MenuItem("Window/Klak/Spout Sender List")] |
|
||||||
static void Init() |
|
||||||
{ |
|
||||||
EditorWindow.GetWindow<SpoutSenderListWindow>("Spout Senders").Show(); |
|
||||||
} |
|
||||||
|
|
||||||
int _updateCount; |
|
||||||
|
|
||||||
void OnInspectorUpdate() |
|
||||||
{ |
|
||||||
// Update once per eight calls. |
|
||||||
if ((_updateCount++ & 7) == 0) Repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
void OnGUI() |
|
||||||
{ |
|
||||||
var count = PluginEntry.CountSharedObjects(); |
|
||||||
|
|
||||||
EditorGUILayout.Space(); |
|
||||||
EditorGUI.indentLevel++; |
|
||||||
|
|
||||||
if (count == 0) |
|
||||||
EditorGUILayout.LabelField("No sender detected."); |
|
||||||
else |
|
||||||
EditorGUILayout.LabelField(count + " sender(s) detected."); |
|
||||||
|
|
||||||
for (var i = 0; i < count; i++) |
|
||||||
{ |
|
||||||
var name = PluginEntry.GetSharedObjectNameString(i); |
|
||||||
if (name != null) EditorGUILayout.LabelField("- " + name); |
|
||||||
} |
|
||||||
|
|
||||||
EditorGUI.indentLevel--; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 66d9365756bb8784faa1774081cc4a3e |
|
||||||
timeCreated: 1492007252 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
{ |
|
||||||
"name": "jp.keijiro.klak.spout.Editor", |
|
||||||
"references": [ |
|
||||||
"jp.keijiro.klak.spout.Runtime" |
|
||||||
], |
|
||||||
"optionalUnityReferences": [], |
|
||||||
"includePlatforms": [ |
|
||||||
"Editor" |
|
||||||
], |
|
||||||
"excludePlatforms": [], |
|
||||||
"allowUnsafeCode": false |
|
||||||
} |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 21435214e6169c649985b5540a63188a |
|
||||||
AssemblyDefinitionImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,21 +0,0 @@ |
|||||||
MIT License |
|
||||||
|
|
||||||
Copyright (c) 2017 Keijiro Takahashi |
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||||
of this software and associated documentation files (the "Software"), to deal |
|
||||||
in the Software without restriction, including without limitation the rights |
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||||
copies of the Software, and to permit persons to whom the Software is |
|
||||||
furnished to do so, subject to the following conditions: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all |
|
||||||
copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||||
SOFTWARE. |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: a3a09c268502f7746810f38992bd70b2 |
|
||||||
TextScriptImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,94 +0,0 @@ |
|||||||
KlakSpout |
|
||||||
========= |
|
||||||
|
|
||||||
 |
|
||||||
|
|
||||||
**KlakSpout** is a Unity plugin that allows sharing rendered frames with other |
|
||||||
applications with using the [Spout] protocol. |
|
||||||
|
|
||||||
The Spout protocol is supported by several frameworks (Processing, |
|
||||||
openFrameworks, etc.) and software packages (Resolume, AfterEffects, etc.). |
|
||||||
The plugin allows Unity to interoperate with them in real time without |
|
||||||
incurring much overhead. |
|
||||||
|
|
||||||
[Spout]: http://spout.zeal.co/ |
|
||||||
|
|
||||||
System Requirements and Compatibilities |
|
||||||
--------------------------------------- |
|
||||||
|
|
||||||
- KlakSpout requires Unity 5.6.0 or later. |
|
||||||
- KlakSpout only supports Direct3D 11 (DX11) graphics API mode. Other APIs |
|
||||||
(DX9, DX12, OpenGL core, etc.) are not supported at the moment. |
|
||||||
|
|
||||||
Features |
|
||||||
-------- |
|
||||||
|
|
||||||
### Sending frames from a camera |
|
||||||
|
|
||||||
You can send rendered frames from a camera in a scene with attaching the |
|
||||||
**SpoutSender** component to it. |
|
||||||
|
|
||||||
### Receiving frames from other applications |
|
||||||
|
|
||||||
You can receive frames from other applications and store them into a render |
|
||||||
texture, or set them to a material property as an animating texture. |
|
||||||
|
|
||||||
Installation |
|
||||||
------------ |
|
||||||
|
|
||||||
Download one of the unitypackage files from the [Releases] page and import it |
|
||||||
to a project. |
|
||||||
|
|
||||||
[Releases]: https://github.com/keijiro/KlakSpout/releases |
|
||||||
|
|
||||||
Component Reference |
|
||||||
------------------- |
|
||||||
|
|
||||||
### SpoutSender component |
|
||||||
|
|
||||||
 |
|
||||||
|
|
||||||
**SpoutSender** is a component for sending rendered frames to other |
|
||||||
Spout-compatible applications. |
|
||||||
|
|
||||||
SpoutSender has only one property. **Clear Alpha** controls whether if contents |
|
||||||
of the alpha channel are to be shared or discarded. When it's set to true, it |
|
||||||
clears up the contents of the alpha channel with 1.0 (100% opacity). It's |
|
||||||
useful when the alpha channel doesn't have any particular use. |
|
||||||
|
|
||||||
### SpoutReceiver component |
|
||||||
|
|
||||||
 |
|
||||||
|
|
||||||
**SpoutReceiver** is a component for receiving frames sent from other |
|
||||||
Spout-compatible applications. |
|
||||||
|
|
||||||
**Name Filter** is used to select which Spout sender to connect to. The |
|
||||||
receiver only tries to connect to a sender that has the given string in its |
|
||||||
name. For instance, when Name Filter is set to "resolume", it doesn't connect |
|
||||||
to "Processing 1" nor "maxSender", but "resolumeOut". When Name Filter is kept |
|
||||||
empty, it tries to connect to the first found sender without name filtering. |
|
||||||
|
|
||||||
SpoutReceiver supports two ways of storing received frames. When a render |
|
||||||
texture is set to **Target Texture**, it updates the render texture with the |
|
||||||
received frames. When Target Texture is kept null, it automatically allocates |
|
||||||
a temporary render texture for storing frames. These render textures are |
|
||||||
accessible from scripts with the `sharedTexture` property. |
|
||||||
|
|
||||||
Received frames can be rendered with using material overriding. To override a |
|
||||||
material, set a renderer to **Target Renderer**, then select a property to be |
|
||||||
overridden from the drop-down list. |
|
||||||
|
|
||||||
Sender List Window |
|
||||||
------------------ |
|
||||||
|
|
||||||
 |
|
||||||
|
|
||||||
The **Spout Sender List** window is available from the menu "Window" -> "Spout" |
|
||||||
-> "Spout Sender List". It shows the names of the senders that are currently |
|
||||||
available. |
|
||||||
|
|
||||||
License |
|
||||||
------- |
|
||||||
|
|
||||||
[MIT](LICENSE.md) |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 4825f67de1ac6914bb329d527edf03bb |
|
||||||
TextScriptImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: c3a1c3646309d4f469c999381310b88c |
|
||||||
folderAsset: yes |
|
||||||
DefaultImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,24 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
#include "UnityCG.cginc" |
|
||||||
|
|
||||||
sampler2D _MainTex; |
|
||||||
fixed _ClearAlpha; |
|
||||||
|
|
||||||
v2f_img vert(appdata_img v) |
|
||||||
{ |
|
||||||
v2f_img o; |
|
||||||
o.pos = UnityObjectToClipPos(v.vertex); |
|
||||||
o.uv = float2(v.texcoord.x, 1 - v.texcoord.y); |
|
||||||
return o; |
|
||||||
} |
|
||||||
|
|
||||||
fixed4 frag(v2f_img i) : SV_Target |
|
||||||
{ |
|
||||||
fixed4 col = tex2D(_MainTex, i.uv); |
|
||||||
#if defined(SPOUT_RECEIVER) && !defined(UNITY_COLORSPACE_GAMMA) |
|
||||||
col.rgb = GammaToLinearSpace(col.rgb); |
|
||||||
#endif |
|
||||||
col.a = saturate(col.a + _ClearAlpha); |
|
||||||
return col; |
|
||||||
} |
|
||||||
@ -1,9 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 35d67d62b7c939d4e8fdb1c3bed59a83 |
|
||||||
timeCreated: 1491926074 |
|
||||||
licenseType: Pro |
|
||||||
ShaderImporter: |
|
||||||
defaultTextures: [] |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,9 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: eb56c59e60b76874692c486f3bdd860d |
|
||||||
timeCreated: 1491925542 |
|
||||||
licenseType: Pro |
|
||||||
ShaderImporter: |
|
||||||
defaultTextures: [] |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: a9ca729c9d09d03428ab5e26dc0170b2 |
|
||||||
folderAsset: yes |
|
||||||
DefaultImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,9 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 82c81c4751c9a7145a4d491944d132ab |
|
||||||
folderAsset: yes |
|
||||||
timeCreated: 1491924284 |
|
||||||
licenseType: Pro |
|
||||||
DefaultImporter: |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
Binary file not shown.
@ -1,139 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: dc935766d7c9fd44181cb4b58ef3627e |
|
||||||
timeCreated: 1491793810 |
|
||||||
licenseType: Pro |
|
||||||
PluginImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
iconMap: {} |
|
||||||
executionOrder: {} |
|
||||||
isPreloaded: 0 |
|
||||||
isOverridable: 0 |
|
||||||
platformData: |
|
||||||
data: |
|
||||||
first: |
|
||||||
'': Any |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
Exclude Editor: 0 |
|
||||||
Exclude Linux: 0 |
|
||||||
Exclude Linux64: 0 |
|
||||||
Exclude LinuxUniversal: 0 |
|
||||||
Exclude OSXIntel: 0 |
|
||||||
Exclude OSXIntel64: 0 |
|
||||||
Exclude OSXUniversal: 0 |
|
||||||
Exclude PS4: 1 |
|
||||||
Exclude Win: 1 |
|
||||||
Exclude Win64: 0 |
|
||||||
Exclude WindowsStoreApps: 1 |
|
||||||
data: |
|
||||||
first: |
|
||||||
'': Editor |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
CPU: x86_64 |
|
||||||
OS: Windows |
|
||||||
data: |
|
||||||
first: |
|
||||||
Any: |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: {} |
|
||||||
data: |
|
||||||
first: |
|
||||||
Editor: Editor |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
DefaultValueInitialized: true |
|
||||||
data: |
|
||||||
first: |
|
||||||
Facebook: Win |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
CPU: None |
|
||||||
data: |
|
||||||
first: |
|
||||||
Facebook: Win64 |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
PS4: PS4 |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: {} |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: Linux |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: x86 |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: Linux64 |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: x86_64 |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: LinuxUniversal |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: OSXIntel |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: OSXIntel64 |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: OSXUniversal |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: Win |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
CPU: None |
|
||||||
data: |
|
||||||
first: |
|
||||||
Standalone: Win64 |
|
||||||
second: |
|
||||||
enabled: 1 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
data: |
|
||||||
first: |
|
||||||
Windows Store Apps: WindowsStoreApps |
|
||||||
second: |
|
||||||
enabled: 0 |
|
||||||
settings: |
|
||||||
CPU: AnyCPU |
|
||||||
DontProcess: False |
|
||||||
PlaceholderPath: |
|
||||||
SDK: AnySDK |
|
||||||
ScriptingBackend: AnyScriptingBackend |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,74 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
using UnityEngine; |
|
||||||
using System.Runtime.InteropServices; |
|
||||||
|
|
||||||
namespace Klak.Spout |
|
||||||
{ |
|
||||||
public static class PluginEntry |
|
||||||
{ |
|
||||||
#region Plugin polling |
|
||||||
|
|
||||||
static int _lastUpdateFrame = -1; |
|
||||||
|
|
||||||
public static void Poll() |
|
||||||
{ |
|
||||||
if (Time.frameCount != _lastUpdateFrame) |
|
||||||
{ |
|
||||||
GL.IssuePluginEvent(GetRenderEventFunc(), 0); |
|
||||||
_lastUpdateFrame = Time.frameCount; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
|
|
||||||
#region Native plugin interface |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr GetRenderEventFunc(); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr CreateSender(string name, int width, int height); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr CreateReceiver(string name); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern void DestroySharedObject(System.IntPtr ptr); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern bool DetectDisconnection(System.IntPtr ptr); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr GetTexturePointer(System.IntPtr ptr); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern int GetTextureWidth(System.IntPtr ptr); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern int GetTextureHeight(System.IntPtr ptr); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern int CountSharedObjects(); |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr GetSharedObjectName(int index); |
|
||||||
|
|
||||||
public static string GetSharedObjectNameString(int index) |
|
||||||
{ |
|
||||||
var ptr = GetSharedObjectName(index); |
|
||||||
return ptr != System.IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; |
|
||||||
} |
|
||||||
|
|
||||||
[DllImport("KlakSpout")] |
|
||||||
public static extern System.IntPtr SearchSharedObjectName(string keyword); |
|
||||||
|
|
||||||
public static string SearchSharedObjectNameString(string keyword) |
|
||||||
{ |
|
||||||
var ptr = SearchSharedObjectName(keyword); |
|
||||||
return ptr != System.IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : null; |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 5833bfa0ae0a90e478f1f90a455ee667 |
|
||||||
timeCreated: 1491903743 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,161 +0,0 @@ |
|||||||
// KlakSpout - Spout realtime video sharing plugin for Unity |
|
||||||
// https://github.com/keijiro/KlakSpout |
|
||||||
using UnityEngine; |
|
||||||
|
|
||||||
namespace Klak.Spout |
|
||||||
{ |
|
||||||
/// Spout receiver class |
|
||||||
[AddComponentMenu("Klak/Spout/Spout Receiver")] |
|
||||||
public class SpoutReceiver : MonoBehaviour |
|
||||||
{ |
|
||||||
#region Editable properties |
|
||||||
|
|
||||||
[SerializeField] string _nameFilter; |
|
||||||
|
|
||||||
public string nameFilter { |
|
||||||
get { return _nameFilter; } |
|
||||||
set { _nameFilter = value; } |
|
||||||
} |
|
||||||
|
|
||||||
[SerializeField] RenderTexture _targetTexture; |
|
||||||
|
|
||||||
public RenderTexture targetTexture { |
|
||||||
get { return _targetTexture; } |
|
||||||
set { _targetTexture = value; } |
|
||||||
} |
|
||||||
|
|
||||||
[SerializeField] Renderer _targetRenderer; |
|
||||||
|
|
||||||
public Renderer targetRenderer { |
|
||||||
get { return _targetRenderer; } |
|
||||||
set { _targetRenderer = value; } |
|
||||||
} |
|
||||||
|
|
||||||
[SerializeField] string _targetMaterialProperty; |
|
||||||
|
|
||||||
public string targetMaterialProperty { |
|
||||||
get { return _targetMaterialProperty; } |
|
||||||
set { targetMaterialProperty = value; } |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
|
|
||||||
#region Public property |
|
||||||
|
|
||||||
Texture2D _sharedTexture; |
|
||||||
RenderTexture _fixedTexture; |
|
||||||
|
|
||||||
public Texture receivedTexture { |
|
||||||
get { return _targetTexture != null ? _targetTexture : _fixedTexture; } |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
|
|
||||||
#region Private variables |
|
||||||
|
|
||||||
System.IntPtr _receiver; |
|
||||||
Material _fixupMaterial; |
|
||||||
MaterialPropertyBlock _propertyBlock; |
|
||||||
|
|
||||||
// Search the texture list and create a receiver when found one. |
|
||||||
void SearchAndCreateTexture() |
|
||||||
{ |
|
||||||
var name = PluginEntry.SearchSharedObjectNameString(_nameFilter); |
|
||||||
if (name != null) _receiver = PluginEntry.CreateReceiver(name); |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
|
|
||||||
#region MonoBehaviour functions |
|
||||||
|
|
||||||
void Start() |
|
||||||
{ |
|
||||||
_fixupMaterial = new Material(Shader.Find("Hidden/Spout/Fixup")); |
|
||||||
_propertyBlock = new MaterialPropertyBlock(); |
|
||||||
|
|
||||||
// Initial search. |
|
||||||
SearchAndCreateTexture(); |
|
||||||
} |
|
||||||
|
|
||||||
void OnDestroy() |
|
||||||
{ |
|
||||||
if (_receiver != System.IntPtr.Zero) |
|
||||||
{ |
|
||||||
PluginEntry.DestroySharedObject(_receiver); |
|
||||||
_receiver = System.IntPtr.Zero; |
|
||||||
} |
|
||||||
|
|
||||||
if (_sharedTexture != null) |
|
||||||
{ |
|
||||||
Destroy(_sharedTexture); |
|
||||||
_sharedTexture = null; |
|
||||||
} |
|
||||||
|
|
||||||
if (_fixedTexture != null) |
|
||||||
{ |
|
||||||
Destroy(_fixedTexture); |
|
||||||
_fixedTexture = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void Update() |
|
||||||
{ |
|
||||||
PluginEntry.Poll(); |
|
||||||
|
|
||||||
if (_receiver == System.IntPtr.Zero) |
|
||||||
{ |
|
||||||
// The receiver hasn't been set up yet; try to get one. |
|
||||||
SearchAndCreateTexture(); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
// We've received textures via this receiver |
|
||||||
// but now it's disconnected from the sender -> Destroy it. |
|
||||||
if (PluginEntry.GetTexturePointer(_receiver) != System.IntPtr.Zero && |
|
||||||
PluginEntry.DetectDisconnection(_receiver)) |
|
||||||
{ |
|
||||||
OnDestroy(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
if (_receiver != System.IntPtr.Zero) |
|
||||||
{ |
|
||||||
if (_sharedTexture == null) |
|
||||||
{ |
|
||||||
// Try to initialize the shared texture. |
|
||||||
var ptr = PluginEntry.GetTexturePointer(_receiver); |
|
||||||
if (ptr != System.IntPtr.Zero) |
|
||||||
{ |
|
||||||
_sharedTexture = Texture2D.CreateExternalTexture( |
|
||||||
PluginEntry.GetTextureWidth(_receiver), |
|
||||||
PluginEntry.GetTextureHeight(_receiver), |
|
||||||
TextureFormat.ARGB32, false, false, ptr |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
// Update external objects. |
|
||||||
if (_targetTexture != null) |
|
||||||
{ |
|
||||||
Graphics.Blit(_sharedTexture, _targetTexture, _fixupMaterial, 1); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
if (_fixedTexture == null) |
|
||||||
_fixedTexture = new RenderTexture(_sharedTexture.width, _sharedTexture.height, 0); |
|
||||||
Graphics.Blit(_sharedTexture, _fixedTexture, _fixupMaterial, 1); |
|
||||||
} |
|
||||||
|
|
||||||
if (_targetRenderer != null) |
|
||||||
{ |
|
||||||
_propertyBlock.SetTexture(_targetMaterialProperty, receivedTexture); |
|
||||||
_targetRenderer.SetPropertyBlock(_propertyBlock); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#endregion |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 62f7dec0b00674947bc631624c21970a |
|
||||||
timeCreated: 1491895289 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,12 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 45099d624c1e6c14e9514f4e5ea1ed9c |
|
||||||
timeCreated: 1491793847 |
|
||||||
licenseType: Pro |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 7cdfac5ef1f961d4ebfe51361a2020bd |
|
||||||
AssemblyDefinitionImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
{ |
|
||||||
"name": "jp.keijiro.klak.spout", |
|
||||||
"displayName": "KlakSpout", |
|
||||||
"version": "0.0.1", |
|
||||||
"unity": "2018.1", |
|
||||||
"description": "KlakSpout is a Unity plugin that allows sharing rendered frames with other applications with using the Spout protocol.", |
|
||||||
"dependencies": { } |
|
||||||
} |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 46d658811c8e74d42a9b9d2ee0dd286a |
|
||||||
TextScriptImporter: |
|
||||||
externalObjects: {} |
|
||||||
userData: |
|
||||||
assetBundleName: |
|
||||||
assetBundleVariant: |
|
||||||
Loading…
Reference in new issue