162 lines
4.8 KiB
C#
162 lines
4.8 KiB
C#
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using QFramework;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using static OperationController;
|
||
using System.Linq;
|
||
using System.Xml.Linq;
|
||
|
||
namespace QFramework.Example
|
||
{
|
||
public class UIBtnAnimData : UIPanelData
|
||
{
|
||
public String title;
|
||
|
||
public String Obj;
|
||
public String AnimObj;
|
||
public String size;
|
||
|
||
public String pos;
|
||
|
||
public String animName;
|
||
|
||
|
||
public string speed;
|
||
|
||
}
|
||
public partial class UIBtnAnim : UIPanel
|
||
{
|
||
protected override void OnInit(IUIData uiData = null)
|
||
{
|
||
mData = uiData as UIBtnAnimData ?? new UIBtnAnimData();
|
||
// please add init code here
|
||
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
||
}
|
||
private void OnStepChanged(StepStatusOnChange change)
|
||
{
|
||
Hide();
|
||
}
|
||
protected override void OnOpen(IUIData uiData = null)
|
||
{
|
||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
|
||
|
||
|
||
mData = uiData as UIBtnAnimData ?? new UIBtnAnimData();
|
||
|
||
|
||
List<String> title = mData.title.Split('|')?.ToList();
|
||
List<String> Obj = mData.Obj.Split('|')?.ToList();
|
||
List<String> targetObj = mData.AnimObj.Split('|')?.ToList();
|
||
List<String> size = mData.size.Split('|')?.ToList();
|
||
List<String> pos = mData.pos.Split('|')?.ToList();
|
||
string speed = mData.speed.ToString();
|
||
for (int i = 0; i < title.Count; i++)
|
||
{
|
||
|
||
int j = i;
|
||
|
||
GameObject ButtonItemObj = GameObject.Instantiate(Button.gameObject, Connet);
|
||
ButtonItemObj.name = title[i];
|
||
|
||
Vector2 positem = Utility.GetVector2FromStrArray(pos[j]);
|
||
Vector2 sizeData = Utility.GetVector2FromStrArray(size[j]);
|
||
|
||
ButtonItemObj.GetComponent<RectTransform>().sizeDelta = sizeData;
|
||
ButtonItemObj.GetComponent<RectTransform>().localPosition = positem;
|
||
GameObject obj = Utility.FindObj(Obj[j]);
|
||
|
||
GameObject AnimObj = Utility.FindObj(targetObj[j]);
|
||
|
||
AnimObj.GetComponent<Animation>();
|
||
|
||
ButtonItemObj.transform.Find("TitleText").GetComponent<Text>().text = title[j];
|
||
ButtonItemObj.transform.GetComponent<Button>().onClick.RemoveAllListeners();
|
||
ButtonItemObj.transform.GetComponent<Button>().onClick.AddListener(() => {
|
||
|
||
UIGuideTipData data = UIKit.GetPanel<UIGuideTip>().Data;
|
||
|
||
|
||
|
||
UIKit.ClosePanel<UIGuideTip>();
|
||
UIKit.ClosePanel<UITextWindow>();
|
||
obj.gameObject.SetActive(false);
|
||
AnimObj.gameObject.SetActive(true);
|
||
PlayReverseAnimation(targetObj[j], mData.animName, () => {
|
||
|
||
|
||
AnimObj.gameObject.SetActive(false);
|
||
obj.gameObject.SetActive(true);
|
||
|
||
|
||
|
||
|
||
UIKit.OpenPanel<UIGuideTip>(uiData: data, canvasLevel: UILevel.Common);
|
||
//UIKit.OpenPanelAsync<UIGuideTip>(uiData: data, canvasLevel: UILevel.Common).ToAction().StartGlobal(() => {
|
||
// UIKit.GetPanel<UIGuideTip>().isUpdate = true;
|
||
//});
|
||
|
||
|
||
// Debug.Log("<22><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD>");
|
||
}, speed);
|
||
|
||
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
public void PlayReverseAnimation(string path, string animName, Action OnFinishAction, string speed)
|
||
{
|
||
var data = new Dictionary<string, string>
|
||
{
|
||
{ "animName", animName },
|
||
{ "speed",speed } // <20><><EFBFBD><EFBFBD>-1ʵ<31>ֵ<EFBFBD><D6B5><EFBFBD>
|
||
};
|
||
|
||
var action = AnimationAction.Allocate(path, data);
|
||
|
||
// <20><><EFBFBD>ûص<C3BB>
|
||
action.OnFinished += () =>
|
||
{
|
||
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɻص<C9BB><D8B5><EFBFBD><EFBFBD><EFBFBD>");
|
||
|
||
action.Finish();
|
||
OnFinishAction?.Invoke(); action.Deinit();
|
||
|
||
};
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
action.OnStart();
|
||
ActionKit.Sequence().Append(action).StartGlobal();
|
||
|
||
|
||
// GameObject obj = Utility.FindObj(path);
|
||
// obj.SetActive(true);
|
||
|
||
//Animation anim = obj.GetComponent<Animation>();
|
||
// anim.clip = anim[animName].clip;
|
||
// anim[animName].speed = speed.ToFloat();
|
||
// anim.Play();
|
||
// if (OnFinishAction!=null)
|
||
// {
|
||
// OnFinishAction.Invoke();
|
||
// }
|
||
|
||
|
||
|
||
}
|
||
protected override void OnShow()
|
||
{
|
||
}
|
||
|
||
protected override void OnHide()
|
||
{
|
||
}
|
||
|
||
protected override void OnClose()
|
||
{
|
||
}
|
||
}
|
||
}
|