tweak multiple monitors example.
This commit is contained in:
@@ -3,9 +3,8 @@
|
|||||||
public class MultipleMonitorCreator : MonoBehaviour
|
public class MultipleMonitorCreator : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] GameObject monitorPrefab;
|
[SerializeField] GameObject monitorPrefab;
|
||||||
[SerializeField] float scale = 10f;
|
[SerializeField] float width = 0.3f;
|
||||||
[SerializeField] float margin = 1f;
|
[SerializeField] float margin = 1f;
|
||||||
[SerializeField] float ratio = 0.001f;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -18,17 +17,19 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
go.name = "Monitor " + i;
|
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);
|
var height = width / texture.monitor.aspect;
|
||||||
|
go.transform.localScale = new Vector3(width, go.transform.localScale.y, height);
|
||||||
go.transform.SetParent(transform);
|
go.transform.SetParent(transform);
|
||||||
totalWidth += texture.monitor.width * ratio * scale;
|
var scaleX = go.GetComponent<MeshFilter>().sharedMesh.bounds.extents.x * 2f;
|
||||||
|
totalWidth += width * scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalWidth += margin * (n - 1);
|
totalWidth += margin * (n - 1);
|
||||||
var x = -totalWidth / 2;
|
var x = -totalWidth / 2;
|
||||||
for (int i = 0 ; i < n; ++i) {
|
for (int i = 0 ; i < n; ++i) {
|
||||||
var go = transform.FindChild("Monitor " + i);
|
var go = transform.FindChild("Monitor " + i);
|
||||||
var texture = go.GetComponent<uDesktopDuplication.Texture>();
|
var halfScaleX = go.GetComponent<MeshFilter>().sharedMesh.bounds.extents.x;
|
||||||
var halfWidth = texture.monitor.width * ratio * scale / 2;
|
var halfWidth = width * halfScaleX;
|
||||||
x += halfWidth;
|
x += halfWidth;
|
||||||
go.transform.localPosition = new Vector3(x, 0f, 0f);
|
go.transform.localPosition = new Vector3(x, 0f, 0f);
|
||||||
x += halfWidth + margin;
|
x += halfWidth + margin;
|
||||||
|
|||||||
Reference in New Issue
Block a user