Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(197评价)
价格: 4431.00元
用代码给UI动态创建动画提示丢失引用
littlebaby发起了问答2017-06-28
3
回复
604
浏览

 

[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"); 

}

所有回复
发表回复
你还没有登录,请先 登录或 注册!