Some Monodevelop Code Completion Templates to Share

These are some that are missing (IMHO), so I thought I’d post them here. I’ll post more if I get the chance. I encourage others to post theirs as well.

How to get them to work is in this thread:

Generic GetComponent:

GetComponent <$type$>();

Instantiate:

$type$ $clone$ = ($type$)Instantiate($prefab$, $position$, $rotation$);

Require Component:

[RequireComponent (typeof ($type$))]

Singelton Support:

private static $type$ $id$;
	
//	Reference Support
//	This can be accessed with $id$.Instance.DoSomething();
//	This can be cached by declaring private $type$ $id$; 
//	 in Start() $id$ = $type$.Instance();
//	Once cached, requires function calls as: $id$.DoSomething ();

public static $type$ Instance () {
	 if (! $id$) {
		 $id$ = FindObjectOfType(typeof ($type$)) as $type$;
		 if (! $id$)
			 Debug.LogError ("There needs to be one active $type$ script on a GameObject in your scene.");
	}
	
	 return $id$;
}

Start Coroutine:

StartCoroutine($method$());

Using:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

Add Menu:

[AddComponentMenu ("$root$/$path$")]

Another handy snippet that doesn’t need variables can be:

[System.Serializable]

… now this will complete normally, but if we make it a snippet, it should complete in one step not two.

nice, are you using windows?
cloud you tell how to make generally mono completion (for unity things) work under it?
I have problems with it

No, unfortunately, on the Mac.

The main thing I’ve noticed with MD and Unity, is that it doesn’t support code completion for Unity.js (Unityscript, Javascript), and code folding is broken for Unity.js.

MD’s best support is for C#, and I’ve only been able to get it to complete and fold properly with C#.

ok, thanks.

yea I know mono does not support js, but for windows I use unitydev for js.

Yeah I’m also seeing a lot of weirdness with code completion for Monodevelop under Windows 7 x64. Anyone else seeing this?

C:\Users<UserName>\AppData\Roaming\MonoDevelop-Unity-2.8\Snippets\ ← templates here

Is there a way to pull in the current class name? Or current method name? I know in other IDEs, you can do that with code snippets.