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# new export variables won't show in Inspector until restart #12518

Closed
codeFlu opened this issue Oct 30, 2017 · 43 comments
Closed

C# new export variables won't show in Inspector until restart #12518

codeFlu opened this issue Oct 30, 2017 · 43 comments

Comments

@codeFlu
Copy link

codeFlu commented Oct 30, 2017

Operating system or device, Godot version, GPU Model and driver (if graphics related):
Linux Ubuntu 16.04 , 3.0.Alpha (3-4 day old i think), R7 250

Issue description:
Script wont show references in Inspector if i dont restart Godot , and no support for Lists :(

Steps to reproduce:
Created new project, c# script whit export variable, added it to node

[Export]
public int ran = new int();

wont show in inspector, tryed switching nodes, starting stoping game, nothing worked until restarted godot. Possible cuz it was first added script, later adding more export variables, started showing after running game in editor

@neikeq neikeq added this to the 3.0 milestone Oct 30, 2017
@neikeq
Copy link
Contributor

neikeq commented Oct 30, 2017

Currently, Godot does not build the project automatically when your script changes. You can build with the Build Project button in the Mono bottom panel, or externally from an IDE or terminal.

@akien-mga
Copy link
Member

Duplicate of #11955?

@codeFlu
Copy link
Author

codeFlu commented Oct 30, 2017

Ok just saying , even if i builded in vscode it dident show in inspector until i restarted Godot editor.. I get it needs alot of polish anyway, and pls dont froget to add support for Exporting Lists and Arrays... This is my first issue whit github so sorry if i am not using it proper :) , do i need to close it now or what?

@akien-mga
Copy link
Member

Your issue is good, don't worry :) My comment is more meant for @neikeq to decide if it's the same issue or a different but related one.

@codeFlu codeFlu changed the title C# First export wont show util restart C# First export wont show until restart Oct 30, 2017
@neikeq
Copy link
Contributor

neikeq commented Oct 30, 2017

@codeFlu that was fixed by #12474. Now Godot should detect that the assembly changed and reload it.

@akien-mga
Copy link
Member

Well I could still reproduce this issue today with a build newer than #12474, though I'd have to debug a bit more to see the exact steps to reproduce.

@zatherz
Copy link
Contributor

zatherz commented Nov 25, 2017

C# exports don't appear for me even after restarting Godot, on git master.

public class GridManager : Node {
	[Export]
	public int test = 0;

	// ...
}

@NathanWarden
Copy link
Contributor

@zatherz I think what's going on here is that the C# project needs to be built before Godot can know about the variables. So, instead of restarting, try adding the export attribute, then run your game with F5 or F6. The variable should then appear in the inspector.

@zatherz
Copy link
Contributor

zatherz commented Nov 26, 2017

@NathanWarden It doesn't, but I might have to make a new build

@zatherz
Copy link
Contributor

zatherz commented Nov 26, 2017

Found my problem, only fields can be Exported at this moment (not properties). Can reproduce this issue.

@akien-mga
Copy link
Member

Many users are confused by this issue, it even makes the monkey_pong demo hard to understand as the export variables used to set the paddle and wall directions are not visible at first.

@NathanWarden
Copy link
Contributor

This also causes a major issue when working in teams or on multiple machines because when downloading the repo for the first time when you first open the project whatever variables are in the startup scene get auto-updated, but since they haven't been exported they get completely deleted. I could make a video showing this if desired.

I may be wrong, but the obvious solution seems to be that when opening the project it should compile the project (if possible), then load the first scene.

@neikeq
Copy link
Contributor

neikeq commented Jan 5, 2018

@NathanWarden That's not related to this, but it sounds like a serious issue indeed.

@NathanWarden
Copy link
Contributor

@neikeq Thanks, I'll open a new issue :)

@akien-mga akien-mga changed the title C# First export wont show until restart C# new export variables won't show in Inspector until restart Jan 18, 2018
@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 24, 2018
@maikramer
Copy link

maikramer commented Feb 15, 2018

I had this issue today, custom build, built today, what happens is:
Created new project, added some [Export] variables
Not showing even building the project.
Restarted godot
Without doing anything, now the variables show
Added new [Export] variables
Showing perfectly after build.

Looks like its just a problem in a new project in the first run.
Just to be clear, building is not the problem, you must do it to show, but that is not the main problem.

@maikramer
Copy link

maikramer commented Feb 18, 2018

New problem, if i export arrays, and mark as [Tool], i cant change the array length in inspector, stays zero even when i press to grow, or type a size, if i try too much godot crash without too much things in console.
if i dont mark [Tool], i can change the array in inspector, but with no effect, if i debug i see that the array is null, then i think is something about the code that change the array lenght in mono

should i open another issue?I could not find any issue already open.

if i can make any test to help i can do

@exts
Copy link
Contributor

exts commented Feb 22, 2018

Yeah I'm having this issue on master atm on Windows 10.

@greym0uth
Copy link

Im having an issue where once I add a signal, the exports I added are no longer showing in the inspector and the signals aren't either.

@NQNStudios
Copy link

As of today on Ubuntu 16.04 running 3.0.5 Mono version stable, I get the same behavior as @maikramer:

Created new project, added some [Export] variables
Not showing even building the project.
Restarted godot
Without doing anything, now the variables show
Added new [Export] variables
Showing perfectly after build.

Looks like its just a problem in a new project in the first run.

Looks like it's been a while. Is anyone still maintaining the Mono version? I might be able to help on this issue with some guidance from someone who's worked with the code base before.

@NathanWarden
Copy link
Contributor

If I remember correctly, this is an issue even with GDScript, where if a script had an error in it then it could no longer generate the variables, thus those values would be lost when the scene is saved.

So, I think the solution would be to have Godot internally know the last successful build of each script, and only update serialized variables in the event of a successful build. It would be set to unsuccessful by default, so when you first open a project it will keep all variables there. This is especially a problem if you just cloned a project from source control, as this means everything gets reset immediately in the main scene.

@NQNStudios
Copy link

That's not the problem I'm describing. My script built successfully, but its Export variables still didn't show up in the editor without restarting.

@NathanWarden
Copy link
Contributor

Oops, I confused this with another very similar issue (again). I bet you'd should be safe to try and tackle this bug then :) @neikeq is still the maintainer, but if I'm not mistaken, I think his time is somewhat limited right now due to school, but should pick up soon.

@neikeq
Copy link
Contributor

neikeq commented Jul 25, 2018

Does this still happen after f1130f9?

@NQNStudios
Copy link

I'll let you know as soon as I've forked and built from source -- might take until tomorrow.

@jesselawson
Copy link

It will take me a while but I'll grab this on Mac and see if f1130f9 fixes this. Right now the problem is just the hot reload; clicking Build Project causes the [Export]'d variables to appear.

@NQNStudios
Copy link

Still haven't checked on Ubuntu because when I ran the build with Mono support enabled, there was still no option to create a C# project. Maybe the build failed silently and I was running the non-Mono bin by accident. I'll look into it more when I get the chance

@jesselawson
Copy link

@NQNStudios I ran into the same problem on my Mac last week. Thank you for taking care of Ubuntu. in my case, though I had thought I set the build flags appropriately, I ended up with a non-Mono Godot. Nowadays I just check the About box as soon as I am done building to verify I didn't screw things up.

@neikeq
Copy link
Contributor

neikeq commented Aug 3, 2018

What is the issue? The C# project should be generated automatically when you create a C# acript. Is there any error?

@jesselawson
Copy link

@neikeq There's no error, just behavior that is unexpected. I don't think this is a bug so much as a feature request. When working in a C# script, if I add [Export] to a variable and then go back to Godot, I need to rebuild the project before my exported variable appears in the editor.

I believe the intention is to have this automatically updated behind the scenes, wherein I add [Export] to a variable, go back to the editor, and the editor sees the change and then adds it to the Godot inspector pane automatically--without us having to automatically build the project.

It's more of a nuisance than anything else, and anyone coming from Unreal or Unity has this "auto-build" expectation as well.

@jesselawson
Copy link

Again, I think this should be re-labelled, since this is not a bug and more of a feature request/improvement.

@exts
Copy link
Contributor

exts commented Aug 4, 2018

@lawsonry I get what you're saying. Essentially with gdscript if you make a change in the editor (even before saving) godot picks up your export variables on keypress it seems.

With c# it picks it up on build and that's not a problem, but it would be nice if godot would reload assemblies if a script has changed when focused. Then it would update exports in the editor before building, but idk if the editor can do that without building the source.

@neikeq
Copy link
Contributor

neikeq commented Aug 4, 2018

Oh, I thought the issue was that the exported properties didn't appear after building.
I plan to make building automatic, it's just that I've been focusing on other parts.

@jesselawson
Copy link

jesselawson commented Aug 4, 2018

@neikeq Thank you for your response. I know from other threads that that's your plan, which is why I thought this issue should be relabeled as a feature request/improvement because it's not really a bug.

@exts Exactly, yes. I also understand that this would require some reworking of what the editor does and probably extracting away the process that reloads the assemblies from the process that builds the project. Again, I don't think the original author of this issue meant for this to be called a bug; I think it's was inadvertently called a bug because it's a commonly expected feature of other editors, like Unity and Unreal.

@exts
Copy link
Contributor

exts commented Aug 4, 2018

@lawsonry yeah, you should create a new issue and I think and @neikeq should close this one because that original issue is essentially fixed to the first problem. When the exports weren't reloading in the editor until you restarted the editor. Now building from the mono tab or play scene reloads them fine.

@NathanWarden
Copy link
Contributor

The issue was that the variables didn't show up even after building. I'm not sure if it has been fixed or not, but I had also seen this a few times. I haven't had much time to work in Godot in the last couple of months, so maybe it's been fixed since then :)

@jesselawson
Copy link

@NathanWarden I think it has been fixed. I've been testing v3.0.6 on both Mac and Windows, and in both cases, a rebuild of the project makes the variables appear.

@neikeq
Copy link
Contributor

neikeq commented Aug 5, 2018

I'm closing this then. Feel free to open an issue about automatic builds.

@neikeq neikeq closed this as completed Aug 5, 2018
@gusg21
Copy link

gusg21 commented May 28, 2019

Sorry to revive this but it's still not working for me. It doesn't even work when I rebuild, or restart Godot. I can use hard-coded values in the meantime but I really like this feature and wish it worked.

I'm running Windows 10, 64-bit.

Godot v3.1.1

@gusg21
Copy link

gusg21 commented May 28, 2019

Okay, it updates but only if I changed the hard coded value. If I change the variable name it doesn't care.

@glebasos
Copy link

glebasos commented Dec 2, 2022

Fixed for me on 4.0 Beta

@Aurumaker72
Copy link

Possible regression: this sometimes still happens, requiring a manual build to coerce the editor into showing the newly added exports.

@hsandt
Copy link
Contributor

hsandt commented Feb 15, 2023

The issue reappeared indeed, but in specific contexts, for reasons related to changes in Godot 4. To leave this old issue closed, I'd recommend future reporters to open new issues, if possible with the more specific contexts causing the bug.

For instance:
Issue with tooltips update only: #70217
If this only happens with base class fields on child class instances: #73390

@RNubla
Copy link

RNubla commented Mar 3, 2023

This still occurs in Godot 4. However my work around for this is to run dotnet build in the root of my project which will show the exported variable. I've only tested this on Mac M1 but this may also work on Windows.

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