In monodevelop, if I declare a variable like so...
public int foo = 1;
Then in the line directly above it, i type ///, it will automatically generate this....
/// <summary>
/// The foo.
/// </summary>
How is this happening? Which files in unity are causing this behaviour? I want to know because I want to modify it to add some other generated code.
How is this happening? Which files in unity are causing this behaviour? I want to know because I want to modify it to add some other generated code.
You won't be able to modify Unity's MonoDevelop that easily. They are actually stuck in some old version (which presumably will make your life even more complicated if you want to change its behaviour) that is years old.
Some people use nowadays Xamarin Studio (instead of Unity's MonoDevelop) or the last version of MonoDevelop, with a Unity plugin. This would be a more reliable way for you to go ahead and change MonoDevelop's documentation-autocompletion behaviour, by looking at its upstream source code, and maybe creating an AddIn yourself for the desired functionality.
Related
I have been watching tutorials on youtube (i'm new to unity), I was trying to add a rigid body to my player, which I've never done. In the video they clicked add component in the inspector then physics then rigid body. but i don't see physics and when I search for it nothing appears. the only options i get are:
Effects
Layout
Mesh
Miscellaneous
Rendering
New Script
Underneath Box Collider i get a warning saying the the "module that implements this component type has been force excluded in player settings" could this be the problem? If so how would i fix it?
Thanks.
Try go to the PackageManager, switch to Built-In Packages and see if the package Physics is installed. Sounds like it has been actively be removed (uninstalled) or you somehow broke the Packages/manifest.json file.
If you can't even get the PackageManager try to reset the packages as described here via the top menu bar → Help → Reset Packages to defaults
or just directly replace your Packages/manifest.json with a one from a fresh empty project
Also note
Our first TECH stream release of the year is available as of today. Unity 2020.1 includes a wide range of features and improvements that make Unity workflows even more intuitive and make you more productive, while Unity 2019 LTS remains the recommended version for projects in production.
The PackageManager got an overhaul and a lot of users had issues like yours. See e.g. this thrread.
You should stick to the LTS versions, currently 2019.4 LTS (except for experimenting with the very newest features).
So if you type in the search bar of Add Component "Rigid" nothing pops up? If not I believe it should.
The problem could be in your libraries. Try deleting the library in your project (with Unity closed). Maybe if you have not made much progress in this project you could try opening a new unity project and seeing if it works.
I have a custom preprocessor in my PlayerSettings added to unity. According to unity documentation Unity Custom Define Link basically you just add the preprocessor in
Player Settings->OtherSettings->Scripting Define Symbols
and use that preprocessor in scripts #if preprocessor.
My problem is when I add it, the VS Editor does not change the code to compile enabled code and results in non complied code. Is there something else that I need to add to script after adding preprocessor. I have tried adding AssetDatabase.Refresh(); to but it did not work. Is something needs to be refreshed in memory? I did restarted unity but did not helped.
Update: Now I have used the following script to add the preprocessor during runtime
/// <summary>
/// Symbols that will be added to the editor
/// </summary>
public static readonly string[] Symbols = new string[] {
"MYPreprocessor1"
};
/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
static void AddDefineSymbols()
{
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
List<string> allDefines = definesString.Split(';').ToList();
allDefines.AddRange(Symbols.Except(allDefines));
PlayerSettings.SetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup,
string.Join(";", allDefines.ToArray()));
}
The preprocessor blocks added via script works but I have to clear "Scripting Define Symbols" values and restarting unity allows the preprocessor block code to compile. But it wont work when you add it directly
Note: The above code adds the preprocessor blocks in to Scripting Define Symbols via scripting. If the preprocessor block is already existing it wont do anything else it will just add it.
Ok this was a problem with Visual Studio 2017. The preprocessor would not work if you just do reload solution. Whenever a change in preprocessor statement was detected the VS would give four option Reload, Reload solution , Ignore and Ignore All. I was always using reload solution to reload all the data after change but for preprocessors to get activated/refreshed the first option in VS ie Reload button had to be pressed. With that you don't need to add any of the additional scripts above. I have tested with mono also and mono seems to do above work automatically. This was the case of VS2017 community. Hope this helps someone.
AssetDatabase.Refresh or AssetDatabase.SaveAssets should do the job without any manual steps, at least for JetBrains Rider.
Check in your preferences that Editor attaching is enabled.
As ARMatt said, AssetDatabase.Refresh or AssetDatabase.SaveAssets, but I found in my case I needed both (saveassets first, but not sure if it matters). One or the other seemed to not retain the build info I was trying to store in the scriptable object.
I'm getting this message multiple times when I try to run my game:
The referenced script on this Behaviour is missing
For some reason, all my prefabs are missing a script that dictates something called their 'Mono Behaviour':
What is the Mono Behaviour component, and what does it do?
How can I fix this error? I can click the little target circle to bring up all my scripts, but that just gives me all of the scripts that I've written:
So I don't really know how to replace my missing Mono Behaviour script... Maybe if I knew what it was I could have a clue how to fix it.
I probably moved something. But how can I select the Mono Behaviour script (whatever it is) if the target just shows me my scripts?
Update
I've moved some assets in the project window, but not via the OS (Finder/Explorer) so why is this happening?
Also I am told that Mono Behaviour is a script I've applied...
Don't really get this...isn't the script component a reference to a script?
This happens when you have a script attached to a component, but then the script has been deleted (or its reference has lost in another way, such as the meta file being modified).
If you don't know which script used to be there, just delete those Mono Behaviour components.
MonoBehaviour is the Base Class of all scripts that you want to attach to a GameObject. I am not sure how you managed to create a MonoBehaviour Component with a script missing. What you normally do is write your script and then just drag it from the project view onto the GameObject you want it attached to.
Our Eclipse RCP application was originally built in the 3.1/3.2 era and was running on 3.2 until we switched to 3.6 recently. Its IApplication runs via PlatformUI.createAndRunWorkbench(...). The WorkbenchAdvisor we pass to that function overridescreateWorkbenchWindowAdvisor(...) to return a WorkbenchWindowAdvisor whose createActionBarAdvisor(...) returns an ActionBarAdvisor.
This ActionBarAdvisor's makeActions(...) creates and register()s a bunch of org.eclipse.jface.action.Actions, many of which do things like setAccelerator(SWT.CTRL | 'O'); in their constructors. The Actions are subsequently installed in the ActionBarAdvisor's fillMenuBar(...) and fillCoolBar(...) methods.
The problem we are having (now that we are on Eclipse RCP 3.6) is that these accelerators don't seem to be active until their menus are shown (even if no action is taken besides closing the menu again).
We see a relevant bug but are having some difficulty understanding how to apply its remedy to our situation. We recognize that instead of Actions we "ought" to be using commands, handlers, and key bindings. But we're hoping we don't have to go down that path just yet.
How can we make our accelerators "live" as soon as the application starts up?
If you don't choose to use o.e.ui.bindings extension point, then there isn't a better way. You should only force update the menuManager yourself as you have done in your answer.
As #Prakash mentioned, if you want to keep down that path in your RCP app you must render all of the main menus to see your accelerators.
There is a partial upgrade path that will get you on the right track to commands without forcing a complete switch over right away. For each action in your menu, define a command with an id and define a binding to the shortcut you want in your plugin.xml. Then, when you create the action in your ActionBarAdvisor, don't set the accelerator. Set the IAction.setActionDefinitionId(*) to the command id, can call register(action);
Then you no longer need to use menuManager.updateAll(true) to eagerly render all of your main menu.
After hunting around and experimenting a bit trying to apply the advice from the bug, we added the following to our WorkbenchWindowAdvisor, which seems to have done the trick:
#Override
public void postWindowCreate() {
getWindowConfigurer().getActionBarConfigurer().getMenuManager().updateAll(true);
}
We have no idea how well this fits with the Workbench's design expectations; there could be a better way.
In NetBeans the GUI Builder generates code that is off limits to you from the editor.
I know you can switch to Design Mode and specify custom code and then enter edit in indirectly that way, but it's a pain to not be able to edit text that's 2 lines from your cursor.
Can I allow editing within those regions... I promise I'll be careful :)
Thanks.
Note: I don't want to lose code generation
If you open it in an external editor, there are two possibilities:
there is no guarantee that the changes you make will work (and not break anything) in the Netbeans UI Editor
The next time you edit the file in Netbeans it will be regenerated.
Either way, probably not what you want. The best thing to do would probably be to make the whole design up in the gui editor and when you are happy with it, delete the comments and continue on.
[sarcasm]
With the drag and drop gui editor, what could you possibly want to change by hand anyway?
[/sarcasm] ;)
If you open the .java files in Notepad or WordPad, you'll find pairs of comments that say
// GEN-BEGIN: <name of section>
...
// GEN-END: <name of section>
Delete those comments, and two things will happen.
You'll be able to edit anywhere in the file in NetBeans.
NetBeans will not be able to regenerate the file from the GUI editor.
So it can be done, but don't do it unless you really mean it.
EDIT: "Note: I don't want to lose code generation." Ok, let's see here.
You want to change what is generated.
You don't want to lose code generation.
You don't want to use the facilities NetBeans provides for adding custom code.
It sounds like you're wishing yourself trouble. :D
I had a same problem. I extended JPanel with my own panel class and I was not able to pack it with the rest of UI. First I searched the web and I found your question. I was not able to find elegant solution to this problem.
Therefore, I decided to create another java class and copy NetBeans created code into it. It worked like a charm.
I agree, it would be nice if we can modify existing code like in .NET.
I copy the initcomponents() method, create my own method newInitComponents() paste the generated code, and override what needs to be overridden before i distribute the code. That way when a change is made in the editor, you can still copy paste the code into your new method. You keep the functionality without costing you the ability to override where necessary. Just call newInitComponents() in your constructor rather than the original. This is not the most efficient way of doing things, but it does what you want.
You can also try moving the .form file in
(project name)\src\(name of JFrame/JPanel).form
NetBeans will now see it as a .java file.
If you did not edit anything necessary for the GUI editor, you can move the .form file back into the src folder.
Can you subclass the class and redefine the method where this code is? Of course then you'll have to maintain the method over time as you make changes to the GUI.
You can maybe also look into AspectJ. It will modify the byte-code at build time and make the changes you define. Not sure if this gives you enough control over what code to change.
If you use APT you can rewrite source code at compile time. This way you can overwrite the code that's there at the moment. You could keep the new code in the same Java file along with comments to explain what is going on. This tutorial makes it pretty easy to get started. Copy that code, get it working, then tweak it to your liking. To find out where in the code the annotated method is call getPosition() on the Declaration.
Go to design page and select any one of the fields. Right click on any selected field and choose Customizer Code , In Customizer Code change all default code to custom creation . Now you can edit your design code as you like...
Very simple... the crappy UTF-8 did not let me compile one JasperReport (everything done by GUI). So, I needed to change Project to iso-8859-1. Result? The project is messed up and some of the things to correct are in the blocked parts of the code. So, I really NEED to edit those automatically generated parts. When they are regenerated, they will be fine because the project is now iso-8859-1.
Step # 1 Close the project in NetBeans
Step # 2 Delete the .form file from the source directory of your project
Reopen the project and it will be editable now!