mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 01:38:23 +00:00
TextureManager.silentWarnings
is a new boolean property that, when set, will prevent the Texture Manager from emiting any warnings or errors to the console in the case of missing texture keys or invalid texture access. The default is to display these warnings, this flag toggles that.
This commit is contained in:
parent
eec60ea861
commit
5aa1584360
1 changed files with 30 additions and 7 deletions
|
@ -99,7 +99,8 @@ var TextureManager = new Class({
|
|||
this.list = {};
|
||||
|
||||
/**
|
||||
* A temporary canvas element. Used to save pixel data during calls to getPixel and getPixelAlpha methods.
|
||||
* The temporary canvas element used to save the pixel data of an arbitrary texture
|
||||
* during the `TextureManager.getPixel` and `getPixelAlpha` methods.
|
||||
*
|
||||
* @name Phaser.Textures.TextureManager#_tempCanvas
|
||||
* @type {HTMLCanvasElement}
|
||||
|
@ -109,7 +110,7 @@ var TextureManager = new Class({
|
|||
this._tempCanvas = CanvasPool.create2D(this);
|
||||
|
||||
/**
|
||||
* The context of the temporary canvas element.
|
||||
* The 2d context of the `_tempCanvas` element.
|
||||
*
|
||||
* @name Phaser.Textures.TextureManager#_tempContext
|
||||
* @type {CanvasRenderingContext2D}
|
||||
|
@ -119,7 +120,8 @@ var TextureManager = new Class({
|
|||
this._tempContext = this._tempCanvas.getContext('2d', { willReadFrequently: true });
|
||||
|
||||
/**
|
||||
* A counting value used for emitting the 'READY' event after all textures have loaded into this manager.
|
||||
* An internal tracking value used for emitting the 'READY' event after all of
|
||||
* the managers in the game have booted.
|
||||
*
|
||||
* @name Phaser.Textures.TextureManager#_pending
|
||||
* @type {number}
|
||||
|
@ -152,6 +154,17 @@ var TextureManager = new Class({
|
|||
*/
|
||||
this.stampCrop = new Rectangle();
|
||||
|
||||
/**
|
||||
* If this flag is `true` then the Texture Manager will never emit any
|
||||
* warnings to the console log that report missing textures.
|
||||
*
|
||||
* @name Phaser.Textures.TextureManager#silentWarnings
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.silentWarnings = false;
|
||||
|
||||
game.events.once(GameEvents.BOOT, this.boot, this);
|
||||
},
|
||||
|
||||
|
@ -215,9 +228,12 @@ var TextureManager = new Class({
|
|||
checkKey: function (key)
|
||||
{
|
||||
if (this.exists(key))
|
||||
{
|
||||
if (!this.silentWarnings)
|
||||
{
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Texture key already in use: ' + key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -251,8 +267,12 @@ var TextureManager = new Class({
|
|||
key = this.get(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.silentWarnings)
|
||||
{
|
||||
console.warn('No texture found matching key: ' + key);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -366,9 +386,12 @@ var TextureManager = new Class({
|
|||
var textureFrame = this.getFrame(key, frame);
|
||||
|
||||
if (textureFrame && (textureFrame.source.isRenderTexture || textureFrame.source.isGLTexture))
|
||||
{
|
||||
if (!this.silentWarnings)
|
||||
{
|
||||
console.warn('Cannot getBase64 from WebGL Texture');
|
||||
}
|
||||
}
|
||||
else if (textureFrame)
|
||||
{
|
||||
var cd = textureFrame.canvasData;
|
||||
|
|
Loading…
Reference in a new issue