public static bool LoadEditorLayout(EditorRoot root) { bool bRet = false; EditorLayoutInfo editorLayout = new EditorLayoutInfo(); editorLayout.ReadEditorLayoutInfo(LayoutInfoBaseDir, root, ref editorLayout); if (CheckLayoutInfoValid(root, editorLayout)) { //root.position = new Rect(editorLayout.XPox, editorLayout.YPox, editorLayout.Width, editorLayout.Height); //EditorUtility.SetDirty(root); //root.position = new Rect(editorLayout.XPox, editorLayout.YPox, editorLayout.Width, editorLayout.Height); List <EditorControl> spliterTbl = root.GetSpliterCtrl(root.RootCtrl); foreach (var item in spliterTbl) { foreach (var info in editorLayout.DivisionInfo) { if (item.CtrlID == info.SpliterID) { item.layoutConstraint.spliterOffset = info.SplitOffset; item.layoutConstraint.spliterOffsetInv = info.SpliterOffsetInv; break; } } } } return(bRet); }
public static bool SaveEditorLayout(EditorRoot root) { bool bRet = false; if (null == root) { return(false); } EditorLayoutInfo editorLayout = new EditorLayoutInfo(); editorLayout.WirteEditorLayoutInfo(LayoutInfoBaseDir, root); return(bRet); }
public object GetSerializeObject(EditorRoot root) { if (null == root) { return(null); } EditorLayoutInfo newInfo = new EditorLayoutInfo(); newInfo.XPox = root.position.x; newInfo.YPox = root.position.y; newInfo.Width = root.position.width; newInfo.Height = root.position.height; newInfo.DivisionInfo = GetDivisionInfo(root.RootCtrl); return(newInfo); }
private static bool CheckLayoutInfoValid(EditorRoot root, EditorLayoutInfo layoutInfo) { bool bRet = true; if ( (null == root) || (null == layoutInfo) ) { return(false); } do { List <string> spliterTbl = root.GetSpliterCtrlID(root.RootCtrl); if (spliterTbl.Count != layoutInfo.DivisionInfo.Count) { bRet = false; break; } foreach (var item in layoutInfo.DivisionInfo) { if (!spliterTbl.Contains(item.SpliterID)) { bRet = false; break; } } if (!bRet) { break; } } while (false); return(bRet); }
public void ReadEditorLayoutInfo(string baseDir, EditorRoot root, ref EditorLayoutInfo info) { if ( (null == root) || string.IsNullOrEmpty(baseDir) ) { return; } string eidtorLayoutInfoPath = baseDir + root.editorName + "/" + "EditorLayoutInfo.layout"; if (!File.Exists(eidtorLayoutInfoPath)) { return; } StreamReader yamlReader = File.OpenText(eidtorLayoutInfoPath); Deserializer yamlDeserializer = new Deserializer(); //读取持久化对象 info = yamlDeserializer.Deserialize <EditorLayoutInfo>(yamlReader); yamlReader.Close(); }