Yami RPG Editor

Yami RPG Editor

Ezhelit Aug 19, 2023 @ 8:27pm
Lifecycle Hooks
Does anyone have a flow of all the methods that are called during the creation of the plugin?
Like a Lifecycle Diagram ?


## Unity Script Component Lifecycle for reference

1. **Initialization:**
- `Awake()`: Called when a script instance is initialized, even if the script is not enabled.
- `OnEnable()`: Called when the script is initialized and every time the component is enabled.
- `Start()`: Called before the first frame update only if the script is enabled.

2. **Game Logic:**
- `Update()`: Called once per frame. It's used for regular operations, such as monitoring user input.
- `LateUpdate()`: Called once per frame but after all `Update()` functions have been completed.

3. **Rendering:**
- `OnPreCull()`: Called before frustum culling takes place.
- `OnBecameVisible()` and `OnBecameInvisible()`: Called when an object becomes visible or invisible to any camera.
- `OnWillRenderObject()`: Called before an object is rendered.
- `OnPreRender()`: Called before the camera starts rendering the scene.
- `OnRenderObject()`: Called after all objects have been rendered.

4. **Deactivation:**
- `OnDisable()`: Called when the object is disabled or when the game is closed.

5. **Destruction:**
- `OnDestroy()`: Called when the object is destroyed or when the game is closed. It's used for cleanup or to deallocate resources.
Originally posted by Ezhelit:
Hello man,

I was able to check and execute 3 methods, but I don't know if there are others besides the 3 I found.

export default class Plugin {

onStart() {
console.log('Hero created on scene',Scene);
}

update() {
console.log(`Hero updated`, Actor.latest);
}

onDestroy() {
console.log('Hero deleted');
}
}

I also understood how class importing works. There's a folder named 'Script' which isn't visible in the editor but is visible in the project. With an editor like Visual Code, it's easy to navigate through the code. To manipulate the 'hero', you just need to import and use the constant from the 'actor.js' file. This makes it easy to manage the hero via script. However, I still believe it would be better to have a documented Plugin Lifecycle to ease the manipulation of all the game's classes.
< >
Showing 1-4 of 4 comments
Mr. Von Grimmsy Aug 19, 2023 @ 8:38pm 
Hi again, Ezhelit!

I wish I could provide some input on this, but so far the most I've done with plugins is open their files and stare blankly; I don't even know where to start. :crtstressed:

I sent Yami an email asking if he could provide some input on the issue though, so once I hear back from him, I'll be sure to pass it on!

In the meantime, have you actually looked at any of the plugin files..? Maybe they can provide some hints as to how things are being done. If you've got the head to go looking, I'm sure you'll glean more from them than I could, at any rate. :p03:
Last edited by Mr. Von Grimmsy; Aug 19, 2023 @ 8:39pm
A moderator of this forum has indicated that this post answers the original topic.
Ezhelit Aug 19, 2023 @ 9:05pm 
Hello man,

I was able to check and execute 3 methods, but I don't know if there are others besides the 3 I found.

export default class Plugin {

onStart() {
console.log('Hero created on scene',Scene);
}

update() {
console.log(`Hero updated`, Actor.latest);
}

onDestroy() {
console.log('Hero deleted');
}
}

I also understood how class importing works. There's a folder named 'Script' which isn't visible in the editor but is visible in the project. With an editor like Visual Code, it's easy to navigate through the code. To manipulate the 'hero', you just need to import and use the constant from the 'actor.js' file. This makes it easy to manage the hero via script. However, I still believe it would be better to have a documented Plugin Lifecycle to ease the manipulation of all the game's classes.
Ezhelit Aug 19, 2023 @ 9:10pm 
Ok. I found
static eventTypeMap = {
update: 'update',
create: 'onCreate',
autorun: 'onStart',
collision: 'onCollision',
hittrigger: 'onHitTrigger',
hitactor: 'onHitActor',
destroy: 'onDestroy',
playerenter: 'onPlayerEnter',
playerleave: 'onPlayerLeave',
actorenter: 'onActorEnter',
actorleave: 'onActorLeave',
skillcast: 'onSkillCast',
skilladd: 'onSkillAdd',
skillremove: 'onSkillRemove',
stateadd: 'onStateAdd',
stateremove: 'onStateRemove',
equipmentadd: 'onEquipmentAdd',
equipmentremove: 'onEquipmentRemove',
itemuse: 'onItemUse',
keydown: 'onKeyDown',
keyup: 'onKeyUp',
mousedown: 'onMouseDown',
mousedownLB: 'onMouseDownLB',
mousedownRB: 'onMouseDownRB',
mouseup: 'onMouseUp',
mouseupLB: 'onMouseUpLB',
mouseupRB: 'onMouseUpRB',
mousemove: 'onMouseMove',
mouseenter: 'onMouseEnter',
mouseleave: 'onMouseLeave',
click: 'onClick',
doubleclick: 'onDoubleClick',
wheel: 'onWheel',
input: 'onInput',
focus: 'onFocus',
blur: 'onBlur',
destroy: 'onDestroy',
}
Mr. Von Grimmsy Aug 20, 2023 @ 12:46am 
Ah, nice work! I'm pretty sure that these can be tied to the events within the engine itself, by using the Enumeration menu and designating each folder as a specific 'type'; basically, right-click, 'set as' -> 'Item Event' etc. so that folder can use those events when modifying item files.

I know it actually adds the entries into the event types, as I've tested it myself by adding 'Create' and 'Destroy' event types to items (which by default only have 'Use Item'); I haven't actually tried using them though, as items aren't technically 'created' or 'destroyed' within a scene. :stimulation:

But as far as documentation, I want to say that the plugin info is potentially part of what Yami is working on, but I can't say that for sure, obviously. Only he can.

We've talked a few times over the past week, but it's only been short responses on his behalf, I guess he's still busy with stuff. Hopefully he gets everything smoothed out sooner rather than later, and can get back on top of things with the engine here! :steamthumbsup:
Last edited by Mr. Von Grimmsy; Aug 20, 2023 @ 12:51am
< >
Showing 1-4 of 4 comments
Per page: 1530 50