Unity2022.3版本下TextMeshPro描边问题

Unity谷主 回复了问题 • 2 人关注 • 1 个回复 • 271 次浏览 • 2023-11-14 11:07 • 来自相关话题

fgui 小按钮在大按钮上面 点击小按钮 大按钮也会响应点击

Unityankisme 回复了问题 • 2 人关注 • 4 个回复 • 1437 次浏览 • 2023-11-09 11:19 • 来自相关话题

求助,在Unity中通过UIConfig设置全局按键声音无效

Unity谷主 回复了问题 • 2 人关注 • 1 个回复 • 202 次浏览 • 2023-11-09 08:56 • 来自相关话题

texturepacker导出的plist 导入FGUI后会出现问题

编辑器使用谷主 回复了问题 • 2 人关注 • 1 个回复 • 177 次浏览 • 2023-11-07 10:39 • 来自相关话题

GRoot下的物体设置不同的Layer

回复

Unitykoyori 回复了问题 • 1 人关注 • 1 个回复 • 146 次浏览 • 2023-11-06 13:13 • 来自相关话题

laya里设置mask不生效

Laya谷主 回复了问题 • 2 人关注 • 1 个回复 • 226 次浏览 • 2023-11-06 10:57 • 来自相关话题

要如何判断一个ui是否在其他ui之上

Unitysd1840888 回复了问题 • 2 人关注 • 1 个回复 • 170 次浏览 • 2023-11-03 18:47 • 来自相关话题

能否将当前打开的项目名字显示在编辑器顶栏?

编辑器使用神逸疏狂 发表了文章 • 1 个评论 • 116 次浏览 • 2023-11-03 18:20 • 来自相关话题

有时候项目比较多来回切换非常容易搞混,一不留神就改错项目,要是能直观看到当前打开的项目名就好了
有时候项目比较多来回切换非常容易搞混,一不留神就改错项目,要是能直观看到当前打开的项目名就好了

Unity平台,文本换行保护(解决标点符号处于行首行末、数字因换行而分离的问题)

UnitykL 发表了文章 • 1 个评论 • 386 次浏览 • 2023-11-01 16:04 • 来自相关话题

在 Unity 下,显示文本,若标点符号刚好处于换行处,将会变成这样:





或者括号刚好处于换行处,将会变成这样:





又或者一串较长的数字刚好处于换行处,将会变成这样:





... ...

但我不想这样,为啥?因为这样游戏无法过审!
后来逛了下论坛,也没找到合适的解决方案,就决定自己倒腾了。
 
下面是我的成果~





▲ 上图展示了标点符号换行效果。其实图内还有一个效果就是当“他”字也被挪到第二行时,第一行的字就变少了,所以就将第一行的字距变宽了,这样就达到了与 Office Word 差不多的效果(该效果默认是禁用的,可通过 TextFormat 的 CWP_StretchEnabled 来启用/禁用)





▲ 上图展示了英文单词换行效果。





▲ 上图展示了长数字换行效果。

... ...

代码改造都有尽量绕开谷主的源码,功能也都做了开关(都在 TextFormat 里,以 CWP 开头的变量)。主要进行代码改造的地方是 TextField.cs 。
 
基于v4.3.0的源码改造的(谷主很久都没更新了呢)。
具体代码在附件,可以直接覆盖使用。 查看全部
在 Unity 下,显示文本,若标点符号刚好处于换行处,将会变成这样:

标点不换行.png

或者括号刚好处于换行处,将会变成这样:

很不厚道的括号.png

又或者一串较长的数字刚好处于换行处,将会变成这样:

被迫分离的爱.png

... ...

但我不想这样,为啥?因为这样游戏无法过审!
后来逛了下论坛,也没找到合适的解决方案,就决定自己倒腾了。
 
下面是我的成果~

标点符号换行,且拉伸少字的行.gif

▲ 上图展示了标点符号换行效果。其实图内还有一个效果就是当“他”字也被挪到第二行时,第一行的字就变少了,所以就将第一行的字距变宽了,这样就达到了与 Office Word 差不多的效果(该效果默认是禁用的,可通过 TextFormat 的 CWP_StretchEnabled 来启用/禁用)

英文单词换行.gif

▲ 上图展示了英文单词换行效果。

长数字换行.gif

▲ 上图展示了长数字换行效果。

... ...

代码改造都有尽量绕开谷主的源码,功能也都做了开关(都在 TextFormat 里,以 CWP 开头的变量)。主要进行代码改造的地方是 TextField.cs 。
 
基于v4.3.0的源码改造的(谷主很久都没更新了呢)。
具体代码在附件,可以直接覆盖使用。

关于一个节点下有多个gowrapper的使用

Unity谷主 回复了问题 • 2 人关注 • 1 个回复 • 193 次浏览 • 2023-11-01 10:11 • 来自相关话题

Unity怎么检测鼠标下有FairyGUI元件

Unityzaq17410 回复了问题 • 3 人关注 • 2 个回复 • 1533 次浏览 • 2023-10-29 22:52 • 来自相关话题

FGUI中如何制作鼠标悬停显示内容

编辑器使用zaq17410 回复了问题 • 3 人关注 • 2 个回复 • 1150 次浏览 • 2023-10-29 22:18 • 来自相关话题

扩展 RichTextElement

回复

Unityhs11234 发起了问题 • 1 人关注 • 0 个回复 • 155 次浏览 • 2023-10-27 10:34 • 来自相关话题

图形遮罩支持圆角

CocosCreatorbydreamxxx 发表了文章 • 1 个评论 • 217 次浏览 • 2023-10-26 16:13 • 来自相关话题

本来想用github发pull request的,一直clone失败
GComponent.prototype._updateGraphics = function() {
// @ts-ignore.
let graphics = this._graphics;
if (!graphics) {
return;
}
this.onDraw(graphics);
}

/**
* mask 用于绘制罩子的函数.
* this 指向mask 对象,需要特别注意.
* @param graphics
*/
GComponent.prototype.onDraw = function(graphics) {
// Share render data with graphics content
graphics.clear(false);
let node = this.node;
let width = node.width;
let height = node.height;
let x = -width * node.anchorX;
let y = -height * node.anchorY;
graphics.roundRect(x, y, width, height, this.radius || 0);
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
graphics.stroke();
} else {
graphics.fill();
}
}

GComponent.prototype.onMaskReady = function () {
this.off(fgui.Event.DISPLAY, this.onMaskReady, this);
if (this._maskContent instanceof fgui.GImage) {
this._customMask.type = cc.Mask.Type.IMAGE_STENCIL;
this._customMask.alphaThreshold = 0.0001;
this._customMask.spriteFrame = this._maskContent._content.spriteFrame;
}
else if (this._maskContent instanceof fgui.GGraph) {
if (this._maskContent.type == 2)
this._customMask.type = cc.Mask.Type.ELLIPSE;
else {
this._customMask.type = cc.Mask.Type.RECT;
let r = this._maskContent._cornerRadius[0];
let _radius = r >= 0 ? r : 0;
if (_radius < 1) {
_radius = Math.min(this.node.width, this.node.height) * _radius;
}
this._customMask["radius"] = _radius;
this._customMask["onDraw"] = this.onDraw.bind(this._customMask);
this._customMask["_updateGraphics"] = this._updateGraphics.bind(this._customMask);
this._customMask.type = cc.Mask.Type.RECT;
}
}
};主要修改GComponent.prototype.onMaskReady 查看全部
本来想用github发pull request的,一直clone失败
GComponent.prototype._updateGraphics = function() {
// @ts-ignore.
let graphics = this._graphics;
if (!graphics) {
return;
}
this.onDraw(graphics);
}

/**
* mask 用于绘制罩子的函数.
* this 指向mask 对象,需要特别注意.
* @param graphics
*/
GComponent.prototype.onDraw = function(graphics) {
// Share render data with graphics content
graphics.clear(false);
let node = this.node;
let width = node.width;
let height = node.height;
let x = -width * node.anchorX;
let y = -height * node.anchorY;
graphics.roundRect(x, y, width, height, this.radius || 0);
if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) {
graphics.stroke();
} else {
graphics.fill();
}
}

GComponent.prototype.onMaskReady = function () {
this.off(fgui.Event.DISPLAY, this.onMaskReady, this);
if (this._maskContent instanceof fgui.GImage) {
this._customMask.type = cc.Mask.Type.IMAGE_STENCIL;
this._customMask.alphaThreshold = 0.0001;
this._customMask.spriteFrame = this._maskContent._content.spriteFrame;
}
else if (this._maskContent instanceof fgui.GGraph) {
if (this._maskContent.type == 2)
this._customMask.type = cc.Mask.Type.ELLIPSE;
else {
this._customMask.type = cc.Mask.Type.RECT;
let r = this._maskContent._cornerRadius[0];
let _radius = r >= 0 ? r : 0;
if (_radius < 1) {
_radius = Math.min(this.node.width, this.node.height) * _radius;
}
this._customMask["radius"] = _radius;
this._customMask["onDraw"] = this.onDraw.bind(this._customMask);
this._customMask["_updateGraphics"] = this._updateGraphics.bind(this._customMask);
this._customMask.type = cc.Mask.Type.RECT;
}
}
};
主要修改GComponent.prototype.onMaskReady

虚拟列表居中放大

Unityfengjing 回复了问题 • 5 人关注 • 4 个回复 • 1438 次浏览 • 2023-10-26 13:56 • 来自相关话题

滚动容器计算高度时未排除隐藏的元件!

编辑器使用bydreamxxx 回复了问题 • 3 人关注 • 3 个回复 • 1000 次浏览 • 2023-10-26 12:51 • 来自相关话题

运行时矩形无圆角

Cocos2dx谷主 回复了问题 • 2 人关注 • 1 个回复 • 123 次浏览 • 2023-10-26 10:56 • 来自相关话题

UIPanel这个在UnityScene里显示好别扭啊

Unity谷主 回复了问题 • 2 人关注 • 1 个回复 • 217 次浏览 • 2023-10-26 10:56 • 来自相关话题

UIPanel在Unity 2D项目中Scene里显示的预览问题

Unity谷主 回复了问题 • 2 人关注 • 1 个回复 • 153 次浏览 • 2023-10-26 10:55 • 来自相关话题