plugin active scene tab problem (... base 'Nil')

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By websterek

HI
I need to write plugin for my godot project to automat few operations.
Everything seems to works correctly with one issue:

After changing active scene tab I need to edit script (add random space in empty line or something like that) and save it, to make it working correctly, otherwise (after chaning tab without editing) it’s outputs error:

res://addons/RoshamboManager/roshambo_manager.gd:219 - Invalid call. Nonexistent function 'get_children' in base 'Nil

I think the problem is with function:

get_tree().get_edited_scene_root()

How to solve that?

:bust_in_silhouette: Reply From: BraindeadBZH

What is the type of roshambo_manager.gd and also how do you access it? As a singleton?

It’s a plugin script created like in this tutoral (dock section): Making Plugins — Godot Engine (3.0) documentation in English

websterek | 2018-03-27 18:56

:bust_in_silhouette: Reply From: BraindeadBZH

I re-read your question and realized that I missed something. If your not using the signal “scene_changed” from EditorPlugin then you should.

Can you explain how to use this signal? I’m trying to analise other plugin and documentation but I can’t find any comprehensive example :frowning:

websterek | 2018-03-28 07:12

Using the connect function (Object — Godot Engine (latest) documentation in English) you can connect a signal to your own function and therefore execute custom codes when this event occur.

Signal are not specific to plugins.

BraindeadBZH | 2018-03-28 10:01