change class names. / add multiple screen example. / performance tuning.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 678e1de5e6de7914baed516a78940503
|
||||
folderAsset: yes
|
||||
timeCreated: 1477643728
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de6f36e446e5e8a48bf61fe198985bb4
|
||||
timeCreated: 1477643732
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a3456d4b2f59e84f969e31deca4016d
|
||||
folderAsset: yes
|
||||
timeCreated: 1477643596
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 445860b05342be845967392bfd70224e
|
||||
timeCreated: 1477643648
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71921882396f0f345aa8a66e2fcb0b6c
|
||||
folderAsset: yes
|
||||
timeCreated: 1477643608
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class MultipleMonitorCreator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject monitorPrefab;
|
||||
[SerializeField] Vector3 margin = new Vector3(20f, 0f, 0f);
|
||||
|
||||
void Start()
|
||||
{
|
||||
var monitors = uDesktopDuplication.Manager.monitors;
|
||||
var n = monitors.Count;
|
||||
for (int i = 0 ; i < n; ++i) {
|
||||
var go = Instantiate(monitorPrefab);
|
||||
go.transform.position = transform.position + margin * (i - n / 2f + 0.5f);
|
||||
var texture = go.GetComponent<uDesktopDuplication.Texture>();
|
||||
texture.monitorId = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb22986017201f74aa864dcbf0cab751
|
||||
timeCreated: 1477643778
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
+5
-4
@@ -3,8 +3,9 @@
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
|
||||
[RequireComponent(typeof(uDD_Texture))]
|
||||
public class uDD_Cursor : MonoBehaviour
|
||||
[AddComponentMenu("uDesktopDuplication/Cursor"),
|
||||
RequireComponent(typeof(Texture))]
|
||||
public class Cursor : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
Transform cursor;
|
||||
@@ -13,11 +14,11 @@ public class uDD_Cursor : MonoBehaviour
|
||||
[SerializeField]
|
||||
Vector2 offset = new Vector2(0.5f, 0.5f);
|
||||
|
||||
private uDD_Texture texture_;
|
||||
private Texture texture_;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
texture_ = GetComponent<uDD_Texture>();
|
||||
texture_ = GetComponent<Texture>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
+3
-1
@@ -5,11 +5,13 @@ using System.Runtime.InteropServices;
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
|
||||
public static class uDD_Lib
|
||||
public static class Lib
|
||||
{
|
||||
[DllImport("uDesktopDuplication")]
|
||||
public static extern int GetMonitorCount();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
public static extern void SetTimeout(int timeout);
|
||||
[DllImport("uDesktopDuplication")]
|
||||
public static extern IntPtr GetRenderEventFunc();
|
||||
[DllImport("uDesktopDuplication")]
|
||||
public static extern void GetName(int id, StringBuilder buf, int len);
|
||||
+21
-10
@@ -5,26 +5,31 @@ using System.Collections.Generic;
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
|
||||
public class uDD_Manager : MonoBehaviour
|
||||
public class Manager : MonoBehaviour
|
||||
{
|
||||
private static uDD_Manager instance_;
|
||||
public static uDD_Manager instance
|
||||
private static Manager instance_;
|
||||
public static Manager instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance_) return instance_;
|
||||
var go = new GameObject("uDesktopDuplicationManager");
|
||||
return go.AddComponent<uDD_Manager>();
|
||||
return go.AddComponent<Manager>();
|
||||
}
|
||||
}
|
||||
|
||||
private List<uDD_Monitor> monitors_ = new List<uDD_Monitor>();
|
||||
static public List<uDD_Monitor> monitors
|
||||
private List<Monitor> monitors_ = new List<Monitor>();
|
||||
static public List<Monitor> monitors
|
||||
{
|
||||
get { return instance.monitors_; }
|
||||
}
|
||||
|
||||
static public uDD_Monitor primary
|
||||
static public int monitorCount
|
||||
{
|
||||
get { return instance.monitors_.Count; }
|
||||
}
|
||||
|
||||
static public Monitor primary
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -32,6 +37,9 @@ public class uDD_Manager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField, Tooltip("Set Desktop Duplication API timeout (milliseconds).")]
|
||||
int timeout = 0;
|
||||
|
||||
private Coroutine renderCoroutine_ = null;
|
||||
|
||||
void Awake()
|
||||
@@ -39,9 +47,11 @@ public class uDD_Manager : MonoBehaviour
|
||||
if (instance_ != null) return;
|
||||
instance_ = this;
|
||||
|
||||
for (int i = 0; i < uDD_Monitor.count; ++i) {
|
||||
monitors.Add(new uDD_Monitor(i));
|
||||
for (int i = 0; i < Lib.GetMonitorCount(); ++i) {
|
||||
monitors.Add(new Monitor(i));
|
||||
}
|
||||
|
||||
Lib.SetTimeout(timeout);
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
@@ -61,7 +71,8 @@ public class uDD_Manager : MonoBehaviour
|
||||
{
|
||||
for (;;) {
|
||||
yield return new WaitForEndOfFrame();
|
||||
foreach (var monitor in monitors) {
|
||||
for (int i = 0; i < monitors.Count; ++i) {
|
||||
var monitor = monitors[i];
|
||||
if (monitor.shouldBeUpdated) {
|
||||
monitor.Render();
|
||||
}
|
||||
+11
-16
@@ -3,18 +3,13 @@
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
|
||||
public class uDD_Monitor
|
||||
public class Monitor
|
||||
{
|
||||
public uDD_Monitor(int id)
|
||||
public Monitor(int id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static int count
|
||||
{
|
||||
get { return uDD_Lib.GetMonitorCount(); }
|
||||
}
|
||||
|
||||
public int id
|
||||
{
|
||||
get;
|
||||
@@ -23,37 +18,37 @@ public class uDD_Monitor
|
||||
|
||||
public string name
|
||||
{
|
||||
get { return uDD_Lib.GetName(id); }
|
||||
get { return Lib.GetName(id); }
|
||||
}
|
||||
|
||||
public bool isPrimary
|
||||
{
|
||||
get { return uDD_Lib.IsPrimary(id); }
|
||||
get { return Lib.IsPrimary(id); }
|
||||
}
|
||||
|
||||
public int width
|
||||
{
|
||||
get { return uDD_Lib.GetWidth(id); }
|
||||
get { return Lib.GetWidth(id); }
|
||||
}
|
||||
|
||||
public int height
|
||||
{
|
||||
get { return uDD_Lib.GetHeight(id); }
|
||||
get { return Lib.GetHeight(id); }
|
||||
}
|
||||
|
||||
public bool isPointerVisible
|
||||
{
|
||||
get { return uDD_Lib.IsPointerVisible(id); }
|
||||
get { return Lib.IsPointerVisible(id); }
|
||||
}
|
||||
|
||||
public int pointerX
|
||||
{
|
||||
get { return uDD_Lib.GetPointerX(id); }
|
||||
get { return Lib.GetPointerX(id); }
|
||||
}
|
||||
|
||||
public int pointerY
|
||||
{
|
||||
get { return uDD_Lib.GetPointerY(id); }
|
||||
get { return Lib.GetPointerY(id); }
|
||||
}
|
||||
|
||||
public bool shouldBeUpdated
|
||||
@@ -69,7 +64,7 @@ public class uDD_Monitor
|
||||
{
|
||||
if (texture_ == null) {
|
||||
texture_ = new Texture2D(width, height, TextureFormat.BGRA32, false);
|
||||
uDD_Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
|
||||
Lib.SetTexturePtr(id, texture_.GetNativeTexturePtr());
|
||||
}
|
||||
return texture_;
|
||||
}
|
||||
@@ -77,7 +72,7 @@ public class uDD_Monitor
|
||||
|
||||
public void Render()
|
||||
{
|
||||
GL.IssuePluginEvent(uDD_Lib.GetRenderEventFunc(), id);
|
||||
GL.IssuePluginEvent(Lib.GetRenderEventFunc(), id);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-5
@@ -3,9 +3,26 @@
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
|
||||
public class uDD_Texture : MonoBehaviour
|
||||
[AddComponentMenu("uDesktopDuplication/Texture")]
|
||||
public class Texture : MonoBehaviour
|
||||
{
|
||||
public uDD_Monitor monitor { get; set; }
|
||||
private Monitor monitor_;
|
||||
public Monitor monitor
|
||||
{
|
||||
get { return monitor_; }
|
||||
set
|
||||
{
|
||||
monitor_ = value;
|
||||
material_ = GetComponent<Renderer>().material;
|
||||
material_.mainTexture = monitor_.texture;
|
||||
}
|
||||
}
|
||||
|
||||
public int monitorId
|
||||
{
|
||||
get { return monitor.id; }
|
||||
set { monitor = Manager.monitors[Mathf.Clamp(value, 0, Manager.monitorCount - 1)]; }
|
||||
}
|
||||
|
||||
public bool invertX = false;
|
||||
public bool invertY = false;
|
||||
@@ -15,10 +32,8 @@ public class uDD_Texture : MonoBehaviour
|
||||
void OnEnable()
|
||||
{
|
||||
if (monitor == null) {
|
||||
monitor = uDD_Manager.primary;
|
||||
monitor = Manager.primary;
|
||||
}
|
||||
material_ = GetComponent<Renderer>().material;
|
||||
material_.mainTexture = monitor.texture;
|
||||
}
|
||||
|
||||
void Update()
|
||||
Reference in New Issue
Block a user