Comments (4)
Actually, I think there should be a setting where you can configure the default visibility, as well as add other modifiers to the default, such as virtual. I would prefer my Unity methods to be "protected virtual" in most cases.
from vscode-unity-code-snippets.
Great suggestion!
I'm trying to create the "convention over configuration" pattern here, so the less you need to type when creating things, the better.
But maybe I can let them private by default, but the keyword editable (I think that most of the times (at least in my experience) you want to make them private).
There is not much options in VSCode snippets language, but I'll try to find something nice here.
(Sorry for the delay, I had no notification)
from vscode-unity-code-snippets.
Well, turns out we have plenty options to create the methods:
- their access can be
public
,private
orprotected
- they can be
virtual
or not Start()
for example can returnvoid
orIEnumerator
The VSCode snippets syntax is very limited and the only thing I could think about was to create options for each of the case, but this made the creation of a new method a long and boring process 😄 .
I created six alternatives to the problem (only for the Start()
method for now) and I'm open to suggestions. You can help me testing these alternatives opening the csharp snippets file (open command palette (ctrl+shift+P
) / Preferences: Configure User Snippets
/ csharp.json (C#)
) and pasting this piece of json:
{
"Test MonoBehaviour Start 1": {
"prefix": "start1",
"description": "Test #1",
"body": [
"${1:private} void Start() {",
"\t$0",
"}"
]
},
"Test MonoBehaviour Start 2": {
"prefix": "start2",
"description": "Test #2",
"body": [
"${1|private,protected,public|} void Start() {",
"\t$0",
"}"
]
},
"Test MonoBehaviour Start 3": {
"prefix": "start3",
"description": "Test #3",
"body": [
"${1|private,protected,public|} ${2| ,virtual |}void Start() {",
"\t$0",
"}"
]
},
"Test MonoBehaviour Start 4": {
"prefix": "start4",
"description": "Test #4",
"body": [
"${1|private,protected,public,protected virtual,public virtual|} void Start() {",
"\t$0",
"}"
]
},
"Test MonoBehaviour Start 5": {
"prefix": "start5",
"description": "Test #5",
"body": [
"${1|private,protected,public|} ${2| ,virtual |}${3|void,IEnumerator|} Start() {",
"\t$0",
"}"
]
},
"Test MonoBehaviour Start 6": {
"prefix": "start6",
"description": "Test #6",
"body": [
"${1|private,protected,public,protected virtual,public virtual|} ${2|void,IEnumerator|} Start() {",
"\t$0",
"}"
]
},
}
With that when you start typing start
the intellisense will suggest all the start*
options. Use each one and post here which you find out to be the best for your use. If none of them is good for you, please describe what would be the best option for you.
If you want to go back to the default snippets configuration, just delete all the text you copied from here.
from vscode-unity-code-snippets.
I'm reading about vscode extensions lately and maybe I can make some options to this one.
from vscode-unity-code-snippets.
Related Issues (20)
- Add bracket position option HOT 4
- Check existing text on line HOT 1
- Publish extension on Open-VSX, so it can be used in VSCodium, Gitpod HOT 3
- Trouble downloading from the website HOT 1
- Possibility to reorder these suggestions to the bottom of the list? HOT 2
- Add option to make open brackets in a new line HOT 10
- Add .gitignore snippet HOT 1
- Auto add parenthesis on static methods HOT 1
- Singleton shortcut. HOT 1
- Condition and Statement will add HOT 1
- Add [SerializeField] & [Serializable] or stuff like that :v HOT 2
- Remove parenthesis from method name found in prefixes.
- Error -1703 HOT 1
- Not Working HOT 1
- Suggestion: Add RequireComponent snippet HOT 1
- Suggestion: allow to remove the 'private' access modifier HOT 3
- Allow curly braces created in new line. HOT 4
- add singleton HOT 1
- SerializeField snippet HOT 1
- Spelling mistake in README.md
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-unity-code-snippets.