/// <summary> /// 绘单个常用图集 /// </summary> /// <param name="index"></param> void DrawAtlasItem(int index) { UIAtlas atlasItem = null; DrawGuiHelper.DrawHorizontal(() => { if (index < commonAtlasList.Count) { GUI.backgroundColor = selectAtlas == commonAtlasList[index] ? new Color(0.8f, 0.8f, 0.8f) : Color.white; commonAtlasList[index] = EditorGUILayout.ObjectField("常用:" + index, commonAtlasList[index], typeof(UIAtlas), true, GUILayout.ExpandWidth(true)) as UIAtlas; atlasItem = commonAtlasList[index]; } else { atlasItem = EditorGUILayout.ObjectField("常用:" + index, atlasItem, typeof(UIAtlas), true, GUILayout.ExpandWidth(true)) as UIAtlas; commonAtlasList.Add(atlasItem); } if (atlasItem != null) { DrawGuiHelper.DrawButton("选中", () => { selectAtlas = atlasItem; }, 50, 20); } GUI.backgroundColor = Color.white; }); }
protected void DrawText() { DrawGuiHelper.DrawHorizontal(() => { DrawGuiHelper.DrawLabel("Text"); var Textcontent = EditorGUILayout.TextField("", Label.text); Label.text = Textcontent; }); }
protected void DrawLblDepth() { DrawGuiHelper.DrawHorizontal(() => { DrawGuiHelper.DrawLabel("Depth"); var depth = EditorGUILayout.IntField(widget.depth); widget.depth = depth; }); }
private void DrawUsingAtlas() { DrawGuiHelper.DrawHorizontal(() => { DrawGuiHelper.DrawLabel("Atlas"); var usingAtlas = EditorGUILayout.ObjectField("", sprite.atlas, typeof(UIAtlas), true, GUILayout.ExpandWidth(true)) as UIAtlas; DrawGuiHelper.DrawButton("更改", () => { if (usingAtlas != selectAtlas) { sprite.atlas = selectAtlas; } }, 50, 20); }); }
private void ShowSprites() { if (childSpList != null && childSpList.Count != 0) { //SpriteFoldout = EditorGUILayout.Foldout(SpriteFoldout, "Sprites"); if (SpriteFoldout) { DrawGuiHelper.DrawVertical(() => { foreach (var item in childSpList) { DrawToggleSpriteItem(item, item.gameObject.activeSelf); } }, "Box"); } } }
/// <summary> /// 显示带Label组件的子物体 /// </summary> private void ShowLabels() { if (childLblList != null && childLblList.Count != 0) { //lblFoldout = EditorGUILayout.Foldout(lblFoldout, "Labels"); if (lblFoldout) { DrawGuiHelper.DrawVertical(() => { foreach (var itemLbl in childLblList) { DrawToggleLabelItem(itemLbl, itemLbl.gameObject.activeSelf); } }, "Box"); } } }
private void DrawUsingSprite() { DrawGuiHelper.DrawHorizontal(() => { if (NGUIEditorTools.DrawPrefixButton("Sprite")) { NGUISettings.atlas = sprite.atlas; NGUISettings.selectedSprite = sprite.name; //ComponentSelector.Show<UIAtlas>(OnSelectAtlas); Debug.LogError("Click"); } //NGUIEditorTools.DrawPadding(); if (GUILayout.Button(sprite.spriteName, "HelpBox", GUILayout.Height(18f))) { NGUIEditorTools.LoacationSpriteAsset(sprite.atlas, sprite.spriteName); } }); }
private void ShowComAtlas() { DrawGuiHelper.DrawHorizontal(() => { commonAtlasFoldout = EditorGUILayout.Foldout(commonAtlasFoldout, "常用图集"); DrawGuiHelper.DrawLabel("Size"); totalAtlasNum = EditorGUILayout.IntField(totalAtlasNum); }); commonAtlasFoldout = totalAtlasNum > 0; if (commonAtlasFoldout) { DrawGuiHelper.DrawVertical(() => { for (int i = 0; i < totalAtlasNum; i++) { DrawAtlasItem(i); } }); } }
void OnGUI() { ParenTf = EditorGUILayout.ObjectField("父对象:", ParenTf, typeof(Transform), true, GUILayout.ExpandWidth(true)) as Transform; if (ParenTf != null) { EditorGUILayout.Vector3Field("世界坐标:", ParenTf.position); EditorGUILayout.Vector3Field("局部坐标:", ParenTf.localPosition); } ChildWroldTf = EditorGUILayout.ObjectField("子对象:", ChildWroldTf, typeof(Transform), true, GUILayout.ExpandWidth(true)) as Transform; if (ChildWroldTf != null) { EditorGUILayout.Vector3Field("世界坐标:", ChildWroldTf.position); EditorGUILayout.Vector3Field("局部坐标:", ChildWroldTf.localPosition); } DrawGuiHelper.DrawButton("子->父(局标):", () => { GetLocalPos(); }); childLocalParentPos = EditorGUILayout.Vector3Field("子转父局部坐标:", childLocalParentPos); }
protected void DrwaTs() { DrawGuiHelper.DrawHorizontal(() => { if (isNeedChangeTs) { var widgetTs = EditorGUILayout.Vector2Field("Transform", new Vector2(widget.transform.localPosition.x, widget.transform.localPosition.y)); widget.transform.localPosition = widgetTs; if (!originalTsDic.ContainsKey(widget)) { originalTsDic.Add(widget, widgetTs); } DrawGuiHelper.DrawButton("还原", () => { if (originalTsDic.ContainsKey(widget)) { widget.transform.localPosition = originalTsDic[widget]; } }, 50, 20); } }); }
protected void DrawName() { DrawGuiHelper.DrawHorizontal(() => { if (isNeedChangeName) { DrawGuiHelper.DrawLabel("Name"); var widgetName = EditorGUILayout.TextField("", widget.name); widget.name = widgetName; if (!originalNameDic.ContainsKey(widget)) { originalNameDic.Add(widget, widget.name); } DrawGuiHelper.DrawButton("还原", () => { if (originalNameDic.ContainsKey(widget)) { widget.name = originalNameDic[widget]; } }, 50, 20); } }); }
void DrawToggleBtn() { DrawGuiHelper.DrawHorizontal(() => { if (GUILayout.Toggle(curShowType == ShowType.Label, "Labels", "ButtonLeft")) { curShowType = ShowType.Label; } if (GUILayout.Toggle(curShowType == ShowType.Sprite, "Sprites", "ButtonMid")) { curShowType = ShowType.Sprite; } if (GUILayout.Toggle(curShowType == ShowType.Texture, "Textures", "ButtonRight")) { curShowType = ShowType.Texture; } lblFoldout = curShowType == ShowType.Label; SpriteFoldout = curShowType == ShowType.Sprite; var lblActive = curShowType == ShowType.Label; var SprActive = curShowType == ShowType.Sprite; var TexActive = curShowType == ShowType.Texture; if (lblActive) { GetLabels(); } else if (SprActive) { GetSprites(); } else if (TexActive) { GetTextures(); } }); }
void OnGUI() { EditorGUILayout.HelpBox("创建对象:", MessageType.Info, true); DrawGuiHelper.DrawVertical(() => { DrawGuiHelper.DrawButton("创建按钮", CreateButton); isNeedScale = GUILayout.Toggle(isNeedScale, "点击需要缩放效果"); }, "Box"); //常用图集 ShowComAtlas(); if (totalAtlasNum > 0) { EditorGUILayout.HelpBox("针对此对象的子物体修改:", MessageType.Info); } DrawGuiHelper.DrawHorizontal(() => { DrawGuiHelper.DrawVertical(() => { if (mTarget == null) { mTarget = Selection.activeGameObject; } mTarget = EditorGUILayout.ObjectField("修改对象:", mTarget, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject; if (mTarget != null) { DrawGuiHelper.DrawHorizontal(() => { isNeedChangeName = GUILayout.Toggle(isNeedChangeName, "修改名字"); isNeedChangeTs = GUILayout.Toggle(isNeedChangeTs, "修改位置"); }); isOnlyShowDepthBelowTen = GUILayout.Toggle(isOnlyShowDepthBelowTen, "只显示层级低于10"); if (resultStringBuilder != null && resultStringBuilder.Length > 0) { GUILayout.TextArea(resultStringBuilder.ToString()); } DrawGuiHelper.DrawHorizontal(() => { //labels sprites Textures DrawToggleBtn(); }); DrawGuiHelper.DrawScrollView(() => { //labels ShowLabels(); //Sprites ShowSprites(); }, ref mLblScrollViewPos); } }, "Box"); DrawGuiHelper.DrawVertical(() => { DrawGuiHelper.DrawButton("保存修改", ApplyChangeAndSave); DrawGuiHelper.DrawButton("位置计算工具", OpenCalTs); DrawGuiHelper.DrawButton("一键修正缩放", OneKeyResetScale); DrawGuiHelper.DrawButton("一键修改使用图集", OneKeyChangeAtlas); DrawGuiHelper.DrawButton("查Foreach", FindAllScripts); }, "Box"); }); }