Skip to content

Latest commit

 

History

History
170 lines (111 loc) · 3.02 KB

README.md

File metadata and controls

170 lines (111 loc) · 3.02 KB

Snippets for Visual Studio

Place snippet files to the snippet folder in addition to existing ones.
For example for vs 2022 it is:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC#\Snippets\1033\Visual C#\

Common C# Snippets

Method

void MyMethod()
{
    throw new System.NotImplementedException();
}

Deconstructor

public void Deconstruct()
{

}

Yield return

yield return null;

fixed

fixed (void* ptr = value)
{

}

StructLayout

[StructLayout(LayoutKind.Sequential, Pack = 1)]

MethodImpl

[MethodImpl(MethodImplOptions.AggressiveInlining)]

For Unity

Debug.Log();

Debug.Log();

SerializeField

[SerializeField]

SerializeReference

[SerializeReference]

UnityObject

using UnityObject = UnityEngine.Object;

#if UNITY_EDITOR

#if UNITY_EDITOR

#endif

#if UNITY_EDITOR || DEVELOPMENT_BUILD

#if UNITY_EDITOR || DEVELOPMENT_BUILD

#endif

OnValidate + Reset

#if UNITY_EDITOR
    private void OnValidate()
    {
        ValidateData();
    }

    private void Reset()
    {
        ValidateData();
    }

    private void ValidateData()
    {

    }
#endif

CustomEditor

[CustomEditor(typeof(ExampleClass))]

CustomPropertyDrawer

[CustomPropertyDrawer(typeof(CustomType))]

MethodButtonsEditor

Used for InspectorButtonAttribute from https://github.com/oleghcp/UnityTools

#if UNITY_EDITOR
    [UnityEditor.CustomEditor(typeof(ExampleClass)), UnityEditor.CanEditMultipleObjects]
    private class Editor : OlegHcpEditor.MethodButtonsEditor { }
#endif