rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.18k stars 259 forks source link

BBCodeTextPlugin erroring on import #423

Closed cmhoopla closed 2 months ago

cmhoopla commented 3 months ago

I'm trying to use the Rex UI plugin, I'm using phaser 3.80.1 & Rex 1.80.2

I'm just trying to replicate this pen: https://codepen.io/rexrainbow/pen/dyezeQN

but in the phaser webpack build.

Importing the TextEditPlugin works ok.

import BBCodeTextPlugin

doesn't cause an error, but, as soon as you add it to the config: { key: 'rexBBCodeTextPlugin', plugin: BBCodeTextPlugin, start: true },

you get the following error: bbcodetext-plugin.js:20 Uncaught TypeError: pluginManager.registerGameObject is not a function

cmhoopla commented 3 months ago

But, I've just found that I can load the plugin scripts in a preload... so I've got a work around :)

Also, whilst I was looking into this, it seems that rexbbcodetextplugin has Phaser bundled in with it... is that correct? It would seem to me that having loaded the phaser js I'm reloading it with the plug in?

rexrainbow commented 3 months ago

I use webpack in my test environment, it works fine. After import Phaser, it will add phaser at reference window.Phaser, then my plugin can use Phaser.GameObjects.GameObject to create a GameObject class.

rexbbcodetextplugin does not have (full) Phaser bundled, the rendering logic of bbcodetext is copy&modify from phaser engine.

cmhoopla commented 3 months ago

Thanks @rexrainbow I did suspect it was me doing something wrong... I've just tried again, and it seems if I add the import (in my index.js) import BBCodeTextPlugin from 'phaser3-rex-plugins/plugins/bbcodetext-plugin.js'; but don't add the rexBBCodeTextPlugin the edit text works as expected... is that how you'd expect to set it up?

rexrainbow commented 3 months ago

A test code of bbcodetext, The path is 'phaser3-rex-plugins/plugins/bbcodetext-plugin.js' as you expect. Then add it into game config

charlie-says commented 3 months ago

(I'm working in a different machine now) Thanks for getting back to me... And also, thanks for the clarification about the rexbbcodetextplugin. I'm still not able to get the imports to work - I've made a basic repo if you've time or inclination to take a look https://github.com/charlie-says/rextest

I am aware this is something I'm doing wrong, and not something wrong with Rex...
rexrainbow commented 3 months ago
charlie-says commented 3 months ago

Thanks for all your help... I have now got the imports working :) Quick question about TextEdit (or maybe BBCodeText) If I set the padding property of the text it works as expected, but, as soon as I edit, the text doesn't respect the padding, and jumps to the edge. Is that resolvable? I've pushed that change to the above repo if you want to see it in action.

rexrainbow commented 3 months ago

Bug fixed, now padding left, padding right can bypass to input text dom. NPM package will upgrade at end of this month.