support option to choise real / fixed scale.
This commit is contained in:
@@ -4,9 +4,26 @@ using MeshForwardDirection = uDesktopDuplication.Texture.MeshForwardDirection;
|
|||||||
|
|
||||||
public class MultipleMonitorCreator : MonoBehaviour
|
public class MultipleMonitorCreator : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] GameObject monitorPrefab;
|
[Tooltip("Create monitors using this prefab.")]
|
||||||
[SerializeField] bool removeIfUnsupported = true;
|
[SerializeField]
|
||||||
[SerializeField] float removeWaitDuration = 5f;
|
GameObject monitorPrefab;
|
||||||
|
|
||||||
|
[Tooltip("Use same scale as real using DPI.")]
|
||||||
|
[SerializeField]
|
||||||
|
bool useRealScale = true;
|
||||||
|
|
||||||
|
[Tooltip("Use this sacle as width if useRealScale is false.")]
|
||||||
|
[SerializeField]
|
||||||
|
float scale = 0.5f;
|
||||||
|
|
||||||
|
[Tooltip("Remove unsupported monitors automatically after removeWaitDuration.")]
|
||||||
|
[SerializeField]
|
||||||
|
bool removeIfUnsupported = true;
|
||||||
|
|
||||||
|
[Tooltip("Remove unsupported monitors automatically after removeWaitDuration.")]
|
||||||
|
[SerializeField]
|
||||||
|
float removeWaitDuration = 5f;
|
||||||
|
|
||||||
bool hasMonitorUnsupportStateChecked = false;
|
bool hasMonitorUnsupportStateChecked = false;
|
||||||
float removeWaitTimer_ = 0f;
|
float removeWaitTimer_ = 0f;
|
||||||
|
|
||||||
@@ -96,10 +113,18 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
var monitor = texture.monitor;
|
var monitor = texture.monitor;
|
||||||
|
|
||||||
// Set width / height
|
// Set width / height
|
||||||
if (meshForwardDirection == MeshForwardDirection.Y) {
|
float width, height;
|
||||||
go.transform.localScale = new Vector3(monitor.widthMeter, go.transform.localScale.y, monitor.heightMeter);
|
if (useRealScale) {
|
||||||
|
width = monitor.widthMeter;
|
||||||
|
height = monitor.heightMeter;
|
||||||
} else {
|
} else {
|
||||||
go.transform.localScale = new Vector3(monitor.widthMeter, monitor.heightMeter, go.transform.localScale.z);
|
width = scale * (monitor.isHorizontal ? 1f : monitor.aspect);
|
||||||
|
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f);
|
||||||
|
}
|
||||||
|
if (meshForwardDirection == MeshForwardDirection.Y) {
|
||||||
|
go.transform.localScale = new Vector3(width, go.transform.localScale.y, height);
|
||||||
|
} else {
|
||||||
|
go.transform.localScale = new Vector3(width, height, go.transform.localScale.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set parent as this object
|
// Set parent as this object
|
||||||
@@ -126,7 +151,8 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
monitors_.Clear();
|
monitors_.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Recreate()
|
[ContextMenu("Recreate")]
|
||||||
|
public void Recreate()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
Create();
|
Create();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class MultipleMonitorLayouter : MonoBehaviour
|
|||||||
|
|
||||||
var totalWidth = 0f;
|
var totalWidth = 0f;
|
||||||
foreach (var info in monitors) {
|
foreach (var info in monitors) {
|
||||||
var width = info.uddTexture.monitor.widthMeter * (info.mesh.bounds.extents.x * 2f);
|
var width = info.gameObject.transform.localEulerAngles.x * (info.mesh.bounds.extents.x * 2f);
|
||||||
totalWidth += width;
|
totalWidth += width;
|
||||||
}
|
}
|
||||||
totalWidth += margin * (n - 1);
|
totalWidth += margin * (n - 1);
|
||||||
@@ -38,11 +38,11 @@ public class MultipleMonitorLayouter : MonoBehaviour
|
|||||||
var x = -totalWidth / 2;
|
var x = -totalWidth / 2;
|
||||||
|
|
||||||
foreach (var info in monitors) {
|
foreach (var info in monitors) {
|
||||||
var monitor = info.uddTexture.monitor;
|
var width = info.gameObject.transform.localEulerAngles.x;
|
||||||
x += (monitor.widthMeter * info.mesh.bounds.extents.x);
|
x += (width * info.mesh.bounds.extents.x);
|
||||||
info.gameObject.transform.localPosition = new Vector3(x, 0f, 0f);
|
info.gameObject.transform.localPosition = new Vector3(x, 0f, 0f);
|
||||||
info.gameObject.transform.localRotation = info.originalRotation;
|
info.gameObject.transform.localRotation = info.originalRotation;
|
||||||
x += (monitor.widthMeter * info.mesh.bounds.extents.x) + margin;
|
x += (width * info.mesh.bounds.extents.x) + margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var info in monitors) {
|
foreach (var info in monitors) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
|||||||
|
|
||||||
var totalWidth = 0f;
|
var totalWidth = 0f;
|
||||||
foreach (var info in monitors) {
|
foreach (var info in monitors) {
|
||||||
var width = info.uddTexture.monitor.widthMeter * (info.mesh.bounds.extents.x * 2f);
|
var width = info.gameObject.transform.localScale.x * (info.mesh.bounds.extents.x * 2f);
|
||||||
totalWidth += width;
|
totalWidth += width;
|
||||||
}
|
}
|
||||||
totalWidth += margin * (n - 1);
|
totalWidth += margin * (n - 1);
|
||||||
@@ -30,7 +30,7 @@ public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
|||||||
float angle = -totalAngle / 2 + offsetAngle * Mathf.Deg2Rad;
|
float angle = -totalAngle / 2 + offsetAngle * Mathf.Deg2Rad;
|
||||||
foreach (var info in monitors) {
|
foreach (var info in monitors) {
|
||||||
var uddTex = info.uddTexture;
|
var uddTex = info.uddTexture;
|
||||||
var width = uddTex.monitor.widthMeter * (info.mesh.bounds.extents.x * 2f);
|
var width = info.gameObject.transform.localScale.x * (info.mesh.bounds.extents.x * 2f);
|
||||||
|
|
||||||
angle += (width / radius) * 0.5f;
|
angle += (width / radius) * 0.5f;
|
||||||
uddTex.transform.localPosition = radius * new Vector3(Mathf.Sin(angle), 0f, Mathf.Cos(angle) - 1f);
|
uddTex.transform.localPosition = radius * new Vector3(Mathf.Sin(angle), 0f, Mathf.Cos(angle) - 1f);
|
||||||
|
|||||||
Reference in New Issue
Block a user