171 lines
4.1 KiB
C#
171 lines
4.1 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
public class XMZJController : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public static XMZJController Instance;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
Instance = this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>ı<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
string space = "\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0";
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>չʾ<D5B9><CABE><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public SpotInfo sceneInfo;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// չʾ<D5B9><CABE><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public GameObject pnlInfo;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Text txtSceneTitle;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Text txtTitle;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ı<EFBFBD><C4B1>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Text txtDetailInfo;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ı<EFBFBD><C4B1>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Text txtDetailInfo2;
|
|||
|
|
/// <summary>
|
|||
|
|
/// չƷ<D5B9>鿴λ<E9BFB4><CEBB>
|
|||
|
|
/// </summary>
|
|||
|
|
public Transform tranModelPos;
|
|||
|
|
/// <summary>
|
|||
|
|
/// չƷͼƬ<CDBC>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public Image imgDetail;
|
|||
|
|
/// <summary>
|
|||
|
|
/// չƷͼƬ<CDBC>ؼ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public RawImage rawDetail;
|
|||
|
|
/// <summary>
|
|||
|
|
/// չƷԭʼλ<CABC><CEBB>
|
|||
|
|
/// </summary>
|
|||
|
|
Vector3 originalPos;
|
|||
|
|
/// <summary>
|
|||
|
|
/// չƷԭʼ<D4AD><CABC>ת
|
|||
|
|
/// </summary>
|
|||
|
|
Quaternion originalRotate;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ǰչƷTransform
|
|||
|
|
/// </summary>
|
|||
|
|
Transform tranCurrentModel;
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ǰչƷ<D5B9><C6B7><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
SpotInfo currentInfo;
|
|||
|
|
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
ShowInfo(sceneInfo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ʾչƷ
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="info">չƷ<D5B9><C6B7>Ϣ</param>
|
|||
|
|
public void ShowInfo(SpotInfo info)
|
|||
|
|
{
|
|||
|
|
currentInfo = info;
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(info.sceneTitle))
|
|||
|
|
{
|
|||
|
|
txtSceneTitle.text = info.sceneTitle;
|
|||
|
|
txtDetailInfo2.gameObject.SetActive(false);
|
|||
|
|
txtDetailInfo.gameObject.SetActive(true);
|
|||
|
|
txtDetailInfo.text = space + info.detailInfo;
|
|||
|
|
txtDetailInfo.fontSize = info.fontSize;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtDetailInfo2.gameObject.SetActive(true);
|
|||
|
|
txtDetailInfo.gameObject.SetActive(false);
|
|||
|
|
txtDetailInfo2.text = space + info.detailInfo;
|
|||
|
|
txtDetailInfo2.fontSize = info.fontSize;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
txtTitle.text = info.title;
|
|||
|
|
pnlInfo.SetActive(true);
|
|||
|
|
rotateDir = info.rotateDir;
|
|||
|
|
|
|||
|
|
// <20><>ʾͼƬ
|
|||
|
|
if (!info.showModel && info.spDetail != null)
|
|||
|
|
{
|
|||
|
|
imgDetail.gameObject.SetActive(true);
|
|||
|
|
imgDetail.sprite = info.spDetail;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
imgDetail.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|||
|
|
if (info.anim != null)
|
|||
|
|
{
|
|||
|
|
info.anim.Play(0, 0, 0f);
|
|||
|
|
info.anim.Update(0f);
|
|||
|
|
info.anim.enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾģ<CABE><C4A3>
|
|||
|
|
if (info.showModel)
|
|||
|
|
{
|
|||
|
|
rawDetail.gameObject.SetActive(true);
|
|||
|
|
|
|||
|
|
Transform tran = info.tranModel == null ? info.transform : info.tranModel;
|
|||
|
|
originalPos = tran.position;
|
|||
|
|
originalRotate = tran.rotation;
|
|||
|
|
tran.position = tranModelPos.position;
|
|||
|
|
tran.rotation = Quaternion.Euler(info.rotateAngle);
|
|||
|
|
tranCurrentModel = tran;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
rawDetail.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnBtnCloseClick()
|
|||
|
|
{
|
|||
|
|
pnlInfo.SetActive(false);
|
|||
|
|
if (tranCurrentModel != null)
|
|||
|
|
{
|
|||
|
|
tranCurrentModel.position = originalPos;
|
|||
|
|
tranCurrentModel.rotation = originalRotate;
|
|||
|
|
tranCurrentModel = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (currentInfo.anim != null)
|
|||
|
|
{
|
|||
|
|
currentInfo.anim.enabled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public float rotateSpeed = 100f;
|
|||
|
|
Vector3 rotateDir;
|
|||
|
|
// public Camera cam;
|
|||
|
|
|
|||
|
|
private void Update()
|
|||
|
|
{
|
|||
|
|
if (currentInfo.showModel && tranCurrentModel != null)
|
|||
|
|
{
|
|||
|
|
tranCurrentModel.Rotate(rotateDir * Time.deltaTime * rotateSpeed, Space.World);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|