Skip to content
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

C# Editor Script Activation Issue: "Possible Cyclic Resource Inclusion" Error #84878

Open
aignermax opened this issue Nov 14, 2023 · 3 comments

Comments

@aignermax
Copy link

Godot version

4.1.1.stable.mono

System information

Windows 11 Godot4.1.1.stable Forward+

Issue description

Issue description:
When trying to activate a C# editor script in my Godot project, I encounter an error stating:

"Another resource is loaded from path 'res://addons/CSharpButton/CSharpButton.cs' (possible cyclic resource inclusion)."
image

This issue only arises with C# editor scripts; GDScript-based plugins function as expected. This problem occurs in a new project where C# is otherwise working correctly.

Steps to reproduce

Steps to reproduce:

  1. Create a new Godot project with C# support.
  2. click on Project > Project Settings
    image
    3.Click on "Plugins > Create New Plugin"
    image
  3. specify name (and folder if you want), switch language to C# and press Create
    image
  4. Try to activate the plugin through the Godot editor under "Project" > "Project Settings" > "Plugins".
    image
  5. Encounter the error message regarding cyclic resource inclusion in the Console Output
    image

Minimal reproduction project

Minimal reproduction project:

MinimalProject.zip

@raulsntos
Copy link
Member

In your screenshot you seem to have left the Activate now? option enabled. This is not supported for C# plugins since the C# projects has to be built before the scripts can be used, as documented in the Making plugins documentation page:

image

With the Activate now? option enabled, a warning alert should have appeared to let you know that it couldn't activate the plugin. Did the alert not show up for you?

image

There's a PR (#83578) that disables the Activate now? for C# plugins to prevent this from happening.

@aignermax
Copy link
Author

Dear Godot Community and @raulsntos

thank you for your explanation.

I'd like to suggest improvements for handling C# plugins in Godot, focusing on the activation process and error messaging.

Current Issue:
The "Activate now" option doesn't work for C# plugins without manual compilation. The error message displayed is misleading, suggesting a script error instead of a compilation requirement. Even the godot Console Error is somewhat misleading as it says "Another reasource is loaded from path... possible cyclic resource inclusion" (not sure what this even means).

Proposals:

  1. Automate Compilation Process: Automate the C# project compilation when "Activate now" is used, aligning it with the GDScript plugin experience. This would streamline the plugin activation process for a better user experience.
  2. Improve Error Messaging: If automation isn't feasible, an improved error message would help. Suggesting the need for compilation (e.g., "Compile the project using Ctrl+Shift+B in Visual Studio, then activate the plugin manually using the Menu Projects>>Project Settings>>Plugins") would be more informative and less confusing.

Benefits:
These changes would simplify the workflow for C# developers and enhance clarity, aligning with Godot’s user-friendly principles.

Thanks for considering these suggestions.

Best,
Max

@freelancegames
Copy link

freelancegames commented Dec 17, 2023

I'd recommend changing the "Activate Now" button so it's grayed out if c# is selected and add a label saying the plugin requires manual compilation for c#.

There are other cyclic bugs with c# plugin in Godot. For example, the following example produces the bug if you try to make any changes without closing VS.code, closing Godot, re-opening Godot, re-compiling the plugin with the plugin disabled, and then enabling the plugin..

#if TOOLS
using Godot;
using System;

[Tool]
public partial class MapEditor : EditorPlugin
{
AcceptDialog _popup;

public override void _EnterTree()
{
	string name = "Bubba Gump";
	Callable callable = Callable.From(() => MapEditorCallBack(name));
	AddToolMenuItem("Map Editor", callable);
}

public override void _ExitTree()
{
	RemoveToolMenuItem("Map Editor...");
	_popup.Free();
}

void MapEditorCallBack(string name)
{
	_popup = new AcceptDialog();
	_popup.Title = "Map Editor";

	AddChild(_popup);
	_popup.Popup();
}

}
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants