Skip to content

Commit 1f2c62a

Browse files
authored
Merge pull request #84 from arimger/develop
Develop - 0.12.4
2 parents 454c045 + c72f7f5 commit 1f2c62a

File tree

6 files changed

+59
-22
lines changed

6 files changed

+59
-22
lines changed

Assets/Editor Toolbox/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.12.4 [31.07.2023]
2+
3+
### Changed:
4+
- Fix SceneView selection tool behaviour when selecting nested prefabs
5+
- Fix InvalidOperationException when ExitGUIException is thrown inside PropertyScope
6+
- Minor SerializedScene index calculation performance improvements
7+
- Fix SearchablePopup styles initialization in Unity 2022+
8+
- Minor visual improvements on how ReferencePicker label is rendered
9+
110
## 0.12.3 [17.06.2023]
211

312
### Changed:

Assets/Editor Toolbox/Editor/Drawers/Toolbox/PropertySelf/ReferencePickerAttributeDrawer.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,16 @@ private void UpdateTypeProperty(SerializedProperty property, Type referenceType)
8080
property.serializedObject.ApplyModifiedProperties();
8181
}
8282

83-
private Rect PrepareTypePropertyPosition(in Rect labelPosition, in Rect inputPosition, bool isPropertyExpanded)
83+
private Rect PrepareTypePropertyPosition(bool hasLabel, in Rect labelPosition, in Rect inputPosition, bool isPropertyExpanded)
8484
{
8585
var position = new Rect(inputPosition);
86-
var baseLabelWidth = EditorGUIUtility.labelWidth + labelWidthOffset;
87-
var realLabelWidth = labelPosition.width;
88-
var labelWidth = Mathf.Max(baseLabelWidth, realLabelWidth);
86+
if (!hasLabel)
87+
{
88+
position.xMin += EditorGUIUtility.standardVerticalSpacing;
89+
return position;
90+
}
91+
92+
//skip row only if label exists
8993
if (isPropertyExpanded)
9094
{
9195
//property is expanded and we have place to move it to the next row
@@ -94,23 +98,28 @@ private Rect PrepareTypePropertyPosition(in Rect labelPosition, in Rect inputPos
9498
return position;
9599
}
96100

101+
var baseLabelWidth = EditorGUIUtility.labelWidth + labelWidthOffset;
102+
var realLabelWidth = labelPosition.width;
97103
//adjust position to already rendered label
98-
position.xMin += labelWidth;
104+
position.xMin += Mathf.Max(baseLabelWidth, realLabelWidth);
99105
return position;
100106
}
101107

102108

103109
protected override void OnGuiSafe(SerializedProperty property, GUIContent label, ReferencePickerAttribute attribute)
104110
{
105-
using (var propertyScope = new PropertyScope(property, label))
111+
//NOTE: we want to close scope manually because ExitGUIException can interrupt drawing and SerializedProperties stack
112+
using (var propertyScope = new PropertyScope(property, label, closeManually: true))
106113
{
107114
UpdateContexts(attribute);
108115

109116
var isPropertyExpanded = propertyScope.IsVisible;
110117
EditorGUI.indentLevel++;
111118
var labelRect = propertyScope.LabelRect;
112119
var inputRect = propertyScope.InputRect;
113-
var position = PrepareTypePropertyPosition(in labelRect, in inputRect, isPropertyExpanded);
120+
121+
var hasLabel = !string.IsNullOrEmpty(label.text);
122+
var position = PrepareTypePropertyPosition(hasLabel, in labelRect, in inputRect, isPropertyExpanded);
114123

115124
var parentType = GetParentType(property, attribute);
116125
CreateTypeProperty(position, property, parentType);
@@ -120,6 +129,7 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label,
120129
}
121130

122131
EditorGUI.indentLevel--;
132+
propertyScope.Close();
123133
}
124134
}
125135

Assets/Editor Toolbox/Editor/Internal/PropertyScope.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ namespace Toolbox.Editor.Internal
1212
internal class PropertyScope : IDisposable
1313
{
1414
private readonly SerializedProperty property;
15+
private readonly bool closeManually;
16+
private bool isClosed;
1517

18+
public PropertyScope(SerializedProperty property, GUIContent label) : this(property, label, false)
19+
{ }
1620

17-
public PropertyScope(SerializedProperty property, GUIContent label)
21+
public PropertyScope(SerializedProperty property, GUIContent label, bool closeManually)
1822
{
1923
this.property = property;
24+
this.closeManually = closeManually;
25+
isClosed = false;
26+
2027
ToolboxEditorGui.BeginProperty(property, ref label, out var rect);
2128
HandleEvents(rect);
2229
TryDrawLabel(rect, label);
@@ -50,9 +57,20 @@ private void TryDrawLabel(Rect rect, GUIContent label)
5057
}
5158

5259

53-
public void Dispose()
60+
public void Close()
5461
{
5562
ToolboxEditorGui.CloseProperty();
63+
isClosed = true;
64+
}
65+
66+
public void Dispose()
67+
{
68+
if (closeManually || isClosed)
69+
{
70+
return;
71+
}
72+
73+
Close();
5674
}
5775

5876

Assets/Editor Toolbox/Editor/Internal/SearchablePopup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,15 @@ static Style()
316316
toolbarStyle = new GUIStyle(EditorStyles.toolbar);
317317
scrollbarStyle = new GUIStyle(GUI.skin.verticalScrollbar);
318318
selectionStyle = new GUIStyle("SelectionRect");
319+
#if UNITY_2022_1_OR_NEWER
320+
searchBoxStyle = new GUIStyle("ToolbarSearchTextField");
321+
showCancelButtonStyle = new GUIStyle("ToolbarSearchCancelButton");
322+
hideCancelButtonStyle = new GUIStyle("ToolbarSearchCancelButtonEmpty");
323+
#else
319324
searchBoxStyle = new GUIStyle("ToolbarSeachTextField");
320325
showCancelButtonStyle = new GUIStyle("ToolbarSeachCancelButton");
321326
hideCancelButtonStyle = new GUIStyle("ToolbarSeachCancelButtonEmpty");
327+
#endif
322328
}
323329
}
324330
}

Assets/Editor Toolbox/Runtime/Serialization/SceneSerializationUtility.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#if UNITY_EDITOR
44
using UnityEditor;
55
#endif
6+
using UnityEngine.SceneManagement;
67

78
namespace Toolbox.Serialization
89
{
@@ -40,37 +41,30 @@ internal static void ConfirmCache()
4041
internal static void RefreshCache()
4142
{
4243
cachedScenes.Clear();
43-
var buildIndex = -1;
4444
foreach (var scene in EditorBuildSettings.scenes)
4545
{
46-
if (string.IsNullOrEmpty(scene.path))
46+
var path = scene.path;
47+
if (string.IsNullOrEmpty(path))
4748
{
4849
continue;
4950
}
5051

51-
var sceneAsset = EditorGUIUtility.Load(scene.path) as SceneAsset;
52+
var sceneAsset = EditorGUIUtility.Load(path) as SceneAsset;
5253
if (sceneAsset == null)
5354
{
5455
continue;
5556
}
5657

57-
var sceneIndex = InvalidSceneIndex;
58-
if (scene.enabled)
59-
{
60-
buildIndex++;
61-
sceneIndex = buildIndex;
62-
}
63-
6458
if (cachedScenes.ContainsKey(sceneAsset))
6559
{
6660
continue;
6761
}
6862

6963
cachedScenes.Add(sceneAsset, new SceneData()
7064
{
71-
BuildIndex = sceneIndex,
65+
BuildIndex = SceneUtility.GetBuildIndexByScenePath(path),
7266
SceneName = sceneAsset.name,
73-
ScenePath = scene.path
67+
ScenePath = path
7468
});
7569
}
7670
}

Assets/Editor Toolbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.browar.editor-toolbox",
33
"displayName": "Editor Toolbox",
4-
"version": "0.12.3",
4+
"version": "0.12.4",
55
"unity": "2018.1",
66
"description": "Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.",
77
"keywords": [

0 commit comments

Comments
 (0)