consider aspect ratio in Multiple Monitor scene.
This commit is contained in:
Binary file not shown.
@@ -3,17 +3,35 @@
|
|||||||
public class MultipleMonitorCreator : MonoBehaviour
|
public class MultipleMonitorCreator : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] GameObject monitorPrefab;
|
[SerializeField] GameObject monitorPrefab;
|
||||||
[SerializeField] Vector3 margin = new Vector3(20f, 0f, 0f);
|
[SerializeField] float scale = 10f;
|
||||||
|
[SerializeField] float margin = 1f;
|
||||||
|
[SerializeField] float ratio = 0.001f;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
var monitors = uDesktopDuplication.Manager.monitors;
|
var monitors = uDesktopDuplication.Manager.monitors;
|
||||||
var n = monitors.Count;
|
var n = monitors.Count;
|
||||||
|
|
||||||
|
var totalWidth = 0f;
|
||||||
for (int i = 0 ; i < n; ++i) {
|
for (int i = 0 ; i < n; ++i) {
|
||||||
var go = Instantiate(monitorPrefab);
|
var go = Instantiate(monitorPrefab);
|
||||||
go.transform.position = transform.position + margin * (i - n / 2f + 0.5f);
|
go.name = "Monitor " + i;
|
||||||
var texture = go.GetComponent<uDesktopDuplication.Texture>();
|
var texture = go.GetComponent<uDesktopDuplication.Texture>();
|
||||||
texture.monitorId = i;
|
texture.monitorId = i;
|
||||||
|
go.transform.localScale = new Vector3(texture.monitor.width * ratio, 1f, texture.monitor.height * ratio);
|
||||||
|
go.transform.SetParent(transform);
|
||||||
|
totalWidth += texture.monitor.width * ratio * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
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<uDesktopDuplication.Texture>();
|
||||||
|
var halfWidth = texture.monitor.width * ratio * scale / 2;
|
||||||
|
x += halfWidth;
|
||||||
|
go.transform.position = new Vector3(x, 0f, 0f);
|
||||||
|
x += halfWidth + margin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user