modify field order.

This commit is contained in:
hecomi
2016-11-14 00:04:43 +09:00
parent 75819f0a7d
commit 931ff6b2db
@@ -8,14 +8,24 @@ public class MultipleMonitorCreator : MonoBehaviour
[SerializeField] [SerializeField]
GameObject monitorPrefab; GameObject monitorPrefab;
[Tooltip("Use same scale as real using DPI.")] public enum ScaleMode
[SerializeField] {
bool useRealScale = true; 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] [SerializeField]
float scale = 0.5f; 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.")] [Tooltip("Remove unsupported monitors automatically after removeWaitDuration.")]
[SerializeField] [SerializeField]
bool removeIfUnsupported = true; bool removeIfUnsupported = true;
@@ -24,12 +34,13 @@ public class MultipleMonitorCreator : MonoBehaviour
[SerializeField] [SerializeField]
float removeWaitDuration = 5f; float removeWaitDuration = 5f;
[Tooltip("Remove all childrens (for debug).")]
[SerializeField]
bool removeChildrenWhenClear = true;
bool hasMonitorUnsupportStateChecked = false; bool hasMonitorUnsupportStateChecked = false;
float removeWaitTimer_ = 0f; 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 class MonitorInfo
{ {
public GameObject gameObject { get; set; } public GameObject gameObject { get; set; }
@@ -113,13 +124,20 @@ public class MultipleMonitorCreator : MonoBehaviour
var monitor = texture.monitor; var monitor = texture.monitor;
// Set width / height // Set width / height
float width, height; float width = 1f, height = 1f;
if (useRealScale) { switch (scaleMode) {
width = monitor.widthMeter; case ScaleMode.Real:
height = monitor.heightMeter; width = monitor.widthMeter;
} else { height = monitor.heightMeter;
width = scale * (monitor.isHorizontal ? 1f : monitor.aspect); break;
height = scale * (monitor.isHorizontal ? 1f / monitor.aspect : 1f); 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) { 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);
@@ -148,6 +166,11 @@ public class MultipleMonitorCreator : MonoBehaviour
foreach (var info in monitors_) { foreach (var info in monitors_) {
Destroy(info.gameObject); Destroy(info.gameObject);
} }
if (removeChildrenWhenClear) {
for (int i = 0; i < transform.childCount; ++i) {
Destroy(transform.GetChild(i).gameObject);
}
}
monitors_.Clear(); monitors_.Clear();
} }