67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
public class ModelShowManager : MonoBehaviour
|
||
|
|
{
|
||
|
|
List<ModelRotate> models = new();
|
||
|
|
Camera mCamera;
|
||
|
|
public void Init()
|
||
|
|
{
|
||
|
|
mCamera = GetComponentInChildren<Camera>(true);
|
||
|
|
foreach (var item in GetComponentsInChildren<ModelRotate>(true))
|
||
|
|
{
|
||
|
|
models.Add(item);
|
||
|
|
item.Init(mCamera);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private void Update()
|
||
|
|
{
|
||
|
|
if (mCamera)
|
||
|
|
{
|
||
|
|
if (Input.GetAxis("Mouse ScrollWheel") < 0)
|
||
|
|
{
|
||
|
|
if (mCamera.fieldOfView < 70)
|
||
|
|
mCamera.fieldOfView += 2;
|
||
|
|
}
|
||
|
|
if (Input.GetAxis("Mouse ScrollWheel") > 0)
|
||
|
|
{
|
||
|
|
if (mCamera.fieldOfView > 40)
|
||
|
|
mCamera.fieldOfView -= 2;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void ShowModel(string value)
|
||
|
|
{
|
||
|
|
if (models.Count == 0) return;
|
||
|
|
for (int i = 0; i < models.Count; i++)
|
||
|
|
{
|
||
|
|
if(value == models[i].name)
|
||
|
|
{
|
||
|
|
models[i].gameObject.SetActive(true);
|
||
|
|
models[i].ResetPosAndRot();
|
||
|
|
if (mCamera) mCamera.fieldOfView = 60;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
models[i].gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void HideModel()
|
||
|
|
{
|
||
|
|
if (models.Count == 0) return;
|
||
|
|
for (int i = 0; i < models.Count; i++)
|
||
|
|
{
|
||
|
|
models[i].ResetPosAndRot();
|
||
|
|
models[i].gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void HideCamera()
|
||
|
|
{
|
||
|
|
if (mCamera) mCamera.gameObject.SetActive(false);
|
||
|
|
}
|
||
|
|
public void ShowCamera()
|
||
|
|
{
|
||
|
|
if (mCamera) mCamera.gameObject.SetActive(true);
|
||
|
|
}
|
||
|
|
}
|