modify field order.
This commit is contained in:
@@ -8,14 +8,24 @@ public class MultipleMonitorCreator : MonoBehaviour
|
||||
[SerializeField]
|
||||
GameObject monitorPrefab;
|
||||
|
||||
[Tooltip("Use same scale as real using DPI.")]
|
||||
[SerializeField]
|
||||
bool useRealScale = true;
|
||||
public enum ScaleMode
|
||||
{
|
||||
Real,
|
||||
Fixed,
|
||||
Pixel,
|
||||
}
|
||||
|
||||
[Tooltip("Use this sacle as width if useRealScale is false.")]
|
||||
[Tooltip("Real: DPI-based real scale \nFixed: Same width \nPixel: bigger if screen resolution is high.")]
|
||||
[SerializeField]
|
||||
ScaleMode scaleMode = ScaleMode.Fixed;
|
||||
|
||||
[Tooltip("Use this sacle as width if scaleMode is Fixed.")]
|
||||
[SerializeField]
|
||||
float scale = 0.5f;
|
||||
|
||||
[Tooltip("Please specify the surface direction of the mesh (e.g. Plane => Y.)")]
|
||||
public MeshForwardDirection meshForwardDirection = MeshForwardDirection.Z;
|
||||
|
||||
[Tooltip("Remove unsupported monitors automatically after removeWaitDuration.")]
|
||||
[SerializeField]
|
||||
bool removeIfUnsupported = true;
|
||||
@@ -24,12 +34,13 @@ public class MultipleMonitorCreator : MonoBehaviour
|
||||
[SerializeField]
|
||||
float removeWaitDuration = 5f;
|
||||
|
||||
[Tooltip("Remove all childrens (for debug).")]
|
||||
[SerializeField]
|
||||
bool removeChildrenWhenClear = true;
|
||||
|
||||
bool hasMonitorUnsupportStateChecked = false;
|
||||
float removeWaitTimer_ = 0f;
|
||||
|
||||
[Tooltip("Please specify the surface direction of the mesh (e.g. Plane => Y.)")]
|
||||
public MeshForwardDirection meshForwardDirection = MeshForwardDirection.Z;
|
||||
|
||||
public class MonitorInfo
|
||||
{
|
||||
public GameObject gameObject { get; set; }
|
||||
@@ -113,13 +124,20 @@ public class MultipleMonitorCreator : MonoBehaviour
|
||||
var monitor = texture.monitor;
|
||||
|
||||
// Set width / height
|
||||
float width, height;
|
||||
if (useRealScale) {
|
||||
width = monitor.widthMeter;
|
||||
height = monitor.heightMeter;
|
||||
} else {
|
||||
width = scale * (monitor.isHorizontal ? 1f : monitor.aspect);
|
||||
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f);
|
||||
float width = 1f, height = 1f;
|
||||
switch (scaleMode) {
|
||||
case ScaleMode.Real:
|
||||
width = monitor.widthMeter;
|
||||
height = monitor.heightMeter;
|
||||
break;
|
||||
case ScaleMode.Fixed:
|
||||
width = scale * (monitor.isHorizontal ? 1f : monitor.aspect);
|
||||
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f);
|
||||
break;
|
||||
case ScaleMode.Pixel:
|
||||
width = scale * (monitor.isHorizontal ? 1f : monitor.aspect) * ((float)monitor.width / 1920);
|
||||
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f) * ((float)monitor.width / 1920);
|
||||
break;
|
||||
}
|
||||
if (meshForwardDirection == MeshForwardDirection.Y) {
|
||||
go.transform.localScale = new Vector3(width, go.transform.localScale.y, height);
|
||||
@@ -148,6 +166,11 @@ public class MultipleMonitorCreator : MonoBehaviour
|
||||
foreach (var info in monitors_) {
|
||||
Destroy(info.gameObject);
|
||||
}
|
||||
if (removeChildrenWhenClear) {
|
||||
for (int i = 0; i < transform.childCount; ++i) {
|
||||
Destroy(transform.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
monitors_.Clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user