当前位置:网站首页>Cocos uses custom material to display problems

Cocos uses custom material to display problems

2022-07-07 15:38:00 Vegetable chicken on the road

The boss of the company just talked to me many times about this problem , But I didn't pay attention when I used it , Just record it !
problem : Pictures are customized material The image texture is not fully displayed after clipping
Desired effect : The avatar is downloaded from the remote server and cut into rounded corners for display
 Insert picture description here
The effect :
 Insert picture description here
In the process of searching, I found that it was replaced by cocos Self contained material There's no problem , Once thought I wrote it myself material Problems arise , In fact, I learned later that the default material does not operate on the image texture , So it's okay .
Then look up the code and find it packable Change it to false Just fine .. It's too much .
Part of the code is as follows :

loadHeadImg(){
         // Download pictures from a remote server 
         this.loadRemoteRes(UserModel.inst.getAvatar(),(error,Texture2D:cc.Texture2D)=>{
            Texture2D.packable = false;
            var sprite  = new cc.SpriteFrame(Texture2D);
            this._headImg.push(sprite);
        })
    }

What the official documents say is clear .. Stick the :
 Insert picture description here
So you'd better read the official documents when you're free !!!!

原网站

版权声明
本文为[Vegetable chicken on the road]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130612339974.html