public override void execute(UIElementNode node) { base.execute(node); //模块名字 //var moduleName = UICodeExport.UIName; //模块名字 dele_xxx var fullName = node.gameObject.name; var arr = fullName.Split('_'); var renderName = UICodeExport.UpperFirstChar(arr[1]); string savePath = UICodeExport.modulePath + "itemRender/" + renderName + "ItemRender" + UICodeExport.CodeExtendsion; if (File.Exists(savePath) == true) { //不重复生成,以免覆盖已有逻辑 return; } String content = FileHelper.GetUTF8Text(UICodeExport.templatePath + uri); content = content.Replace("[name]", renderName); content = content.Replace("[varname]", outputVar(node)); content = content.Replace("[varaddress]", outputAddress(node)); content = content.Replace("[varhandler]", outputHandler(node)); content = content.Replace("[varadvname]", outputAdvName(node)); content = content.Replace("[varadvaddress]", outputAdvAddress(node)); FileHelper.SaveUTF8(content, savePath); }
public UIBtnPropertyElement(string key, string name) : base(key, name) { this.import_str = ""; this.define_str = "public ClayButton {0};"; this.property_str = "{0} = new ClayButton(getGameObject(\"{0}\"));"; this.handler_header_str = "private void on" + UICodeExport.UpperFirstChar(name) + "Click(EventX e)"; }
public UIDelePropertyElement(string key, string name) : base(key, name) { var deleClassName = UICodeExport.UpperFirstChar(name) + "Delegate"; this.import_str = ""; this.define_str = "public " + deleClassName + " {0};"; this.property_str = "{0} = addDelegate<" + deleClassName + ">(getGameObject(\"{0}\"));\r\n " + "{0}.hide();"; }
private static void CodeExport() { var go = Selection.activeGameObject; if (go == null) { EditorUtility.DisplayDialog("提示", "选择物体为null", "ok"); return; } var el = new UICodeExport(); el.decode(go); el.dispose(); }
protected override string outputAddress(UIElementNode node) { string output = ""; foreach (var prop in node.propterties) { if (prop is UIBtnPropertyElement) { output += addressSpace + UICodeExport.LowerFirstChar(prop.fullName) + ".addEventListener(EventX.CLICK, on" + UICodeExport.UpperFirstChar(prop.name) + "Click);" + breakLine; } } return(output); }
private void handleSpecialProperty(UIElementPropertyBase prop, GameObject child, string value) { if (prop is UIPageListPropertyElement) { var pagelist = prop as UIPageListPropertyElement; GameObject item; var itemTrs = child.transform.Find("itemRender_" + value); bool isInList = false; if (itemTrs) { item = itemTrs.gameObject; isInList = true; } else { item = getChildByName("itemRender_" + value); } RectTransform itemTransform = null; if (item != null) { itemTransform = item.GetComponent <RectTransform>(); } if (itemTransform != null) { pagelist.itemClass = UICodeExport.UpperFirstChar(value) + "ItemRender"; if (isInList) { pagelist.itemSkin = StringUtil.substitute("getGameObject(\"{0}/{1}\")", child.name, "itemRender_" + value); } else { pagelist.itemSkin = "itemRender_" + value; } pagelist.itemWidth = (int)itemTransform.sizeDelta.x; pagelist.itemHeight = (int)itemTransform.sizeDelta.y; } } }
public override void execute(UIElementNode node) { base.execute(node); //模块名字 //var moduleName = UICodeExport.UIName; //模块名字 dele_xxx var fullName = node.gameObject.name; var arr = fullName.Split('_'); var renderName = UICodeExport.UpperFirstChar(arr[1]); String content = FileHelper.GetUTF8Text(UICodeExport.templatePath + uri); content = content.Replace("[name]", renderName); content = content.Replace("[varname]", outputVar(node)); content = content.Replace("[varaddress]", outputAddress(node)); string savePath = UICodeExport.modulePath + "code/Code" + renderName + "ItemRender" + UICodeExport.CodeExtendsion; FileHelper.SaveUTF8(content, savePath); }
public virtual string outputDefine() { //声明的变量首字小写 return(StringUtil.substitute(define_str, UICodeExport.LowerFirstChar(fullName))); }