void LeftClick() { //左键单击 // CurMemInfo = null; TimeLineData data = TimeLineDataManager.Instance.GetCurSelectTimeLine(); if (data == null) { return; } data.InitDefaultTime(); Type t = data.GetType(); data.SetFieldValue(data); var memInfo = t.GetMethods(); TimeLineDataManager.Instance.memDic.Clear(); int selectKey = -1; TimeLineDataManager.Instance.curOperationAction = null; foreach (MethodInfo info in memInfo) { foreach (var item in data.GetActionDic()) { ActionItemData ad = item.Value; if (ad.IsSelect()) { foreach (var name in ad.methodNameList) { if (name == info.Name) { TimeLineDataManager.Instance.AddGUIMemInfo(info); } } //移除要操作的action 用临时变量保存 TimeLineDataManager.Instance.curOperationAction = ad.Clone(); selectKey = ad.index; } else { if (LastSelectGridY != CurSelectGridY) { //更换timeline // TimeLineDataManager.Instance.curOperationAction = null; } } } } data.DeleteAction(selectKey); }
IEnumerator PlayLine(TimeLineData data) { Type t = data.GetType(); List <string> keyList = new List <string>(); foreach (var actionPair in data.GetActionDic()) { Debug.Log("key is " + actionPair.Key); keyList.Add(actionPair.Key); } for (int i = 0; i < keyList.Count; i++) { string key = keyList[i]; if (i == 0) { ActionItemData ad = data.GetActionByKey(key); float st = ad.actionStartTime; yield return(new WaitForSeconds(st)); data.SetValueByAction(ad); foreach (var name in ad.methodNameList) { string methodName = "Execute" + name; t.InvokeMember(methodName, BindingFlags.InvokeMethod, null, data, null); } } else { string lastkey = keyList[i - 1]; ActionItemData lastad = data.GetActionByKey(lastkey); float lastst = lastad.actionStartTime; ActionItemData ad = data.GetActionByKey(key); float st = ad.actionStartTime; float time = st - lastst; Debug.Log(" time is " + time.ToString()); yield return(new WaitForSeconds(time)); data.SetValueByAction(ad); foreach (var name in ad.methodNameList) { string methodName = "Execute" + name; t.InvokeMember(methodName, BindingFlags.InvokeMethod, null, data, null); } } } }
void OnTimeLineGUI() { curTimeLineRect = new Rect(0, TITLE_HEIGHT, totalGridCount * GRID_WIDTH, 600); GUILayout.BeginArea(curTimeLineRect); int len = TimeLineDataManager.Instance.GetTimeLineCount(); for (int i = 0; i < len; i++) { TimeLineData data = TimeLineDataManager.Instance.GetTimeLineByIndex(i); DrawBox(data.TimeLineName, 0, LABEL_HEIGHT * i, LABLE_WIDTH, LABEL_HEIGHT, Color.white); for (int j = 0; j < totalGridCount; j++) { Color c = Color.white; SortedDictionary <string, ActionItemData> acDic = data.GetActionDic(); foreach (var acpair in acDic) { //当期操作的action 不画 ActionItemData ad = acpair.Value; int st = (int)(ad.actionStartTime / TimeLineDataManager.Instance.TickDelta); int et = (int)(ad.actionEndTime / TimeLineDataManager.Instance.TickDelta); if (j == st) { c = Color.green; } if (j > st && j <= et) { c = Color.red; } } if (CurSelectGridY == i) { //画当前操作的action ActionItemData tempad = TimeLineDataManager.Instance.curOperationAction; if (tempad != null) { int st = (int)(tempad.actionStartTime / TimeLineDataManager.Instance.TickDelta); int et = (int)(tempad.actionEndTime / TimeLineDataManager.Instance.TickDelta); if (j == st) { c = selectColor; } if (j > st && j <= et) { c = Color.red; } } else { if (j == CurSelectGridX) { c = selectColor; } } } //if ( CurSelectGridX == j && CurSelectGridY == i ) //{ // c = selectColor; //} DrawBox("", LABLE_WIDTH + j * GRID_WIDTH, LABEL_HEIGHT * i, GRID_WIDTH, GRID_HEIGHT, c); } } GUILayout.EndArea(); }