-
-
Notifications
You must be signed in to change notification settings - Fork 19.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mono editor plugins can't cast non-tool C# types #36395
Comments
Update from someone on the Discord:
And indeed, setting my Game class as a |
This is probably the same issue I was having: #36192 Is there any drawback to marking something as |
If the question is for me: yes, separation of concerns. I want my |
I also encountered this inexplicable prompt. It turned out to be |
I realized that the key of problem on the other side was that Godot didn't output the error information of C# completely. what godot output error info in editor, I can't find useful information from it.:
Here's the message I got using
|
I have a minimal test case that helps reproduce the issue. Can we rename the issue so that it may get proper attention? |
As noted in the duplicate #52729, this can trigger in the default constructors called by the Editor. I saw it with There's a chance that the tool classes referring to non-tool classes is actually sorta expected behavior. I mean, Tool is kinda meant to say "The editor will need this". Could probably use better errors, though. The one that seems more questionable to me is the case highlighted in #52729, as classes not marked with I'm still trying to understand this issue, so sorry if some of that was wrong. |
just encountered this problem today, is this going to be fixed in V4.0 ? |
(More than a year later, I renamed the issue, according to @geneishouko's proposition) |
Running into this right now trying to add a button to the inspector for a non-tool class. I don't think adding My particular case: // Code inside an EditorInspectorPlugin
public override bool CanHandle(Godot.Object @object)
{
if (@object is MyCustomType) // This fails if MyCustomType doesn't have the [Tool] annotation,
// even if MyCustomType derives from a [Tool] class and even if
// MyCustomType was registered by the plugin using AddCustomType()
return true;
// Etc...
return false;
} There's a proposal (godotengine/godot-proposals#900) that suggests having a secondary annotation for this purpose (perhaps |
I have also encountered this issue just after upgrading to 4.0, in my case, I want to assign a Custom Resource (that is not marked with [Tool]) to a inspector slot from a script that is marked with [Tool]. It was working just fine on 3.5. |
I have also encountered and have to work around this. Is there any way for this to be noted in the documents or made clear in the editor? I find it quite difficult when it comes down to making scripts that act as UI, as its usually quite useful to have that UI run in editor, and this UI need to reference a resource or node that I would rather not have running in the editor, and in some cases this might even require me to make multiple other unrelated scripts tool scripts as well just for the ability to have these nodes be assigned via the editor. |
I also encountered the problem and adding [Tool] solved it. Since I don't use methods like "_Ready" or "_Process" to run my game, the drawback of this solution is not an issue for me. Should still not be required though. |
[Tool] Should definitely not be required for a node to be referenced in a plugin. Sometimes you just want to visualize a node in the 3D view like for example a grid or box, whatever, and you don't want these classes to run during the editor for a good reason. A workaround that doesn't include [Tool] is to load the script and test for that instead of the C# type and then get and set the properties using the variants:
|
Godot version: 3.2.stable
OS/device including version: Windows 10 Pro
Issue description:
With the following hierarchy
![unknown](https://user-images.githubusercontent.com/3216752/74970309-6ea0b780-541e-11ea-8790-8f355ddd67bd.png)
Game
(Control
) andToolGame
(Node2D
) have their own C# classes with the same names.ToolGame
is a[Tool]
, and makes aGetParent<Game>()
call, that works in-game, but fails in-editor with the following error:The same message is shown between 3 and 5 times. The exact same structure and code in Gdscript works as intended.
Steps to reproduce:
Create a scene like the one in the screenshot, and add corresponding classes.
ToolGame.cs
contains this minimal code:The text was updated successfully, but these errors were encountered: