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 void RespawnEditor(EditorRoot e) { string editorName = e.editorName; string initCallbackRefTypeName = e.initCallbackRefType; string initCallbackName = e.initCallback; bool isUtility = e.isUtility; object userData = e.UserData; //Debug.Log("Editor Respawn " + e.initCallbackRefType + "." + e.initCallback + " utility=" + isUtility); e.Close(); EditorRoot findEditor = FindEditor(editorName); if (findEditor != null) { RemoveEditor(editorName); } Type refType = Assembly.GetExecutingAssembly().GetType(initCallbackRefTypeName); MethodInfo initCallbackInfo = refType.GetMethod(initCallbackName, BindingFlags.Public | BindingFlags.Static); if (refType == null || initCallbackInfo == null) { Debug.Log("编辑器\"" + editorName + "\"恢复失败!"); return; } VoidDelegate initDelegate = Delegate.CreateDelegate(typeof(VoidDelegate), null, initCallbackInfo, false) as VoidDelegate; CreateEditor(editorName, isUtility, initDelegate, userData); }
public EditorRoot FindEditor(string name) { EditorRoot editor = null; roots.TryGetValue(name, out editor); return(editor); }
public void AssignCtrlID(EditorRoot root, EditorControl rootCtrl) { if ( (null == root) || (null == rootCtrl) ) { return; } do { root.CtrlCounter++; rootCtrl.CtrlID = root.editorName + "_" + rootCtrl.GetType() + "_" + (root.CtrlCounter).ToString(); EditorCtrlComposite rootCtrlComp = rootCtrl as EditorCtrlComposite; if (null == rootCtrlComp) { break; } foreach (var item in rootCtrlComp.children) { AssignCtrlID(root, item); } } while (false); }
private void UpdateCtrlCountAndID(EditorRoot root, EditorControl rootCtrl) { if (GetEditorRoot() != null) { EditorManager.GetInstance().AssignCtrlID(root, rootCtrl); } }
static void OnEditorGUI(EditorRoot root) {//编辑器响应窗口OnGuI回调函数 if (m_spriteListView == null) { return; } if (m_spriteListView.LastSelectItem < 0) {//如果当前未选中任何小图,更新小图资源变更 if (m_inspector == null) { return; } //Inspecetor试图清空 if (m_inspector.onInspector == OnSpriteInspector) { ClearSpriteView(); } //更新小图资源 //UIAtlasEditorModel.GetInstance().UpdateSprite(); } if ((Event.current.type == EventType.MouseDrag) || (Event.current.type == EventType.ScrollWheel)) { RequestRepaint(); } }
static void OnEnable(EditorRoot root) {//窗口有效回调函数 UIAtlasEditorModel.GetInstance().ReadImagePathConfig(); Undo.undoRedoPerformed += OnUndoRedo; RequestRepaint(); }
static void OnEnable(EditorRoot root) { Debug.Log("OnEnable,窗口初始化?"); ResourceManageConfig.GetInstance().Init(); ResourceManageToolModel.GetInstance().Init(); RebuildResourcesTreeView(); }
public void WirteEditorLayoutInfo(string baseDir, EditorRoot root) { if ( (null == root) || string.IsNullOrEmpty(baseDir) ) { return; } object obj = GetSerializeObject(root); if (null == obj) { return; } string eidtorLayoutInfoPath = baseDir + root.editorName + "/" + "EditorLayoutInfo.layout"; if (!Directory.Exists(baseDir + root.editorName)) { Directory.CreateDirectory(baseDir + root.editorName); } UniversalEditorUtility.MakeFileWriteable(eidtorLayoutInfoPath); StreamWriter yamlWriter = File.CreateText(eidtorLayoutInfoPath); Serializer yamlSerializer = new Serializer(); yamlSerializer.Serialize(yamlWriter, obj); yamlWriter.Close(); }
static void OnDestroy(EditorRoot root) { ResourceManageToolModel.GetInstance().onResourceDBUpdate = null; ResourceManageToolModel.DestroyInstance(); ResourceManageConfig.DestoryInstance(); s_root = null; }
void OnEditorGUI(EditorRoot root) { if ((Event.current.type == EventType.MouseDrag) || (Event.current.type == EventType.ScrollWheel)) { RequestRepaint(); } }
void _StartUpEditor() { EditorRoot root = EditorManager.GetInstance().FindEditor("特效编辑器"); if (root == null) { root = EditorManager.GetInstance().CreateEditor("特效编辑器", false, SpecialEffectEditor.InitControls); } }
public static void Show() { EditorRoot root = EditorManager.GetInstance().FindEditor("资源导出工具"); if (root == null) { root = EditorManager.GetInstance().CreateEditor("资源导出工具", false, InitControls); } }
static void Init() { EditorRoot root = EditorManager.GetInstance().FindEditor(s_editorName); if (root == null) { root = EditorManager.GetInstance().CreateEditor(s_editorName, false, InitControls); } }
static void Init() { //一个单例模式,UI框架只允许同时实例化一个同名UI; EditorRoot root = EditorManager.GetInstance().FindEditor("资源检查工具2"); if (root == null) { root = EditorManager.GetInstance().CreateEditor("资源检查工具2", false, InitControls); } }
static void EditorInit() {//创建主窗口 EditorRoot root = EditorManager.GetInstance().FindEditor("Sprite搜索工具") as SearchSpriteEditor; if (root == null) { EditorManager.GetInstance().RemoveEditor("Sprite搜索工具"); root = EditorManager.GetInstance().CreateEditor <SearchSpriteEditor>("Sprite搜索工具", false, InitControls) as SearchSpriteEditor; } }
static void Init() {//创建Atlas编辑器窗口 EditorRoot root = EditorManager.GetInstance().FindEditor("Atlas编辑器"); if (root == null) { root = EditorManager.GetInstance().CreateEditor("Atlas编辑器", false, InitControls); } }
public static void InitControls(EditorRoot editorRoot) { s_root = editorRoot; //s_root.position = new Rect(100f, 100f, 1024, 768f); { s_root.onDestroy = OnDestroy; s_root.onEnable = OnEnable; } HSpliterCtrl hspliter = new HSpliterCtrl(); hspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true); s_root.RootCtrl = hspliter; //上方树状视图 VBoxCtrl vb0 = new VBoxCtrl(); hspliter.Add(vb0); //下方工具条 HBoxCtrl hb0 = new HBoxCtrl(); hspliter.Add(hb0); TreeViewCtrl treeView = new TreeViewCtrl(); treeView.Name = "_MainTreeView"; treeView.onValueChange = OnTreeViewNodeToggle; vb0.Add(treeView); Rect btnRect = new Rect(0, 0, 60, 20); ButtonCtrl okBtn = new ButtonCtrl(); okBtn.Caption = "确定"; okBtn.Name = "_OkButton"; okBtn.Size = btnRect; okBtn.onClick = OnOkButtonClick; ButtonCtrl cancelBtn = new ButtonCtrl(); cancelBtn.Caption = "取消"; cancelBtn.Name = "_CancelButton"; cancelBtn.Size = btnRect; cancelBtn.onClick = OnCancelButtonClick; hb0.Add(okBtn); hb0.Add(cancelBtn); }
static void OnEditorEnable(EditorRoot root) { SpecialEffectAnimClipEditorModel.GetInstance().Init(); SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipNew = OnSpeClipNew; SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipOpen = OnSpeClipOpen; SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipItemNumChange = OnSpeClipItemNumChange; SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipValueChange = OnSpeClipValueChange; SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipItemSelect = OnSpeClipItemSelectionChange; SpecialEffectAnimClipEditorModel.GetInstance().onSpeAnimClipSetNewAction = OnSpeSetNewPreviewAction; RefreshUIState(); }
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 void InitEidtorFromLayout(EditorRoot e) { if (null == e) { return; } string editorName = e.editorName; string initCallbackRefTypeName = e.initCallbackRefType; string initCallbackName = e.initCallback; // object userData = e.UserData; e.Init(); Type refType = Assembly.GetExecutingAssembly().GetType(initCallbackRefTypeName); MethodInfo initCallbackInfo = refType.GetMethod(initCallbackName, BindingFlags.Public | BindingFlags.Static); if (refType == null || initCallbackInfo == null) { Debug.Log("编辑器\"" + editorName + "\"恢复失败!"); return; } VoidDelegate initDelegate = Delegate.CreateDelegate(typeof(VoidDelegate), null, initCallbackInfo, false) as VoidDelegate; initDelegate(e); EditorManager.GetInstance().AssignCtrlID(e, e.RootCtrl); UniversalEditorUtility.LoadEditorLayout(e); if (e.onAwake != null) { e.onAwake(e); } if (e.onEnable != null) { e.onEnable(e); } if (!roots.ContainsKey(editorName)) { roots.Add(editorName, e); } }
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); }
static void OnEnable(EditorRoot root) { //Modify by liteng for 发布工具改善 start PackageExportToolModel.GetInstance().ReadExportPath(); PackageExportToolModel.GetInstance().ReadManualPath(); PackageExportToolModel.GetInstance().Load(); m_ExportPath = PackageExportToolModel.GetInstance().GetExportPath(); m_ManualPath = PackageExportToolModel.GetInstance().GetManualPath(); m_MainVer = PackageExportToolModel.GetInstance().PackageVer.MainVers; m_UpgradeVer = PackageExportToolModel.GetInstance().PackageVer.UpgradeVer; m_P4Ver = PackageExportToolModel.GetInstance().PackageVer.P4Ver; //Modify by liteng for 发布工具改善 end UpdateTreeView(); }
static void OnDisable(EditorRoot root) {//窗口无效回调函数 if (UIAtlasEditorModel.GetInstance().IsProjectExist()) { if (!m_bIsOperateSaved) { if (EditorUtility.DisplayDialog("保存工程", "是否保存当前工程", "保存", "取消")) { OnSaveProjBtn(null); } } } UIAtlasTempTextureManager.DestroyInstance(); UIAtlasEditorModel.GetInstance().DestoryInstance(); EditorCommandManager.GetInstance().Clear(); Undo.undoRedoPerformed -= OnUndoRedo; GameObject.DestroyImmediate(m_Counter); GameObject.DestroyImmediate(m_previewObj); }
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(); }
//构建控件 public static void InitControls(EditorRoot editorRoot) { s_root = editorRoot; editorRoot.RootCtrl = new HSpliterCtrl(); (editorRoot.RootCtrl as SpliterCtrl).Dragable = false; editorRoot.RootCtrl.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30); HBoxCtrl menuArea = new HBoxCtrl(); editorRoot.RootCtrl.Add(menuArea); _BuildMenuButtons(menuArea); HSpliterCtrl h1 = new HSpliterCtrl(); h1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30); editorRoot.RootCtrl.Add(h1); HBoxCtrl playCtrlArea = new HBoxCtrl(); h1.Add(playCtrlArea); //播放控件 PlayCtrl playCtrl = new PlayCtrl(); playCtrl.Name = s_playCtrlName; playCtrl.onValueChange = OnPlayCtrlValueChange; playCtrl.onStop = OnPlayCtrlStop; playCtrlArea.Add(playCtrl); VSpliterCtrl v1 = new VSpliterCtrl(); v1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(200); v1.Dragable = false; VBoxCtrl speListArea = new VBoxCtrl(); v1.Add(speListArea); h1.Add(v1); //特效动画子项列表 ListViewCtrl speListView = new ListViewCtrl(); speListView.Name = s_speListCtrlName; speListView.onAcceptDragObjs = OnSpeListAcceptDragObjs; speListView.onDropObjs = OnSpeListDropObjs; speListView.onItemSelected = OnSpeListItemSelect; speListView.onDoubleClick = OnSpeListItemDoubleClick; speListView.onScroll = OnSpeListScroll; //speListView.onItemSelectedR = OnSpeListItemRightBtnUp; speListView.onItemSelectedRU = OnSpeListItemRightBtnUp; speListArea.Add(speListView); VSpliterCtrl v2 = new VSpliterCtrl(); v2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(400, true); v2.Dragable = true; v1.Add(v2); VBoxCtrl timeLineViewArea = new VBoxCtrl(); v2.Add(timeLineViewArea); //时间线控件 TimeLineViewCtrl timeLineView = new TimeLineViewCtrl(); timeLineView.Name = s_speTimeLineCtrlName; timeLineView.onItemSelected = OnTimeLineItemSelect; timeLineViewArea.Add(timeLineView); VBoxCtrl tabViewArea = new VBoxCtrl(); v2.Add(tabViewArea); TabViewCtrl tabView = new TabViewCtrl(); tabView.Name = s_tabViewCtrlName; tabViewArea.Add(tabView); tabView.onItemSelected = OnTabViewSelect; _BuildPropertyTabView(tabView); {//注册窗体回调 editorRoot.onEnable = OnEditorEnable; editorRoot.onDisable = OnEditorDisable; editorRoot.onUpdate = OnEditorUpdate; editorRoot.onDestroy = OnEditorDestroy; editorRoot.onGUI = OnEditorGUI; editorRoot.onMessage = OnEditorMessage; } }
static void OnEditorDestroy(EditorRoot root) { SpecialEffectAnimClipEditorModel.GetInstance().Destory(); }
static void OnEditorUpdate(EditorRoot root) { }
static void OnEditorGUI(EditorRoot root) { }