add logs.
This commit is contained in:
@@ -9,6 +9,7 @@ public enum Message
|
||||
{
|
||||
None = -1,
|
||||
Reinitialized = 0,
|
||||
TextureSizeChanged = 1,
|
||||
}
|
||||
|
||||
public enum CursorShapeType
|
||||
@@ -36,7 +37,8 @@ public enum MonitorState
|
||||
Unsupported = 3,
|
||||
CurrentlyNotAvailable = 4,
|
||||
SessionDisconnected = 5,
|
||||
AccessLost = 6,
|
||||
AccessLost = 6,
|
||||
TextureSizeInconsistent = 7,
|
||||
Unknown = 999,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
@@ -113,7 +112,7 @@ public class Manager : MonoBehaviour
|
||||
}
|
||||
|
||||
[ContextMenu("Reinitialize")]
|
||||
void Reinitialize()
|
||||
public void Reinitialize()
|
||||
{
|
||||
Debug.Log("[uDD] Reinitialize");
|
||||
Lib.Reinitialize();
|
||||
@@ -152,10 +151,14 @@ public class Manager : MonoBehaviour
|
||||
{
|
||||
var message = Lib.PopMessage();
|
||||
while (message != Message.None) {
|
||||
Debug.Log("[uDD] " + message);
|
||||
switch (message) {
|
||||
case Message.Reinitialized:
|
||||
ReinitializeMonitors();
|
||||
break;
|
||||
case Message.TextureSizeChanged:
|
||||
RecreateTextures();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -195,15 +198,11 @@ public class Manager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void WaitThenDo(System.Action func, float sec)
|
||||
void RecreateTextures()
|
||||
{
|
||||
StartCoroutine(_WaitThenDo(func, sec));
|
||||
}
|
||||
|
||||
IEnumerator _WaitThenDo(System.Action func, float sec)
|
||||
{
|
||||
yield return new WaitForSeconds(sec);
|
||||
func();
|
||||
for (int i = 0; i < monitorCount; ++i) {
|
||||
monitors[i].CreateTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace uDesktopDuplication
|
||||
{
|
||||
@@ -204,13 +203,17 @@ public class Monitor
|
||||
set;
|
||||
}
|
||||
|
||||
private Texture2D errorTexture_;
|
||||
private static readonly string errorTexturePath = "uDesktopDuplication/Textures/NotAvailable";
|
||||
|
||||
private Texture2D texture_;
|
||||
public Texture2D texture
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!available) {
|
||||
return Resources.Load<Texture2D>("uDesktopDuplication/Textures/NotAvailable");
|
||||
return errorTexture_ ??
|
||||
(errorTexture_ = Resources.Load<Texture2D>(errorTexturePath));
|
||||
}
|
||||
if (texture_ == null) {
|
||||
CreateTexture();
|
||||
@@ -242,7 +245,10 @@ public class Monitor
|
||||
|
||||
if (texture_) {
|
||||
if (texture_.width != w || texture_.height != h) {
|
||||
if (texture_) Object.DestroyImmediate(texture_);
|
||||
if (texture_) {
|
||||
Object.Destroy(texture_);
|
||||
texture_ = null;
|
||||
}
|
||||
shouldCreate = true;
|
||||
} else {
|
||||
shouldCreate = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace uDesktopDuplication
|
||||
@@ -25,6 +26,17 @@ public static class Utility
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public static void WaitThenDo(System.Action func, float sec)
|
||||
{
|
||||
Manager.instance.StartCoroutine(_WaitThenDo(func, sec));
|
||||
}
|
||||
|
||||
public static IEnumerator _WaitThenDo(System.Action func, float sec)
|
||||
{
|
||||
yield return new WaitForSeconds(sec);
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user