Giter Site home page Giter Site logo

Comments (4)

dantonel avatar dantonel commented on June 15, 2024 1

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.

kleber-swf avatar kleber-swf commented on June 15, 2024

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.

kleber-swf avatar kleber-swf commented on June 15, 2024

Well, turns out we have plenty options to create the methods:

  • their access can be public, private or protected
  • they can be virtual or not
  • Start() for example can return void or IEnumerator

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.

kleber-swf avatar kleber-swf commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.