[SOLVED] Text element can not change material?

It seems we can not change text element’s material ?
There is no option in the online editor.
In the engine, it will always use the default material:

_updateMaterial: function (screenSpace) {
    if (screenSpace) {
        this._material = this._system.defaultScreenSpaceTextMaterial;
        if (this._meshInstance) this._meshInstance.layer = pc.scene.LAYER_HUD;
    } else {
        this._material = this._system.defaultTextMaterial;
        if (this._meshInstance) this._meshInstance.layer = pc.scene.LAYER_WORLD;
    }
    if (this._meshInstance) {
        this._meshInstance.material = this._material;
        this._meshInstance.screenSpace = screenSpace;
    }
}

Why do you want to change the material?

I want to implement the effect that discussed in [SOLVED] How can I make the element transparent when other entities in front?

Right I see.

There isn’t an official API for setting your own material on the text at the moment. You’d probably have to patch that _updateMaterial method if you wanted to use your own material.

1 Like