先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class tips_base : MonoBehaviour
|
|
{
|
|
public RectTransform content;
|
|
public RectTransform bg;
|
|
public RectTransform arrow;
|
|
protected float width;
|
|
#if UNITY_EDITOR
|
|
private void Reset()
|
|
{
|
|
Awake();
|
|
}
|
|
#endif
|
|
protected virtual void Awake()
|
|
{
|
|
content = GetComponent<RectTransform>();
|
|
bg = content.Find("bg").GetComponent<RectTransform>();
|
|
arrow = bg.Find("arrow").GetComponent<RectTransform>();
|
|
|
|
}
|
|
public void SetContent(Vector3 pos)
|
|
{
|
|
bg.transform.position = pos;
|
|
|
|
float limit = content.rect.width / 2 - width;
|
|
//边界检测
|
|
if (bg.transform.localPosition.x > limit)
|
|
{
|
|
bg.transform.localPosition = new Vector3(limit, bg.transform.localPosition.y);
|
|
}
|
|
else if (bg.transform.localPosition.x < -limit)
|
|
{
|
|
bg.transform.localPosition = new Vector3(-limit, bg.transform.localPosition.y);
|
|
}
|
|
arrow.transform.position = new Vector3(pos.x, arrow.transform.position.y);
|
|
}
|
|
}
|