How to add autocomplete for common functions such as "Start" and "Update",

Monodevelop can auto-populate code, but it cannot auto-populate key functions like Start , Update , FixedUpdate , OnCollisionEnter , etc., so I often skip key functions.

Is there a way to add autocomplete or spell check entries for these common features?

+6
source share
4 answers

While you cannot create AutoCorrect entries in MonoDevelop, you can create code snippets (called code templates in MonoDevelop).

A code snippet is a piece of code that is created automatically when you enter an identifier string (for example, start) and the hit tab. It can be a function, property, bit of a template that you always started writing (for example, GetComponent calls). It even appears in the AutoCorrect list.

The code snippets are quite powerful and even allow you to enter a tab above the template and easily and quickly change important things, such as types and variable names.

Just create a code snippet (MonoDevelop-> Tools β†’ Options β†’ Text Editor β†’ Code Templates-> Add) for each of the elements that usually cause problems.

+3
source

Well, you can use Unity Snippets for MonoDevelop for your problem. It has many useful snippets, it works great. When the code snippet code appears, press the Tab key twice to insert the template.

Image

Download Unity.template.xml and create a folder called Snippets inside C: \ Users {your_pc_name_here} \ AppData \ Roaming \ MonoDevelop-Unity-5.0 (or in Windows Press Win + R β†’% appdata%) and copy this file to this folder . When you restart Monodevelop, code fragments will work.

+1
source

As Andrei said, I believe that Unity accesses these methods using a naming convention and signature, rather than using a compile time identifier.

What you can do is define an interface that represents these methods:

 public interface IStart { void Start(); } public interface IUpdate { void Update(); } 

Then in your script classes, you can inherit from the interfaces you are going to implement:

 public class MyScript : MonoBehaviour, IStart, IUpdate { public void Start() { } public void Update() { } } 

The disadvantage is that these methods become public . I have never tried, but I assume that Unity will support these methods, implemented using an explicit interface implementation , which can help hide these method calls from the regular API access:

 public class MyScript : MonoBehaviour, IStart, IUpdate { void IStart.Start() { } void IUpdate.Update() { } } 

After you have this, if you seal the method signature, you will get a compiler error.

As an added bonus, I don't know if MonoDevelop has this parameter, but in Visual Studio, when you add interface inheritance to the class declaration, you get a context parameter so that Visual Studio automatically implements the interface method signatures (implicitly or explicitly).

0
source

this problem takes me hours and does not fix the end of ant. BUT, I found out that we can integrate the Microsoft Visual Studio IDE IDE just with Unity from version 5.5. no more plugins are required and is easily installed as a standard IDE by default in the settings. then you need to install the single fragments plugin by searching in it as an extension, and then everything will be done.

0
source

Source: https://habr.com/ru/post/970033/


All Articles