|
|
@@ -26,7 +26,7 @@ public class CameraSurround : MonoBehaviour
|
|
|
|
|
|
public void SetCameraPosition(bool reset = false)
|
|
|
{
|
|
|
- Bounds tmpBounds = GetBounds(DeviceController.instance.transform);
|
|
|
+ Bounds tmpBounds = GetBounds(DeviceController.instance.transform);
|
|
|
|
|
|
//物体最大长度
|
|
|
float a = tmpBounds.size.magnitude;
|
|
|
@@ -35,15 +35,24 @@ public class CameraSurround : MonoBehaviour
|
|
|
{
|
|
|
if (reset)
|
|
|
{
|
|
|
- transform.position = tmpBounds.center +
|
|
|
- ((tmpBounds.center + new Vector3(1, 0.2f, 0)) - tmpBounds.center).normalized
|
|
|
- * a / 2 * 1.9f;
|
|
|
+ if (tmpBounds.size.x > tmpBounds.size.z)
|
|
|
+ {
|
|
|
+ transform.position = tmpBounds.center +
|
|
|
+((tmpBounds.center + new Vector3(0.2f, 0, 1)) - tmpBounds.center).normalized
|
|
|
+* a / 2 * 1.9f;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ transform.position = tmpBounds.center +
|
|
|
+ ((tmpBounds.center + new Vector3(1, 0.2f, 0)) - tmpBounds.center).normalized
|
|
|
+ * a / 2 * 1.9f;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
transform.position = tmpBounds.center +
|
|
|
- (transform.position - tmpBounds.center).normalized
|
|
|
- * a / 2 * 1.9f;
|
|
|
+ (transform.position - tmpBounds.center).normalized
|
|
|
+ * a / 2 * 1.9f;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -97,7 +106,7 @@ public class CameraSurround : MonoBehaviour
|
|
|
|
|
|
if (Input.GetKey(KeyCode.Mouse1))
|
|
|
{
|
|
|
- if (m_RotationPoint.x.ToString() != "NaN" && m_RotationPoint.y.ToString() != "NaN" && m_RotationPoint.z.ToString() != "NaN")
|
|
|
+ if (m_RotationPoint.x.ToString() != "NaN" && m_RotationPoint.y.ToString() != "NaN" && m_RotationPoint.z.ToString() != "NaN")
|
|
|
{
|
|
|
transform.RotateAround(m_RotationPoint, Vector3.up, mouse_X * 5);
|
|
|
|
|
|
@@ -126,7 +135,7 @@ public class CameraSurround : MonoBehaviour
|
|
|
tmpMeshRenders.AddRange(item.GetMeshRender());
|
|
|
}
|
|
|
|
|
|
- Bounds bounds = new Bounds(GetModelGroupBoundesConent(tmpMeshRenders.ToArray()),Vector3.zero);
|
|
|
+ Bounds bounds = new Bounds(GetModelGroupBoundesConent(tmpMeshRenders.ToArray()), Vector3.zero);
|
|
|
|
|
|
foreach (Renderer renderer in tmpMeshRenders)
|
|
|
{
|