Skip to content

Commit 6213ea4

Browse files
committed
Add support to Unity 2021.2
1 parent 73279bb commit 6213ea4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Editor/ScriptTemplatesEditor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,17 @@ void DrawTemplateView()
109109
};
110110
listView.bindItem = (element, i) => (element as ObjectField).SetValueWithoutNotify(templates[i]);
111111
listView.itemsSource = templates;
112+
#if UNITY_2021_2_OR_NEWER
113+
listView.fixedItemHeight = 20;
114+
#else
112115
listView.itemHeight = 20;
116+
#endif
113117
listView.selectionType = SelectionType.Single;
118+
#if UNITY_2021_2_OR_NEWER
119+
listView.onSelectionChange += selection => Selection.activeObject = (Object)selection.FirstOrDefault();
120+
#else
114121
listView.onSelectionChanged += selection => Selection.activeObject = (Object)selection.FirstOrDefault();
122+
#endif
115123

116124
var projectButton = rootVisualElement.Q<Button>("copy-project-button");
117125
projectButton.clicked += () =>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.myunitytools.scripttemplate",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"displayName": "My Unity Tools - Script Templates",
55
"description": "This tool adds custom Script Templates to Unity that will serve as alternatives for the default \"C#Script\" that I personally always modify before writing my scripts.\nIn essence, it adds a signature header on every script with your name, email and creation date. \nAdditionally, it adds templates for others types of scripts rather than just Mono Behaviours.",
66
"unity": "2019.4",

0 commit comments

Comments
 (0)