[0]提几个建议
1.新建脚本的时候能不能跟runtime一样选择目录
2.Scene上面添加个drawCallOptimize开关
3.Sprite是不是可以扩展几个方法
Object.defineProperty(Laya.Sprite.prototype, "gray", {
get: function (): boolean { return this._gray },
set: function (value: boolean) {
this._gray = value;
Laya.UIUtils.gray(this, value);
}
})
Object.defineProperty(Laya.Sprite.prototype, "useSourceSize", {
get: function (): boolean { return this._useSourceSize },
set: function (value: boolean) {
if (this._useSourceSize != value) {
if (value && this.texture)
this.size(this.texture.sourceWidth, this.texture.sourceHeight);
this._useSourceSize = value; //放最后,因为size会改变autoSize的值
}
}
})
Object.defineProperty(Laya.Sprite.prototype, "skin", {
get: function (): string { return this._skin },
set: function (url: string) {
this._skin = url;
if (!url) {
this.texture = null;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
} else {
let tex = Laya.loader.getRes(url);
if (tex) {
this.texture = tex;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
}
else {
if (this._skinBaseUrl)
url = Laya.URL.formatURL(url, this._skinBaseUrl);
let sk = this._skin;
Laya.loader.load(url).then((tex: Laya.Texture) => {
if (this._skin == sk) {
this.texture = tex;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
}
});
}
}
}
})
2.Scene上面添加个drawCallOptimize开关
3.Sprite是不是可以扩展几个方法
Object.defineProperty(Laya.Sprite.prototype, "gray", {
get: function (): boolean { return this._gray },
set: function (value: boolean) {
this._gray = value;
Laya.UIUtils.gray(this, value);
}
})
Object.defineProperty(Laya.Sprite.prototype, "useSourceSize", {
get: function (): boolean { return this._useSourceSize },
set: function (value: boolean) {
if (this._useSourceSize != value) {
if (value && this.texture)
this.size(this.texture.sourceWidth, this.texture.sourceHeight);
this._useSourceSize = value; //放最后,因为size会改变autoSize的值
}
}
})
Object.defineProperty(Laya.Sprite.prototype, "skin", {
get: function (): string { return this._skin },
set: function (url: string) {
this._skin = url;
if (!url) {
this.texture = null;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
} else {
let tex = Laya.loader.getRes(url);
if (tex) {
this.texture = tex;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
}
else {
if (this._skinBaseUrl)
url = Laya.URL.formatURL(url, this._skinBaseUrl);
let sk = this._skin;
Laya.loader.load(url).then((tex: Laya.Texture) => {
if (this._skin == sk) {
this.texture = tex;
this.repaint(Laya.SpriteConst.REPAINT_ALL);
}
});
}
}
}
})
1 个回复
小高
赞同来自:
2、这个功能不应该在Scene开启。做UI使用预制体,不要用Scene。
3、Sprite是轻量化的,不适合扩展这些功能。