Skip to content

Commit f7e6847

Browse files
committed
Added setGameObject method and currentUnit property
1 parent 5986f8f commit f7e6847

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ var WebGLPipeline = new Class({
235235
* @since 3.10.0
236236
*/
237237
this.active = false;
238+
239+
/**
240+
* Holds the most recently assigned texture unit.
241+
* Treat this value as read-only.
242+
*
243+
* @name Phaser.Renderer.WebGL.Pipelines.WebGLPipeline#currentUnit
244+
* @type {number}
245+
* @since 3.25.0
246+
*/
247+
this.currentUnit = 0;
238248
},
239249

240250
/**
@@ -279,6 +289,27 @@ var WebGLPipeline = new Class({
279289
return this;
280290
},
281291

292+
/**
293+
* Custom pipelines can use this method in order to perform any required pre-batch tasks
294+
* for the given Game Object. It must return the texture unit the Game Object was assigned.
295+
*
296+
* @method Phaser.Renderer.WebGL.Pipelines.WebGLPipeline#setGameObject
297+
* @since 3.25.0
298+
*
299+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered or added to the batch.
300+
* @param {Phaser.Textures.Frame} [frame] - Optional frame to use. Can override that of the Game Object.
301+
*
302+
* @return {number} The texture unit the Game Object has been assigned.
303+
*/
304+
setGameObject: function (gameObject, frame)
305+
{
306+
if (frame === undefined) { frame = gameObject.frame; }
307+
308+
this.currentUnit = this.renderer.setTextureSource(frame.source);
309+
310+
return this.currentUnit;
311+
},
312+
282313
/**
283314
* Adds a description of vertex attribute to the pipeline
284315
*

0 commit comments

Comments
 (0)