public static List <GTimelineStyle> LoadAssets(string path, string pattern = "*") { if (!Directory.Exists(path)) { return(null); } List <GTimelineStyle> list = new List <GTimelineStyle>(); DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] fls = dirInfo.GetFiles(pattern, SearchOption.AllDirectories); foreach (var file in fls) { string json = File.ReadAllText(file.FullName); try { GTimelineStyle ps = JsonConvert.DeserializeObject(json, typeof(GTimelineStyle), getSetting()) as GTimelineStyle;// GJsonInfo.DeSerialize(json) as GTimelineStyle; if (ps != null) { list.Add(ps); } bool b = RefreshStyle(ps, false); if (b) { Save(ps); } } catch (Exception e) { Debug.LogError(e.Message + "\n" + e.StackTrace); Debug.LogError(json); } } return(list); }
public static void Save(GTimelineStyle tls) { string json = GTimelineFactory.Serialize(tls); System.IO.StreamWriter sw = new System.IO.StreamWriter(skillDir + tls.name + Suffix, false, new System.Text.UTF8Encoding(false)); sw.Write(json); sw.Flush(); sw.Close(); sw.Dispose(); AssetDatabase.SaveAssets(); }
void creatTimeline() { GTimelineStyle newTL = GTimelineStyle.CreatDefault("skill" + allDic.Count); if (!Directory.Exists(skillDir)) { Directory.CreateDirectory(skillDir); } allDic.Add(newTL.name, newTL); selectTimeLine = selectData = root.Add(newTL, 0); }
void DeleteEvent(object param) { TreeNode node = (TreeNode)param; if (object.Equals(node.parent, null)) { return; } GTimelineStyle tl = node.parent.obj as GTimelineStyle; GEventStyle eS = node.obj as GEventStyle; // Undo.RecordObjects(new UnityEngine.Object[] { tl,node, this }, "delete Event"); tl.styles.Remove(eS); node.parent.childs.Remove(node); }
void creatTimeline() { GTimelineStyle newTL = GTimelineStyle.CreatDefault("skill" + allStyleList.Count); if (!Directory.Exists(skillDir)) { Directory.CreateDirectory(skillDir); } allStyleList.Add(newTL); InitStyles(); curSelectIdx = allStyleList.Count - 1; UpdateSelectSkill(); // SetSelect(root.Add(newTL, 0)); rootNode.isChange = true; }
public static void Save(GTimelineStyle tls) { string json = JsonConvert.SerializeObject(tls, Newtonsoft.Json.Formatting.Indented, getSetting()); //string json = GJsonInfo.Serialize(tls); System.IO.StreamWriter sw = new System.IO.StreamWriter(skillDir + tls.name + Suffix, false, new System.Text.UTF8Encoding(false)); sw.Write(json); sw.Flush(); sw.Close(); sw.Dispose(); if (Inst != null) { Inst.rootNode.isChange = false; Inst.Repaint(); } AssetDatabase.SaveAssets(); }
public TreeNode Add(GTimelineStyle style, int depth) { depth++; if (depth > 10) { Debug.LogError("超出深度上限=10"); return(null); } TreeNode d = Add(style, style.name); d.isOpen = false; for (int i = 0; i < style.styles.Count; i++) { GEventStyle evt = style.styles[i]; d.AddEventData(evt, depth); } return(d); }
public static List <GTimelineStyle> LoadAssets(string path, string pattern = "*") { if (!Directory.Exists(path)) { return(null); } List <GTimelineStyle> list = new List <GTimelineStyle>(); DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] fls = dirInfo.GetFiles(pattern, SearchOption.AllDirectories); foreach (var file in fls) { string json = File.ReadAllText(file.FullName); GTimelineStyle ps = GTimelineFactory.DeSerialize(Path.GetFileNameWithoutExtension(file.Name), json); if (ps != null) { list.Add(ps); } } return(list); }
void drawRoot(GTimelineStyle root) { string rName = "保存-" + root.name; if (rootNode.isChange) { rName += "*"; } if (GUILayout.Button(rName, GUILayout.MinHeight(30f))) { TimelineWindow.Save(root); } EditorGUILayout.BeginHorizontal(); // root.name = EditorGUILayout.TextField(root.name); root.UpdateMode = (AnimatorUpdateMode)EditorGUILayout.EnumPopup(root.UpdateMode); GUILayout.Label("帧率:", EditorStyles.label); root.FrameRate = EditorGUILayout.IntField(root.FrameRate); GUILayout.Label("总帧数:", EditorStyles.label); root.End = EditorGUILayout.IntField(root.End); GUILayout.Label("t:" + root.LengthTime + "s", GUILayout.Width(30f)); EditorGUILayout.EndHorizontal(); }
public TreeNode AddEventData(GEventStyle data, int depth) { if (data == null) { return(null); } TreeNode node = null; if (data is GPlayTimelineStyle) { string tName = (data as GPlayTimelineStyle).styleRes; if (!object.Equals(this.parent, null) && tName == this.parent.name) { Debug.LogError("错误的名字,timeLineName不能是自己"); return(null); } if (string.IsNullOrEmpty(tName) || !allDic.ContainsKey(tName)) { node = Add(data, data.typeName + "[" + tName + "]"); return(node); } GTimelineStyle ts = allDic[tName]; node = Add(data, data.typeName + "[" + tName + "]"); node.Add(ts, depth); } else { node = Add(data, data.typeName); } for (int i = 0; i < data.styles.Count; i++) { GEventStyle evt = data.styles[i]; node.AddEventData(evt, depth); } return(node); }