/// <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; }); }
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); }); }
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 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"); }); }