Skip to content

Instantly share code, notes, and snippets.

@barleymalt
Last active February 3, 2023 11:41
Show Gist options
  • Save barleymalt/2ed8a690a76ea4093d775a10ee87d979 to your computer and use it in GitHub Desktop.
Save barleymalt/2ed8a690a76ea4093d775a10ee87d979 to your computer and use it in GitHub Desktop.
Rider Live Templates
=================================================================
A LIST OF LIVE TEMPLATES FOR UNITY
TO MAKE THINGS EASIER, OR JUST BECAUSE, WHY NOT?
==================================================================
==================================================================
UNITY
==================================================================
------------------------------------------------------------------
:customeditor: [create a custom editor nested inside a class file]
------------------------------------------------------------------
$TYPE$ macro: current file without extension
#if UNITY_EDITOR
[CustomEditor(typeof($TYPE$))]
public class $TYPE$_Editor : UnityEditor.Editor
{
$TYPE$ script;
private void OnEnable()
{
script = ($TYPE$)target;
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
}
}
#endif
------------------------------------------------------------------
:persistent_bool: [create a bool variable saved in the player prefs]
------------------------------------------------------------------
$PREFS_VAR_NAME$ macro: value of $VAR_NAME$ with the first letter uppercase
private bool $VAR_NAME$
{
get => PlayerPrefs.GetInt("$PREFS_VAR_NAME$") == 1;
set => PlayerPrefs.SetInt("$PREFS_VAR_NAME$", value ? 1 : 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment