public void AddItem() { InputTextDialog.Open( delegate(byte[] bts) { //创建文件夹 IoBuffer ib = new IoBuffer(); ib.PutBytes(bts); string inputFieldText = ib.GetString(); if (!BeFolderOpen) { OpenFolder(); //没打开的先打开再创建,否则位置错乱 } var ti = TreeItem.Create(inputFieldText, this, MyTreeContainer); //nafio add 170623 这段代码有点冗余应该赋值一次就可以,类似重复的代码也需要整理下 // if (null != MyMenuList.CurSelItem && // !MyMenuList.CurSelItem.Equals (ti)) // { // MyMenuList.CurSelItem.DeSelect(); // } ti.TreeItemID = GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].CreateKVList(MyTreeContainer.Name); MyTreeContainer.CurSelItem = ti; //ti.OnSelect (); Log.i("TreeFolder", "AddItem", "新建item name:" + inputFieldText + " id:" + ti.TreeItemID, BeShowLog); } ); }
public Vector2 GetMousePosInParentRectTransform(Vector2 mousePos) { Vector2 pos = new Vector2(0, 0); var rt = ParentTrm.GetComponent <RectTransform> (); //注意这里要注意下是否会可能出现多个相机 RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, mousePos, GEditorRoot.GetIns()._Canvas.worldCamera, out pos); return(pos); }
/// <summary> /// 导出所有当前打开tree的config /// </summary> public static void ExportTreeConfig() { //获取所有根Folder TreeFolder[] treeFolder = GEditorRoot.GetIns().GetAllTreeRootFolder(); ioBuffer4TreeCfgExport = new IoBuffer(); for (int i = 0; i < treeFolder.Length; i++) { ProcessOneTreeItem(treeFolder[i]); FileHelper.Save(GEditorEnum.EDITOR_DATA_ROOTURL, GEditorEnum.EDITOR_TREE_CONFIG_NAME + treeFolder[i].Name + ".config", ioBuffer4TreeCfgExport.ToArray()); ioBuffer4TreeCfgExport.Clear(); } ioBuffer4TreeCfgExport = null; }
public static void Open(Listener callback, string content) { var go = GameObject.Instantiate(Resources.Load("Prefabs/OKDialog")) as GameObject; go.transform.SetParent(GEditorRoot.GetIns().DialogPanel); var rt = go.GetComponent <RectTransform> (); rt.anchoredPosition = Vector2.zero; OKDialog dialog = go.GetComponent <OKDialog>(); dialog.Callback = callback; dialog.ContentText.text = content; }
public static void ExportTabConfig() { TabData[] td = GEditorRoot.GetIns().GetOpenedTabDatas(); IoBuffer ib = new IoBuffer(); ib.PutInt(td.Length); //长度 for (int i = 0; i < td.Length; i++) { ib.PutString(td[i].Name); //name; ib.PutString(td[i].RefName); //refName; ib.PutInt(td[i].Index); //Index; //VLog.I("GEditorDataMgr","ExportTabConfig","i:"+i+" Name:"+td[i].Name+" RefName:"+td[i].RefName+" Index:"+td[i].Index); } FileHelper.Save(GEditorEnum.EDITOR_DATA_ROOTURL, GEditorEnum.EDITOR_TAB_CONFIG_NAME, ib.ToArray()); }
private void AddItem() { InputTextDialog.Open( delegate(byte[] bts) { //创建文件夹 IoBuffer ib = new IoBuffer(); ib.PutBytes(bts); string name = ib.GetString(); string _itemID = GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].CreateKVList(MyTreeContainer.Name); var treeItem = InsertItem(IndexInParentFolder, name, ParentFolder, MyTreeContainer); treeItem.TreeItemID = _itemID; Log.i("TreeItem", "AddItem", "新建item name:" + name + " id:" + _itemID, BeShowLog); } ); }
public override void OnSelect() { Log.i("TreeItem", "OnSelect", "当前被选中TreeItem ID:" + TreeItemID, BeShowLog); //ItemNameText.color = Color.white; ItemTextBGImg.gameObject.SetActive(true); //通知KVContain刷新当前选中的treeItem数据 if (!BeFolder) { GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].SwitchTreeItem(TreeItemID); } else { //这里如果点中非item,清空KV区域,暂时没找到清理kvitemui的位置 GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].ClearKVListUI(); } }
/// <summary> /// Open the specified callback, regular and info. /// </summary> /// <param name="callback">Callback.</param> /// <param name="regular">正则过滤字符串</param> /// <param name="info">如果输入不符合过滤,需要提示的信息</param> public static void Open(Listener <byte[]> callback, string title = "title", string info = "info", string regular = null, string warning = "") { var go = GameObject.Instantiate(Resources.Load("Prefabs/InputTextDialog")) as GameObject; go.transform.SetParent(GEditorRoot.GetIns().DialogPanel); var rt = go.GetComponent <RectTransform> (); rt.anchoredPosition = Vector2.zero; InputTextDialog dialog = go.GetComponent <InputTextDialog>(); dialog.FilterRegularStr = regular; dialog.WarningStr = info; dialog.Info.text = info; dialog.Title.text = title; dialog.Callback = callback; }
/// <summary> /// 删除item /// </summary> /// <param name="bDelData">true删除数据+treeitem节点,false只删节点,不删除本地及sql数据,剪切时用后者</param> public void DelItem(bool bDelData = false) { if (bDelData) { GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].DelKVListData(TreeItemID); GEditorRoot.GetIns().KVContainerDic[MyTreeContainer.Name].ClearKVListUI();//删除时清空当前kvcontainer的显示,否则item已经删除,但是kv上还显示数据就很奇怪了 } Log.i("TreeItem", "DelItem", "删除TreeItem id:" + TreeItemID, BeShowLog); //先做删除文件夹后的排序 ParentFolder.ParentYOrder(UIEnum.ItemH, IndexInParentFolder); //然后把folder从父类ListItem中去掉 ParentFolder.ItemList.Remove(this); //再删除folder节点 Destroy(gameObject); ParentFolder.RefreshItemNum(); }
/// <summary> /// 生成单个Tab页的GameData /// </summary> public static void GenerateGameData(string editorType) { //初始化缓存 //ioBuffer4GameData = new IoBuffer(); //获取某个tab的TreeContainer TreeContainer _treeContainer = GEditorRoot.GetIns().TreeContainerDic[editorType]; //获取某个tab的KvContainer KVContainer _kvContainer = GEditorRoot.GetIns().KVContainerDic [editorType]; //得到一个treeContainer下所有的treeItem信息 TreeItemData[] itemData = _treeContainer.GetAllTreeItemData(); //确保所有的treeItem数据都被(从sql)拉取到本地 for (int i = 0; i < itemData.Length; i++) { string _treeItemID = itemData[i].TreeItemID; _kvContainer.CheckAndLoadTreeItemData2Local(_treeItemID); } //开始过滤并,返回过滤后要存储的二进制数据 byte[] bs = GEditorConfig.FilterData(editorType, _kvContainer.KVDateDic); if (null == bs) { Debug.Log("未导出 editorType:" + editorType + " 原因数据为null"); return; } //Debug.Log("TExportData------->bs.len:"+bs.Length); //ioBuffer4GameData.PutString(editorType);//存储tab名 //ioBuffer4GameData.PutInt(_treeContainer.RootFolder.SubAllItemNums);//存储当前tab下数据总条数 //递归存储一个treeItem下的所有gdata //SaveOneTreeItemData(_treeContainer.RootFolder,editorType); //NINFO 对存储到ioBuffer4GameData中的数据进行冗余过滤 FileHelper.Save(GEditorEnum.EDITOR_GAME_DATA_ROOTURL, editorType + GEditorEnum.EDITOR_GAME_DATA_NAME, bs /*ioBuffer4GameData.ToArray()*/); //ioBuffer4GameData.Clear(); //ioBuffer4GameData = null; }
/// <summary> /// 打开窗口操作 /// </summary> /// <param name="callback">用于返回窗口操作的结果</param> /// <param name="editorType">当前打开dlg的kvitem属于于哪个editor,有了这个信息,就可以去特定editor数据模板中查找一些数据项的dropdown选项</param> /// <param name="title">打开窗口的名称</param> /// <param name="key">kvitem中 KVData的 key值</param> /// <param name="value">kvitem中 KVData的 value值</param> /// <param name="type">kvitem中 KVData的 type值</param> public static void Open(Listener <byte[]> callback, string editorType, string title = "title", string key = "key", string value = "value", string type = "string") { var go = GameObject.Instantiate(Resources.Load("Prefabs/DefaultDialog")) as GameObject; go.transform.SetParent(GEditorRoot.GetIns().DialogPanel); var rt = go.GetComponent <RectTransform> (); rt.anchoredPosition = Vector2.zero; KVDataModifyDialog dlg = go.GetComponent <KVDataModifyDialog>(); //dialog.FilterRegularStr = regular; //dialog.WarningStr = info; //dialog.Info.text = info; dlg.Title.text = title; dlg.KeyInputField.text = key; dlg.ValueInputField.text = value; dlg.EditorType = editorType; dlg.DataType = type; dlg.TypeInfo.text = type; dlg.InitContentDropdown(type); dlg.DlgCallback = callback; }