[SerializeField]
private float up = -35.6f;
[SerializeField]
private float down = -36;
public static TitleHide instance=null;
private bool isDown = false;
public bool IsDown { get{ return isDown;} }
private RectTransform _rect;
private Animation _ani;
void Awake ()
{
instance = this;
_rect = gameObject.GetComponent();
_ani = gameObject.GetComponent();
if (_ani == null)
{
_ani = gameObject.AddComponent();
} _ani.playAutomatically = false;
_ani.wrapMode = WrapMode.Once;
AnimationClip clip = new AnimationClip();
clip.name = "GoUp";
clip.wrapMode = WrapMode.Once;
clip.legacy = true;
AnimationCurve curve = AnimationCurve.Linear(0, down, 1, up);
clip.SetCurve("", typeof(RectTransform), "anchoredPosition.y", curve);
_ani.AddClip(clip, "GoUp");
clip = new AnimationClip();
clip.name = "GoDown";
clip.wrapMode = WrapMode.Once;
clip.legacy = true;
curve = AnimationCurve.Linear(0, up, 1, down);
clip.SetCurve("", typeof(RectTransform), "anchoredPosition.y", curve);
_ani.AddClip(clip, "GoDown");
}
你的代码是在运行模式下运行的,运行模式下修改的东西不会保存,
在编辑器模式下运行创建的代码应该就可以保存下来了