CCEffect 设置 properties 后,属性检查器没显示出来

完整的 effect 代码如下:


CCEffect %{
  techniques:
  - name: opaque
    passes:
    - vert: vs:vert
      frag: fs:frag
    properties:
      coverColor: { value: [1.0, 0.0, 0.0, 1.0] }        // 这里定义了一个 vec4 属性
}%

CCProgram vs %{
  precision highp float;
  #include <cc-global>
  #if USE_LOCAL
    #include <cc-local>
  #endif
  in vec3 a_position;
  in vec2 a_texCoord;
  in vec4 a_color;
  out vec4 v_light;
  out vec2 uv0;
  
  vec4 vert() {
    vec4 pos = vec4(a_position, 1);

    #if USE_LOCAL
      pos = cc_matWorld * pos;
    #endif

    pos = cc_matViewProj * pos;

    v_light = a_color;
    uv0 = a_texCoord;
    
    return  pos;
  }
}%

CCProgram fs %{
  precision highp float;

  in vec4 v_light;
  in vec2 uv0;
  uniform Arg {
    vec4 coverColor;
  };

  #pragma builtin(local)  
  layout() uniform sampler2D cc_spriteTexture;

  vec4 frag() {
    vec4 o = texture(cc_spriteTexture, uv0);
    o.rgb = mix(coverColor.rgb, o.rgb, 0.2); 
    return o;
  }
}%

预期属性检查器里应该显示出这个自定义的 coverColor 属性,但却没有(只显示了一个内置的 USE_LOCAL):

是什么原因呢?

有大佬知道原因么?版本 3.8.6 :scream:

把注释删掉

这里的注释只是我发帖才特意写上,起一个显眼作用……

实际没有这行注释的:joy:

image 这样?

coverColor 如果用来指定颜色的话,需要使用 editor 指定是颜色类型

如 newSetColor: { value: [1,1,1,1], editor: { type: color } }

顺便参考 demo demo/2dP2/Creator3.8.3_2D_ColorfulLabel/assets/colorful-label.effect · 木限东/CocosCreatorShader - Gitee.com

1赞

是不是路径没选对

感谢!我仔细对照了下你的 demo,问题竟然是 properties 少了2个空格……(应该得和 frag 同级)