先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class IconRodRoot : MonoBehaviour
|
|
{
|
|
public Camera rodCamera;
|
|
public GameObject[] fx_fishingrods;
|
|
public RenderTexture rt;
|
|
//模型存放节点
|
|
public Transform avatar;
|
|
public GameObject fishrodback;
|
|
private void Awake()
|
|
{
|
|
transform.localScale = Vector3.one / transform.lossyScale.x;
|
|
transform.position = new Vector3(0, 0, 0);
|
|
if (fishrodback != null)
|
|
{
|
|
int level = QualitySettings.GetQualityLevel();
|
|
fishrodback.SetActive(level > 1);
|
|
}
|
|
}
|
|
public void SetRawImage(RawImage rawImageRod)
|
|
{
|
|
RectTransform rectTransform = rawImageRod.GetComponent<RectTransform>();
|
|
rt = new RenderTexture((int)rectTransform.rect.width, (int)rectTransform.rect.height, 24, RenderTextureFormat.ARGB32);
|
|
rodCamera.targetTexture = rt;
|
|
rodCamera.Render();
|
|
float fovRad = 30 * Mathf.Deg2Rad;
|
|
float aspectRatio = Screen.width / (float)Screen.height;
|
|
aspectRatio = Mathf.Clamp(aspectRatio, 0, 0.5625f) * 2340 / 1080;
|
|
rodCamera.fieldOfView = 2 * Mathf.Atan(Mathf.Tan(fovRad) * aspectRatio) * Mathf.Rad2Deg;
|
|
rawImageRod.texture = rt;
|
|
rawImageRod.gameObject.SetActive(true);
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
rodCamera.targetTexture = null;
|
|
if (rt != null)
|
|
{
|
|
rt.Release();
|
|
Destroy(rt);
|
|
rt = null;
|
|
}
|
|
}
|
|
}
|