From 908988dcaa240fdfacef5ff2a09ec533d75e5375 Mon Sep 17 00:00:00 2001 From: hecomi Date: Fri, 4 Nov 2016 21:37:08 +0900 Subject: [PATCH] tweak multiple monitors example. --- .../Examples/Scripts/MultipleMonitorCreator.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Assets/uDesktopDuplication/Examples/Scripts/MultipleMonitorCreator.cs b/Assets/uDesktopDuplication/Examples/Scripts/MultipleMonitorCreator.cs index 04c76e7..d960bb0 100644 --- a/Assets/uDesktopDuplication/Examples/Scripts/MultipleMonitorCreator.cs +++ b/Assets/uDesktopDuplication/Examples/Scripts/MultipleMonitorCreator.cs @@ -3,9 +3,8 @@ public class MultipleMonitorCreator : MonoBehaviour { [SerializeField] GameObject monitorPrefab; - [SerializeField] float scale = 10f; + [SerializeField] float width = 0.3f; [SerializeField] float margin = 1f; - [SerializeField] float ratio = 0.001f; void Start() { @@ -18,17 +17,19 @@ public class MultipleMonitorCreator : MonoBehaviour go.name = "Monitor " + i; var texture = go.GetComponent(); texture.monitorId = i; - go.transform.localScale = new Vector3(texture.monitor.width * ratio, 1f, texture.monitor.height * ratio); + var height = width / texture.monitor.aspect; + go.transform.localScale = new Vector3(width, go.transform.localScale.y, height); go.transform.SetParent(transform); - totalWidth += texture.monitor.width * ratio * scale; + var scaleX = go.GetComponent().sharedMesh.bounds.extents.x * 2f; + totalWidth += width * scaleX; } totalWidth += margin * (n - 1); var x = -totalWidth / 2; for (int i = 0 ; i < n; ++i) { var go = transform.FindChild("Monitor " + i); - var texture = go.GetComponent(); - var halfWidth = texture.monitor.width * ratio * scale / 2; + var halfScaleX = go.GetComponent().sharedMesh.bounds.extents.x; + var halfWidth = width * halfScaleX; x += halfWidth; go.transform.localPosition = new Vector3(x, 0f, 0f); x += halfWidth + margin;