save scale even after reinitialization.
This commit is contained in:
@@ -109,7 +109,6 @@ public class GazePointAnalyzer : MonoBehaviour
|
|||||||
coord += center * weight;
|
coord += center * weight;
|
||||||
totalWeights += weight;
|
totalWeights += weight;
|
||||||
}
|
}
|
||||||
var n = monitor.dirtyRectCount;
|
|
||||||
coord /= totalWeights;
|
coord /= totalWeights;
|
||||||
filter = dirtyRectFilter;
|
filter = dirtyRectFilter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,10 +35,17 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
bool hasMonitorUnsupportStateChecked_ = false;
|
bool hasMonitorUnsupportStateChecked_ = false;
|
||||||
float removeWaitTimer_ = 0f;
|
float removeWaitTimer_ = 0f;
|
||||||
|
|
||||||
|
public class SavedMonitorInfo
|
||||||
|
{
|
||||||
|
public float widthScale = 1f;
|
||||||
|
public float heightScale = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
public class MonitorInfo
|
public class MonitorInfo
|
||||||
{
|
{
|
||||||
public GameObject gameObject { get; set; }
|
public GameObject gameObject { get; set; }
|
||||||
public Quaternion originalRotation { get; set; }
|
public Quaternion originalRotation { get; set; }
|
||||||
|
public Vector3 originalLocalScale { get; set; }
|
||||||
public uDesktopDuplication.Texture uddTexture { get; set; }
|
public uDesktopDuplication.Texture uddTexture { get; set; }
|
||||||
public Mesh mesh { get; set; }
|
public Mesh mesh { get; set; }
|
||||||
}
|
}
|
||||||
@@ -46,6 +53,9 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
private List<MonitorInfo> monitors_ = new List<MonitorInfo>();
|
private List<MonitorInfo> monitors_ = new List<MonitorInfo>();
|
||||||
public List<MonitorInfo> monitors { get { return monitors_; } }
|
public List<MonitorInfo> monitors { get { return monitors_; } }
|
||||||
|
|
||||||
|
private List<SavedMonitorInfo> savedInfoList_ = new List<SavedMonitorInfo>();
|
||||||
|
public List<SavedMonitorInfo> savedInfoList { get { return savedInfoList_; } }
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
uDesktopDuplication.Manager.CreateInstance();
|
uDesktopDuplication.Manager.CreateInstance();
|
||||||
@@ -105,6 +115,12 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
var go = Instantiate(monitorPrefab);
|
var go = Instantiate(monitorPrefab);
|
||||||
go.name = "Monitor " + i;
|
go.name = "Monitor " + i;
|
||||||
|
|
||||||
|
// Saved infomation
|
||||||
|
if (savedInfoList.Count == i) {
|
||||||
|
savedInfoList.Add(new SavedMonitorInfo());
|
||||||
|
}
|
||||||
|
var savedInfo = savedInfoList[i];
|
||||||
|
|
||||||
// Expand AABB
|
// Expand AABB
|
||||||
var mesh = go.GetComponent<MeshFilter>().mesh; // clone
|
var mesh = go.GetComponent<MeshFilter>().mesh; // clone
|
||||||
var aabbScale = mesh.bounds.size;
|
var aabbScale = mesh.bounds.size;
|
||||||
@@ -133,6 +149,10 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f) * ((float)monitor.width / 1920);
|
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f) * ((float)monitor.width / 1920);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width *= savedInfo.widthScale;
|
||||||
|
height *= savedInfo.heightScale;
|
||||||
|
|
||||||
if (meshForwardDirection == MeshForwardDirection.Y) {
|
if (meshForwardDirection == MeshForwardDirection.Y) {
|
||||||
go.transform.localScale = new Vector3(width, go.transform.localScale.y, height);
|
go.transform.localScale = new Vector3(width, go.transform.localScale.y, height);
|
||||||
} else {
|
} else {
|
||||||
@@ -143,12 +163,15 @@ public class MultipleMonitorCreator : MonoBehaviour
|
|||||||
go.transform.SetParent(transform);
|
go.transform.SetParent(transform);
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
var info = new MonitorInfo();
|
{
|
||||||
info.gameObject = go;
|
var info = new MonitorInfo();
|
||||||
info.originalRotation = go.transform.rotation;
|
info.gameObject = go;
|
||||||
info.uddTexture = texture;
|
info.originalRotation = go.transform.rotation;
|
||||||
info.mesh = mesh;
|
info.originalLocalScale = go.transform.localScale;
|
||||||
monitors_.Add(info);
|
info.uddTexture = texture;
|
||||||
|
info.mesh = mesh;
|
||||||
|
monitors.Add(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort monitors in coordinate order
|
// Sort monitors in coordinate order
|
||||||
|
|||||||
@@ -18,13 +18,20 @@ public class MultipleMonitorRoundLayouter : MultipleMonitorLayouter
|
|||||||
var monitors = creator_.monitors;
|
var monitors = creator_.monitors;
|
||||||
var n = monitors.Count;
|
var n = monitors.Count;
|
||||||
|
|
||||||
// keep the local scale z of monitors as 1 to bend them correctly.
|
// Keep the local scale z of monitors as 1 to bend them correctly.
|
||||||
foreach (var info in monitors) {
|
// And save width / height to use same values after reinitialization.
|
||||||
|
for (int i = 0; i < monitors.Count; ++i) {
|
||||||
|
var info = monitors[i];
|
||||||
|
var savedInfo = creator_.savedInfoList[i];
|
||||||
var scale = info.gameObject.transform.localScale;
|
var scale = info.gameObject.transform.localScale;
|
||||||
if (creator_.meshForwardDirection == MeshForwardDirection.Y) {
|
if (creator_.meshForwardDirection == MeshForwardDirection.Y) {
|
||||||
scale.y = 1f;
|
scale.y = 1f;
|
||||||
|
savedInfo.widthScale = scale.x / info.originalLocalScale.x;
|
||||||
|
savedInfo.heightScale = scale.z / info.originalLocalScale.z;
|
||||||
} else {
|
} else {
|
||||||
scale.z = 1f;
|
scale.z = 1f;
|
||||||
|
savedInfo.widthScale = scale.x / info.originalLocalScale.x;
|
||||||
|
savedInfo.heightScale = scale.y / info.originalLocalScale.y;
|
||||||
}
|
}
|
||||||
info.gameObject.transform.localScale = scale;
|
info.gameObject.transform.localScale = scale;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user