diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ac5acbe --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 150, + "tabWidth": 4 +} diff --git a/assets/effects/sprite-outline.effect b/assets/effects/sprite-outline.effect index 12e455a..ecb774f 100644 --- a/assets/effects/sprite-outline.effect +++ b/assets/effects/sprite-outline.effect @@ -77,6 +77,7 @@ CCProgram fs %{ ALPHA_TEST(o); - gl_FragColor = o; + // gl_FragColor = o; + gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); } }% diff --git a/assets/effects/sprite-outline.effect.meta b/assets/effects/sprite-outline.effect.meta index de3674d..520572e 100644 --- a/assets/effects/sprite-outline.effect.meta +++ b/assets/effects/sprite-outline.effect.meta @@ -5,11 +5,11 @@ { "glsl1": { "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n", - "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n}\n" + "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n}\n" }, "glsl3": { "vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n", - "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n}\n" + "frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n}\n" } } ], diff --git a/assets/scenes/MainScene.fire b/assets/scenes/MainScene.fire index a0cc5e8..26b8d63 100755 --- a/assets/scenes/MainScene.fire +++ b/assets/scenes/MainScene.fire @@ -78,16 +78,16 @@ "__id__": 8 }, { - "__id__": 10 + "__id__": 11 } ], "_active": true, "_components": [ { - "__id__": 12 + "__id__": 13 }, { - "__id__": 13 + "__id__": 14 } ], "_prefab": null, @@ -177,7 +177,7 @@ "array": [ 0, 0, - 324.7595264191645, + 554.2562584220408, 0, 0, 0, @@ -372,6 +372,9 @@ "_components": [ { "__id__": 9 + }, + { + "__id__": 10 } ], "_prefab": null, @@ -432,7 +435,7 @@ "_enabled": true, "_materials": [ { - "__uuid__": "ca058f99-941b-40f2-b208-d776de59abed" + "__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053" } ], "_srcBlendFactor": 770, @@ -454,6 +457,16 @@ "_atlas": null, "_id": "c5wu68mipC4qBjTD+u0rFa" }, + { + "__type__": "93154zKEUxNspOL91D2hv6b", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_id": "4aQ0ah9X1FT4GFrlS5JCi9" + }, { "__type__": "cc.Node", "_name": "HelloLabel", @@ -465,7 +478,7 @@ "_active": true, "_components": [ { - "__id__": 11 + "__id__": 12 } ], "_prefab": null, @@ -521,7 +534,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 10 + "__id__": 11 }, "_enabled": true, "_materials": [ @@ -572,7 +585,7 @@ }, "_enabled": true, "label": { - "__id__": 11 + "__id__": 12 }, "text": "hello", "_id": "aa8ulaDR9JcbRoT7r3pqZq" diff --git a/assets/scripts/SpriteOutlineCrtl.ts b/assets/scripts/SpriteOutlineCrtl.ts new file mode 100644 index 0000000..420e1e8 --- /dev/null +++ b/assets/scripts/SpriteOutlineCrtl.ts @@ -0,0 +1,21 @@ +const { ccclass, property } = cc._decorator; + +@ccclass +export default class SpriteOutlineCtrl extends cc.Component { + private _sprite: cc.Sprite = null; + + onLoad() { + this._sprite = this.getComponent(cc.Sprite); + if (this._sprite == null) { + throw new Error(`${this.name} can only bind on Sprite`); + } + } + + start() { + // let material: cc.Material = this._sprite.getMaterial(0); + // material.setProperty("test", 0); + // this._sprite.setMaterial(0, material); + } + + // update (dt) {} +} diff --git a/assets/scripts/SpriteOutlineCrtl.ts.meta b/assets/scripts/SpriteOutlineCrtl.ts.meta new file mode 100644 index 0000000..d60927b --- /dev/null +++ b/assets/scripts/SpriteOutlineCrtl.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "93154cca-114c-4db2-938b-f750f686fe9b", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/creator.d.ts b/creator.d.ts index 2c2946a..c4b806a 100644 --- a/creator.d.ts +++ b/creator.d.ts @@ -13601,6 +13601,16 @@ declare namespace cc { /** !#en Material Asset. !#zh 材质资源类。 */ export class Material extends Asset { + /** + * 设置属性 + * @param {string} name + * @param {Object} val + */ + setProperty (name, val, force?); + /** + * 获取属性 + */ + getProperty (name); } /** !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users. !#zh EditBox 组件,用于获取用户的输入文本。 */