tweak multiple monitors example.
This commit is contained in:
@@ -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<uDesktopDuplication.Texture>();
|
||||
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<MeshFilter>().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<uDesktopDuplication.Texture>();
|
||||
var halfWidth = texture.monitor.width * ratio * scale / 2;
|
||||
var halfScaleX = go.GetComponent<MeshFilter>().sharedMesh.bounds.extents.x;
|
||||
var halfWidth = width * halfScaleX;
|
||||
x += halfWidth;
|
||||
go.transform.localPosition = new Vector3(x, 0f, 0f);
|
||||
x += halfWidth + margin;
|
||||
|
||||
Reference in New Issue
Block a user