Skip to content

Commit f49b111

Browse files
authored
Merge pull request #13 from Jubessin/2.2.1
small patch
2 parents 417265d + 81728d1 commit f49b111

File tree

7 files changed

+74
-7
lines changed

7 files changed

+74
-7
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.2.1] --- 2023-04-15
11+
12+
### Changed
13+
14+
- RequireTag enforcer now checks if tag is built-in
15+
- added additional test for require tag attribute
16+
- address issue with closing editor window using 'ESC' key
17+
- address issue with editor window throwing error after compiling changes
18+
- update package dependencies
19+
1020
## [2.2.0] --- 2023-02-21
1121

1222
### Added

Editor/Editor Window/ClassAttributeEnforcerEditorWindow.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ internal sealed class ClassAttributeEnforcerEditorWindow : EditorWindow, ICustom
1515
{
1616
#region Fields
1717

18+
private int?
19+
selectionWindowID,
20+
configurationWindowID;
21+
1822
private Panel
1923
panel1,
2024
panel2;
@@ -127,11 +131,17 @@ void ICustomEditorWindow.RemoveFocusable(Rect rect) { }
127131

128132
private void OnGUI()
129133
{
130-
HandleEvent();
134+
HandleEvent(out bool close);
135+
136+
if (close)
137+
return;
138+
131139
HandleWindow();
132140

133-
void HandleEvent()
141+
void HandleEvent(out bool close)
134142
{
143+
close = false;
144+
135145
var evt = Event.current;
136146

137147
if (evt == null)
@@ -143,6 +153,8 @@ void HandleEvent()
143153
if (evt.keyCode == KeyCode.Escape)
144154
{
145155
Close();
156+
157+
close = true;
146158
}
147159
}
148160
void HandleWindow()
@@ -153,8 +165,19 @@ void HandleWindow()
153165
BeginWindows();
154166

155167
// Invoke OnPanelGUI on both panels, supplying the rect that will serve as their bounds.
156-
GUI.Window(1, panel1WindowRect, (_) => panel1.OnPanelGUI(panel1Size), "", EditorStyles.inspectorDefaultMargins);
157-
GUI.Window(2, panel2WindowRect, (_) => panel2.OnPanelGUI(panel2Size), "", EditorStyles.inspectorDefaultMargins);
168+
GUI.Window(
169+
selectionWindowID ??= GenerateUniqueSessionID(),
170+
panel1WindowRect,
171+
(_) => panel1.OnPanelGUI(panel1Size),
172+
"",
173+
EditorStyles.inspectorDefaultMargins);
174+
175+
GUI.Window(
176+
configurationWindowID ??= GenerateUniqueSessionID(),
177+
panel2WindowRect,
178+
(_) => panel2.OnPanelGUI(panel2Size),
179+
"",
180+
EditorStyles.inspectorDefaultMargins);
158181

159182
EndWindows();
160183

Editor/RequireTagClassAttributeEnforcer.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ private static void OnHierarchyChanged()
169169
Utilities.ApplyAttributeToSelectedGameObject(typesWithAttribute, ApplyAttribute);
170170
}
171171

172+
private static bool IsBuiltIn(string tag) =>
173+
tag == "Untagged" ||
174+
tag == "Respawn" ||
175+
tag == "Finish" ||
176+
tag == "EditorOnly" ||
177+
tag == "MainCamera" ||
178+
tag == "Player" ||
179+
tag == "GameController";
180+
172181
private static void ApplyAttribute(GameObject gameObject, Attribute attribute)
173182
{
174183
if (!(attribute is RequireTagAttribute attr))
@@ -177,6 +186,13 @@ private static void ApplyAttribute(GameObject gameObject, Attribute attribute)
177186
if (gameObject.tag == attr.tag)
178187
return;
179188

189+
if (IsBuiltIn(attr.tag))
190+
{
191+
gameObject.tag = attr.tag;
192+
193+
return;
194+
}
195+
180196
var asset = AssetDatabase.LoadAssetAtPath<UnityObject>("ProjectSettings/TagManager.asset");
181197

182198
var tagManagerObject = new SerializedObject(asset);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ Unity package used in the development of Ikonoclast projects, containing a set o
2020

2121
This package has dependencies. To use this package, add the following to the manifest.json file found under Assets > Packages:
2222

23-
* `"com.ikonoclast.common" : "https://github.com/Jubessin/com.ikonoclast.common.git#3.0.0"`
23+
* `"com.ikonoclast.common" : "https://github.com/Jubessin/com.ikonoclast.common.git#3.1.0"`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using UnityEngine;
2+
3+
namespace Ikonoclast.ClassAttributes.Tests
4+
{
5+
[RequireTag("Player")]
6+
internal class RequireBuiltInTagTest : MonoBehaviour { }
7+
}

Tests/Runtime/RequireBuiltInTagTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"license": "MIT",
33
"unity": "2020.3",
4-
"version": "2.2.0",
4+
"version": "2.2.1",
55
"author": {
66
"name": "Jubessin",
77
"url": "https://github.com/Jubessin"
@@ -13,6 +13,6 @@
1313
],
1414
"description": "Unity package used in the development of Ikonoclast projects, containing a set of attributes that can be configured, applied to classes, and enforced when the project loads or the hierarchy changes.",
1515
"dependencies": {
16-
"com.ikonoclast.common": "3.0.0"
16+
"com.ikonoclast.common": "3.1.0"
1717
}
1818
}

0 commit comments

Comments
 (0)