From c8aeb5908f02ee4b61e452f22f202bb497188d42 Mon Sep 17 00:00:00 2001 From: jk20012001 Date: Thu, 9 Dec 2021 18:58:22 +0800 Subject: [PATCH] Add scene panel component help url and item tooltips (#9783) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加场景面板help和tooltips * 增加场景面板help和tooltips * update tooltips * Apply suggestions from code review Co-authored-by: yufang.wu <2435731537@qq.com> * Apply suggestions from code review Co-authored-by: yufang.wu <2435731537@qq.com> Co-authored-by: yufang.wu <2435731537@qq.com> --- cocos/core/scene-graph/scene-globals.ts | 41 ++++++++++++++++++++-- editor/i18n/en/localization.js | 46 ++++++++++++++++++++++++- editor/i18n/zh/localization.js | 44 +++++++++++++++++++++++ 3 files changed, 127 insertions(+), 4 deletions(-) diff --git a/cocos/core/scene-graph/scene-globals.ts b/cocos/core/scene-graph/scene-globals.ts index 49fe2dfd1c..fa0dd52ae9 100644 --- a/cocos/core/scene-graph/scene-globals.ts +++ b/cocos/core/scene-graph/scene-globals.ts @@ -24,7 +24,7 @@ * @module scene-graph */ -import { ccclass, visible, type, displayOrder, readOnly, slide, range, rangeStep, editable, serializable, rangeMin, tooltip, formerlySerializedAs, displayName } from 'cc.decorator'; +import { ccclass, visible, type, displayOrder, readOnly, slide, range, rangeStep, editable, serializable, rangeMin, tooltip, formerlySerializedAs, displayName, help } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; import { TextureCube } from '../assets/texture-cube'; import { CCFloat, CCBoolean, CCInteger } from '../data/utils/attribute'; @@ -58,6 +58,7 @@ const normalizeHDRColor = (color : Vec4) => { * @zh 场景的环境光照相关信息 */ @ccclass('cc.AmbientInfo') +@help('i18n:cc.Ambient') export class AmbientInfo { @serializable @formerlySerializedAs('_skyColor') @@ -116,6 +117,7 @@ export class AmbientInfo { } }) @editable + @tooltip('i18n:ambient.skyLightingColor') set skyLightingColor (val: Color) { _v4.set(val.x, val.y, val.z, val.w); if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { @@ -147,6 +149,7 @@ export class AmbientInfo { */ @editable @type(CCFloat) + @tooltip('i18n:ambient.skyIllum') set skyIllum (val: number) { if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { this._skyIllumHDR = val; @@ -178,6 +181,7 @@ export class AmbientInfo { } }) @editable + @tooltip('i18n:ambient.groundLightingColor') set groundLightingColor (val: Color) { _v4.set(val.x, val.y, val.z, val.w); if ((legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR) { @@ -215,6 +219,7 @@ legacyCC.AmbientInfo = AmbientInfo; * @zh 天空盒相关信息 */ @ccclass('cc.SkyboxInfo') +@help('i18n:cc.Skybox') export class SkyboxInfo { @serializable protected _applyDiffuseMap = false; @@ -251,6 +256,7 @@ export class SkyboxInfo { return false; }) @editable + @tooltip('i18n:skybox.applyDiffuseMap') set applyDiffuseMap (val) { this._applyDiffuseMap = val; @@ -267,6 +273,7 @@ export class SkyboxInfo { * @zh 是否启用天空盒? */ @editable + @tooltip('i18n:skybox.enabled') set enabled (val) { if (this._enabled === val) return; this._enabled = val; @@ -284,6 +291,7 @@ export class SkyboxInfo { * @zh 是否启用环境光照? */ @editable + @tooltip('i18n:skybox.useIBL') set useIBL (val) { this._useIBL = val; @@ -300,6 +308,7 @@ export class SkyboxInfo { * @zh 是否启用HDR? */ @editable + @tooltip('i18n:skybox.useHDR') set useHDR (val) { (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR = val; this._useHDR = val; @@ -327,6 +336,7 @@ export class SkyboxInfo { */ @editable @type(TextureCube) + @tooltip('i18n:skybox.envmap') set envmap (val) { const isHDR = (legacyCC.director.root as Root).pipeline.pipelineSceneData.isHDR; if (isHDR) { @@ -406,6 +416,7 @@ legacyCC.SkyboxInfo = SkyboxInfo; * @en Global fog info */ @ccclass('cc.FogInfo') +@help('i18n:cc.Fog') export class FogInfo { public static FogType = FogType; @serializable @@ -434,6 +445,7 @@ export class FogInfo { * @en Enable global fog */ @editable + @tooltip('i18n:fog.enabled') set enabled (val: boolean) { if (this._enabled === val) return; this._enabled = val; @@ -454,6 +466,7 @@ export class FogInfo { * @en Enable accurate fog (pixel fog) */ @editable + @tooltip('i18n:fog.accurate') set accurate (val: boolean) { if (this._accurate === val) return; this._accurate = val; @@ -474,6 +487,7 @@ export class FogInfo { * @en Global fog color */ @editable + @tooltip('i18n:fog.fogColor') set fogColor (val: Color) { this._fogColor.set(val); if (this._resource) { this._resource.fogColor = this._fogColor; } @@ -489,6 +503,7 @@ export class FogInfo { */ @editable @type(FogType) + @tooltip('i18n:fog.type') get type () { return this._type; } @@ -510,6 +525,7 @@ export class FogInfo { @rangeStep(0.01) @slide @displayOrder(3) + @tooltip('i18n:fog.fogDensity') get fogDensity () { return this._fogDensity; } @@ -527,6 +543,7 @@ export class FogInfo { @type(CCFloat) @rangeStep(0.01) @displayOrder(4) + @tooltip('i18n:fog.fogStart') get fogStart () { return this._fogStart; } @@ -544,6 +561,7 @@ export class FogInfo { @type(CCFloat) @rangeStep(0.01) @displayOrder(5) + @tooltip('i18n:fog.fogEnd') get fogEnd () { return this._fogEnd; } @@ -562,6 +580,7 @@ export class FogInfo { @rangeMin(0.01) @rangeStep(0.01) @displayOrder(6) + @tooltip('i18n:fog.fogAtten') get fogAtten () { return this._fogAtten; } @@ -579,6 +598,7 @@ export class FogInfo { @type(CCFloat) @rangeStep(0.01) @displayOrder(7) + @tooltip('i18n:fog.fogTop') get fogTop () { return this._fogTop; } @@ -596,6 +616,7 @@ export class FogInfo { @type(CCFloat) @rangeStep(0.01) @displayOrder(8) + @tooltip('i18n:fog.fogRange') get fogRange () { return this._fogRange; } @@ -617,6 +638,7 @@ export class FogInfo { * @zh 平面阴影相关信息 */ @ccclass('cc.ShadowsInfo') +@help('i18n:cc.Shadow') export class ShadowsInfo { @serializable protected _type = ShadowType.Planar; @@ -662,6 +684,7 @@ export class ShadowsInfo { * @zh 是否启用平面阴影? */ @editable + @tooltip('i18n:shadow.enabled') set enabled (val: boolean) { if (this._enabled === val) return; this._enabled = val; @@ -704,6 +727,7 @@ export class ShadowsInfo { * @zh 阴影接收平面的法线 */ @visible(function (this: ShadowsInfo) { return this._type === ShadowType.Planar; }) + @tooltip('i18n:shadow.normal') set normal (val: Vec3) { Vec3.copy(this._normal, val); if (this._resource) { this._resource.normal = val; } @@ -717,6 +741,7 @@ export class ShadowsInfo { * @zh 阴影接收平面与原点的距离 */ @type(CCFloat) + @tooltip('i18n:shadow.distance') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.Planar; }) set distance (val: number) { this._distance = val; @@ -734,6 +759,7 @@ export class ShadowsInfo { @range([0.0, 1.0, 0.01]) @slide @type(CCFloat) + @tooltip('i18n:shadow.saturation') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set saturation (val: number) { if (val > 1.0) { @@ -753,6 +779,7 @@ export class ShadowsInfo { * @zh 阴影接收平面的法线 */ @type(PCFType) + @tooltip('i18n:shadow.pcf') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set pcf (val) { this._pcf = val; @@ -781,6 +808,7 @@ export class ShadowsInfo { * @zh 获取或者设置阴影纹理偏移值 */ @type(CCFloat) + @tooltip('i18n:shadow.bias') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set bias (val: number) { this._bias = val; @@ -795,6 +823,7 @@ export class ShadowsInfo { * @zh 打开或者关闭自阴影。 */ @type(CCFloat) + @tooltip('i18n:shadow.normalBias') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set normalBias (val: number) { this._normalBias = val; @@ -809,6 +838,7 @@ export class ShadowsInfo { * @zh 获取或者设置阴影纹理大小 */ @type(ShadowSize) + @tooltip('i18n:shadow.shadowMapSize') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set shadowMapSize (value: number) { this._size.set(value, value); @@ -829,6 +859,7 @@ export class ShadowsInfo { * @zh 是否是固定区域阴影 */ @type(CCBoolean) + @tooltip('i18n:shadow.fixedArea') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap; }) set fixedArea (val) { this._fixedArea = val; @@ -843,6 +874,7 @@ export class ShadowsInfo { * @zh 获取或者设置阴影相机近裁剪面 */ @type(CCFloat) + @tooltip('i18n:shadow.near') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; }) set near (val: number) { this._near = val; @@ -857,6 +889,7 @@ export class ShadowsInfo { * @zh 获取或者设置阴影相机远裁剪面 */ @type(CCFloat) + @tooltip('i18n:shadow.far') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; }) set far (val: number) { this._far = Math.min(val, Shadows.MAX_FAR); @@ -871,10 +904,10 @@ export class ShadowsInfo { * @zh 获取或者设置潜在阴影产生的范围 */ @editable - @tooltip('if shadow has been culled, increase this value to fix it') @range([0.0, 2000.0, 0.1]) @slide @type(CCFloat) + @tooltip('i18n:shadow.invisibleOcclusionRange') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === false; }) set invisibleOcclusionRange (val: number) { this._invisibleOcclusionRange = Math.min(val, Shadows.MAX_FAR); @@ -891,10 +924,10 @@ export class ShadowsInfo { * @zh 获取或者设置潜在阴影产生的范围 */ @editable - @tooltip('shadow visible distance: shadow quality is inversely proportional of the magnitude of this value') @range([0.0, 2000.0, 0.1]) @slide @type(CCFloat) + @tooltip('i18n:shadow.shadowDistance') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === false; }) set shadowDistance (val: number) { this._shadowDistance = Math.min(val, Shadows.MAX_FAR); @@ -911,6 +944,7 @@ export class ShadowsInfo { * @zh 获取或者设置阴影相机正交大小 */ @type(CCFloat) + @tooltip('i18n:shadow.orthoSize') @visible(function (this: ShadowsInfo) { return this._type === ShadowType.ShadowMap && this._fixedArea === true; }) set orthoSize (val: number) { this._orthoSize = val; @@ -963,6 +997,7 @@ export const DEFAULT_WORLD_MAX_POS = new Vec3(1024.0, 1024.0, 1024.0); export const DEFAULT_OCTREE_DEPTH = 8; @ccclass('cc.OctreeInfo') +@help('i18n:cc.OctreeCulling') export class OctreeInfo { @serializable protected _enabled = false; diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 87776a1cce..bf540bf300 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -21,6 +21,10 @@ module.exports = { Canvas: `${url}/${version}/manual/en/ui-system/components/editor/canvas.html`, SkinnedMeshRenderer: `${url}/${version}/manual/en/engine/animation/skeletal-animation.html`, SkinnedMeshBatchRenderer: `${url}/${version}/manual/en/engine/animation/skeletal-animation.html`, + Ambient: `${url}/${version}/manual/zh/concepts/scene/light/lighttype/ambient.html`, + Skybox: `${url}/${version}/manual/zh/concepts/scene/skybox.html`, + Fog: `${url}/${version}/manual/zh/concepts/scene/fog.html`, + Shadow: `${url}/${version}/manual/zh/concepts/scene/light/shadow.html`, DirectionalLight: `${url}/${version}/manual/en/concepts/scene/light/dir-light.html`, SphereLight: `${url}/${version}/manual/en/concepts/scene/light/sphere-light.html`, SpotLight: `${url}/${version}/manual/en/concepts/scene/light/spot-light.html`, @@ -67,8 +71,48 @@ module.exports = { OctreeCulling: `${url}/${version}/manual/en/advanced-topics/native-scene-culling.html`, }, }, + ambient: { + skyLightingColor: 'Sky Color (Upper sphere lighting source).', + groundLightingColor: 'Ground Color (Lower sphere lighting source).', + skyIllum: 'Ambient lighting intensity.', + }, + skybox: { + applyDiffuseMap: 'When checking, scene objects will use accurate diffusion map instead of hemisphere lighting.', + enabled: 'Enable or disable skybox rendering with Envmap cube texture settings.', + useIBL: 'When checking, scene objects will calculate image based lighting from Envmap settings with diffuse and specular-reflections. Otherwise objects only calculate hemisphere diffuse lighting.', + useHDR: 'Toggle HDR or LDR mode. Each mode has seperate light source settings, HDR mode uses physical luminosity unit with camera exposure attributes, and LDR mode uses none-unit without exposure calculations.', + envmap: 'Set skybox texture and environment light source. Support cross / longitude and latitude / 6-separated cube textures. Support hdr / tga / png file type.', + }, + fog: { + enabled: 'Enable or disable global fog effect.', + accurate: 'Toggle vertex fog and pixel fog. Pixel fog has more accurate visual effect with low vertex count objects, but vertex fog has better performance.', + fogColor: 'Fog In-Scattering Color.', + type: 'Different calculation models.', + fogDensity: 'The larger the value, the more foggy it looks.', + fogStart: 'Fog will start with this value (world space unit). Increase this value if you want more clarity nearby.', + fogEnd: 'Further than this value (world space unit), will receive maximum fog effect.', + fogAtten: 'The smaller the value, the more foggy it looks.', + fogTop: 'Objects above this height value (world space unit) are not affected by fog.', + fogRange: 'Fog extends down this range value (world space unit) from the top point.', + }, + shadow: { + enabled: 'Enable or disable real time shadows.', + normal: 'The normal of the plane which receives shadow.', + distance: 'The distance from coordinate origin to the receiving plane.', + saturation: 'Shadow saturation. This value should be 1.0, we recommend that you\'d rather increase ambient lighting than modify this value. ', + pcf: 'Enable soft shadows.', + bias: 'Bias value (world space unit) that can avoid moire artifacts with shadows. The more the value, the more the light leakage.', + normalBias: 'Bias value (world space unit) that can avoid moire artifacts with surfaces that parallel to the directional light.', + shadowMapSize: 'Shadowmap resolutions.', + fixedArea: 'Toggle CSM and fixed area shadows. When checking, shadow will not follow camera, it distributes around directional light position. It is a legacy mode that we do not recommend.', + near: 'Fix area start.', + far: 'Fix area end.', + orthoSize: 'Fix area size, the larger value, the lower precision of shadows.', + invisibleOcclusionRange: 'If some shadow near the camera is missing, increase this value (world space unit) to fix it.', + shadowDistance: 'Shadows do not appear beyond this distance (world space unit).', + }, animation: { - default_clip: 'When checking, the deault animation clip is automatically played.', + default_clip: 'When checking, the default animation clip is automatically played.', clips: 'You can access and play animation clips via a script', play_on_load: 'Automatically play animation clip with the scene is loaded', use_baked_animation: diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index d393efa682..d819031703 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -21,6 +21,10 @@ module.exports = { Canvas: `${url}/${version}/manual/zh/ui-system/components/editor/canvas.html`, SkinnedMeshRenderer: `${url}/${version}/manual/zh/engine/animation/skeletal-animation.html`, SkinnedMeshBatchRenderer: `${url}/${version}/manual/zh/engine/animation/skeletal-animation.html`, + Ambient: `${url}/${version}/manual/zh/concepts/scene/light/lighttype/ambient.html`, + Skybox: `${url}/${version}/manual/zh/concepts/scene/skybox.html`, + Fog: `${url}/${version}/manual/zh/concepts/scene/fog.html`, + Shadow: `${url}/${version}/manual/zh/concepts/scene/light/shadow.html`, DirectionalLight: `${url}/${version}/manual/zh/concepts/scene/light/dir-light.html`, SphereLight: `${url}/${version}/manual/zh/concepts/scene/light/sphere-light.html`, SpotLight: `${url}/${version}/manual/zh/concepts/scene/light/spot-light.html`, @@ -67,6 +71,46 @@ module.exports = { OctreeCulling: `${url}/${version}/manual/zh/advanced-topics/native-scene-culling.html`, }, }, + ambient: { + skyLightingColor: '天空颜色(上半球光照)', + groundLightingColor: '地面颜色(下半球光照)', + skyIllum: '环境光强度', + }, + skybox: { + applyDiffuseMap: '勾选后,场景物体将使用更精确的漫反射图来取代默认的半球光照。', + enabled: '勾选后即可开启天空盒,使用设置的立方体贴图进行渲染', + useIBL: '勾选后,场景物体将使用设置的立方体贴图来进行环境光漫反射及镜面反射计算.', + useHDR: '切换高/低动态范围模式,每种模式都有自己独立的光源设定。\n高动态(HDR)模式会使用光度学灯光单位,配合相机镜头属性进行曝光计算,\n低动态(LDR)模式使用无单位光源和无曝光的镜头,更便于保留原图颜色', + envmap: '设置一个立方体贴图作为环境光源和天空盒,贴图类型包括十字型 HDR 贴图、经纬度图、手动创建的 CubeMap 等。目前支持 HDR/TGA/PNG 等文件格式。', + }, + fog: { + enabled: '雾开关', + accurate: '切换顶点雾和像素雾。勾选该项则使用像素雾,像素雾在顶点数少面积大的物体上有更精确的雾化效果;顶点雾则有更好的性能。', + fogColor: '内散射颜色', + type: '不同的计算雾化模型,目前包括 LINEAR(线性雾)、EXP(指数雾)、EXP_SQUARED(指数平房雾)、LAYERED(层雾)。', + fogDensity: '该值越大雾气越浓', + fogStart: '雾效影响的起始位置', + fogEnd: '雾效影响的结束位置', + fogAtten: '雾化衰减系数,该值越小则雾越浓', + fogTop: '模型顶点在世界坐标系垂直方向上的位置,小于该位置时所有的顶点都会受到雾化效果的影响', + fogRange: '雾化效果从设置的 fogTop 往下所影响的范围', + }, + shadow: { + enabled: '是否开启实时阴影', + normal: '阴影接收平面的法线,垂直于阴影,用于调整阴影的倾斜度', + distance: '阴影接收平面与原点的距离', + saturation: '阴影饱和度,建议设置为 1.0。若需要减小方向光阴影的饱和程度,推荐通过增加环境光来实现,而不是调节该值。', + pcf: '开启软阴影,目前支持 HARD(硬采样)、SOFT(4 倍采样)、SOFT_2X(9 倍采样)类型', + bias: '增加深度偏移值(世界空间单位)可以有效消除阴影摩尔纹,但是过大的值可能造成漏光现象', + normalBias: '法线深度偏移值(世界空间单位),可以消除物体表面朝向平行于阳光方向的阴影摩尔纹,防止曲面出现锯齿状;但是过大的值可能会造成阴影位置偏差', + shadowMapSize: '阴影贴图分辨率,目前支持 Low_256x256、Medium_512x512、High_1024x1024、Ultra_2048x2048 四种精度的纹理', + fixedArea: '切换固定区域和 CSM 模式。固定区域是一种旧模式,我们并不推荐使用。勾选该项则开启 CSM 模式,该模式下阴影会跟随方向光节点的位置,在方向光包围盒附近分布,而非跟随相机。', + near: '固定区域开始值', + far: '固定区域结束值', + orthoSize: '固定区域大小,该值越大则阴影精度越低', + invisibleOcclusionRange: '如果有背后的潜在投射物阴影丢失,请增大该值(世界空间单位)', + shadowDistance: '阴影有效距离(世界空间单位),该值越大则阴影精度越低', + }, animation: { default_clip: '在勾选自动播放或调用 play() 时默认播放的动画 clip。', clips: '通过脚本可以访问并播放的 AnimationClip 列表',