Skip to content

Commit 4030355

Browse files
authored
Merge pull request #34 from arimger/develop
Develop - 0.10.8
2 parents 593d5cf + 2fbad52 commit 4030355

File tree

85 files changed

+375
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+375
-129
lines changed

Assets/Editor Toolbox/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 0.10.8 [26.02.2022]
2+
3+
### Added:
4+
- [Conditional("UNITY_EDITOR")] attribute to all drawer attributes
5+
- Possibility to ignore certain properties directly in the ToolboxEditor OnGUI callback
6+
7+
### Changed:
8+
- Resizing "Size" field in the ReorderableLists depending on the content
9+
- Serializing Scene name in the SerializedScene class
10+
- Optimization of types caching (mostly related to the SerializedType class)
11+
112
## 0.10.6 [30.11.2021]
213

314
### Added:

Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public abstract class ReorderableListBase
5252

5353

5454
protected const string defaultLabelFormat = "{0} {1}";
55+
protected const string defaultElementName = "Element";
5556

5657
/// <summary>
5758
/// Hotcontrol index, unique for this instance.
@@ -408,7 +409,7 @@ protected virtual void HandleHeaderEvents(Rect rect)
408409

409410
public string GetElementDefaultName(int index)
410411
{
411-
return string.Format(defaultLabelFormat, "Element", index);
412+
return string.Format(defaultLabelFormat, defaultElementName, index);
412413
}
413414

414415
public string GetElementDefinedName(int index)
@@ -621,20 +622,22 @@ public virtual void DrawStandardHeader(Rect rect)
621622
var label = EditorGUI.BeginProperty(rect, TitleLabel, List);
622623
//display the property label using the preprocessed name
623624
DrawStandardName(rect, label, Foldable);
624-
625-
var diff = rect.height - Style.sizePropertyStyle.fixedHeight;
626-
rect.yMin += diff / 2;
627-
rect.yMax -= diff / 2;
628-
rect.xMin = rect.xMax - Style.sizeAreaWidth;
629-
630625
using (new EditorGUI.DisabledScope(FixedSize))
631626
{
632627
var property = Size;
628+
var sizeValue = property.intValue;
629+
630+
var potentialSizeContent = new GUIContent(sizeValue.ToString());
631+
var width = Style.sizePropertyStyle.CalcSize(potentialSizeContent).x;
632+
var diff = rect.height - Style.sizePropertyStyle.fixedHeight;
633+
rect.yMin += diff / 2;
634+
rect.yMax -= diff / 2;
635+
rect.xMin = rect.xMax - Mathf.Max(Style.sizeAreaWidth, width);
633636

634637
EditorGUI.BeginProperty(rect, Style.sizePropertyContent, property);
635638
EditorGUI.BeginChangeCheck();
636639
//cache the size value using the delayed int field
637-
var sizeValue = Mathf.Max(EditorGUI.DelayedIntField(rect, property.intValue, Style.sizePropertyStyle), 0);
640+
sizeValue = Mathf.Max(EditorGUI.DelayedIntField(rect, sizeValue, Style.sizePropertyStyle), 0);
638641
if (EditorGUI.EndChangeCheck())
639642
{
640643
property.intValue = sizeValue;
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "Toolbox-Editor",
2+
"name": "Toolbox.Editor",
3+
"rootNamespace": "",
34
"references": [
45
"Toolbox",
56
"Unity.EditorCoroutines.Editor"
67
],
7-
"optionalUnityReferences": [],
88
"includePlatforms": [
99
"Editor"
1010
],
@@ -13,5 +13,7 @@
1313
"overrideReferences": false,
1414
"precompiledReferences": [],
1515
"autoReferenced": true,
16-
"defineConstraints": []
16+
"defineConstraints": [],
17+
"versionDefines": [],
18+
"noEngineReferences": false
1719
}
File renamed without changes.

Assets/Editor Toolbox/Editor/ToolboxEditor.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23

34
using UnityEditor;
45

@@ -14,6 +15,9 @@ namespace Toolbox.Editor
1415
[CanEditMultipleObjects]
1516
public class ToolboxEditor : Editor
1617
{
18+
private readonly HashSet<string> propertiesToIgnore = new HashSet<string>();
19+
20+
1721
/// <summary>
1822
/// Inspector GUI re-draw call.
1923
/// </summary>
@@ -37,13 +41,18 @@ public override sealed void OnInspectorGUI()
3741
}
3842
}
3943

40-
4144
/// <summary>
4245
/// Handles property display process using custom <see cref="Drawers.ToolboxDrawer"/>.
4346
/// </summary>
4447
/// <param name="property">Property to display.</param>
4548
public virtual void DrawCustomProperty(SerializedProperty property)
4649
{
50+
var propertyPath = property.propertyPath;
51+
if (propertiesToIgnore.Contains(propertyPath))
52+
{
53+
return;
54+
}
55+
4756
ToolboxEditorGui.DrawToolboxProperty(property);
4857
}
4958

@@ -85,6 +94,22 @@ public virtual void DrawCustomInspector()
8594
DrawDefaultInspector();
8695
}
8796

97+
/// <summary>
98+
/// Forces provided <see cref="SerializedProperty"/> to be ignored in the drawing process.
99+
/// </summary>
100+
public void IgnoreProperty(SerializedProperty property)
101+
{
102+
IgnoreProperty(property.propertyPath);
103+
}
104+
105+
/// <summary>
106+
/// Forces associated <see cref="SerializedProperty"/> to be ignored in the drawing process.
107+
/// </summary>
108+
public void IgnoreProperty(string propertyPath)
109+
{
110+
propertiesToIgnore.Add(propertyPath);
111+
}
112+
88113

89114
public static event Action<Editor> OnBeginToolboxEditor;
90115
public static event Action<Editor> OnBreakToolboxEditor;

Assets/Editor Toolbox/EditorSettings.asset

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,44 +48,45 @@ MonoBehaviour:
4848
iconName:
4949
useToolboxDrawers: 1
5050
decoratorDrawerHandlers:
51-
- classReference: Toolbox.Editor.Drawers.BeginGroupAttributeDrawer, Toolbox-Editor
52-
- classReference: Toolbox.Editor.Drawers.BeginHorizontalAttributeDrawer, Toolbox-Editor
53-
- classReference: Toolbox.Editor.Drawers.BeginHorizontalGroupAttributeDrawer, Toolbox-Editor
54-
- classReference: Toolbox.Editor.Drawers.BeginIndentAttributeDrawer, Toolbox-Editor
55-
- classReference: Toolbox.Editor.Drawers.DynamicHelpAttributeDrawer, Toolbox-Editor
56-
- classReference: Toolbox.Editor.Drawers.EditorButtonAttributeDrawer, Toolbox-Editor
57-
- classReference: Toolbox.Editor.Drawers.EndGroupAttributeDrawer, Toolbox-Editor
58-
- classReference: Toolbox.Editor.Drawers.EndHorizontalAttributeDrawer, Toolbox-Editor
59-
- classReference: Toolbox.Editor.Drawers.EndHorizontalGroupAttributeDrawer, Toolbox-Editor
60-
- classReference: Toolbox.Editor.Drawers.EndIndentAttributeDrawer, Toolbox-Editor
61-
- classReference: Toolbox.Editor.Drawers.GuiColorAttributeDrawer, Toolbox-Editor
62-
- classReference: Toolbox.Editor.Drawers.HelpAttributeDrawer, Toolbox-Editor
63-
- classReference: Toolbox.Editor.Drawers.HighlightAttributeDrawer, Toolbox-Editor
64-
- classReference: Toolbox.Editor.Drawers.ImageAreaAttributeDrawer, Toolbox-Editor
65-
- classReference: Toolbox.Editor.Drawers.IndentAreaAttributeDrawer, Toolbox-Editor
66-
- classReference: Toolbox.Editor.Drawers.LabelAttributeDrawer, Toolbox-Editor
67-
- classReference: Toolbox.Editor.Drawers.LineAttributeDrawer, Toolbox-Editor
68-
- classReference: Toolbox.Editor.Drawers.SpaceAreaAttributeDrawer, Toolbox-Editor
51+
- classReference: Toolbox.Editor.Drawers.BeginGroupAttributeDrawer, Toolbox.Editor
52+
- classReference: Toolbox.Editor.Drawers.BeginHorizontalAttributeDrawer, Toolbox.Editor
53+
- classReference: Toolbox.Editor.Drawers.BeginHorizontalGroupAttributeDrawer, Toolbox.Editor
54+
- classReference: Toolbox.Editor.Drawers.BeginIndentAttributeDrawer, Toolbox.Editor
55+
- classReference: Toolbox.Editor.Drawers.DynamicHelpAttributeDrawer, Toolbox.Editor
56+
- classReference: Toolbox.Editor.Drawers.EditorButtonAttributeDrawer, Toolbox.Editor
57+
- classReference: Toolbox.Editor.Drawers.EndGroupAttributeDrawer, Toolbox.Editor
58+
- classReference: Toolbox.Editor.Drawers.EndHorizontalAttributeDrawer, Toolbox.Editor
59+
- classReference: Toolbox.Editor.Drawers.EndHorizontalGroupAttributeDrawer, Toolbox.Editor
60+
- classReference: Toolbox.Editor.Drawers.EndIndentAttributeDrawer, Toolbox.Editor
61+
- classReference: Toolbox.Editor.Drawers.GuiColorAttributeDrawer, Toolbox.Editor
62+
- classReference: Toolbox.Editor.Drawers.HelpAttributeDrawer, Toolbox.Editor
63+
- classReference: Toolbox.Editor.Drawers.HighlightAttributeDrawer, Toolbox.Editor
64+
- classReference: Toolbox.Editor.Drawers.ImageAreaAttributeDrawer, Toolbox.Editor
65+
- classReference: Toolbox.Editor.Drawers.IndentAreaAttributeDrawer, Toolbox.Editor
66+
- classReference: Toolbox.Editor.Drawers.LabelAttributeDrawer, Toolbox.Editor
67+
- classReference: Toolbox.Editor.Drawers.LineAttributeDrawer, Toolbox.Editor
68+
- classReference: Toolbox.Editor.Drawers.SpaceAreaAttributeDrawer, Toolbox.Editor
6969
conditionDrawerHandlers:
70-
- classReference: Toolbox.Editor.Drawers.DisableAttributeDrawer, Toolbox-Editor
71-
- classReference: Toolbox.Editor.Drawers.DisableIfAttributeDrawer, Toolbox-Editor
72-
- classReference: Toolbox.Editor.Drawers.DisableInPlayModeAttributeDrawer, Toolbox-Editor
73-
- classReference: Toolbox.Editor.Drawers.EnableIfAttributeDrawer, Toolbox-Editor
74-
- classReference: Toolbox.Editor.Drawers.HideAttributeDrawer, Toolbox-Editor
75-
- classReference: Toolbox.Editor.Drawers.HideDisabledIfAttributeDrawer, Toolbox-Editor
76-
- classReference: Toolbox.Editor.Drawers.HideIfAttributeDrawer, Toolbox-Editor
77-
- classReference: Toolbox.Editor.Drawers.ShowDisabledIfAttributeDrawer, Toolbox-Editor
78-
- classReference: Toolbox.Editor.Drawers.ShowIfAttributeDrawer, Toolbox-Editor
79-
- classReference: Toolbox.Editor.Drawers.ShowWarningIfAttributeDrawer, Toolbox-Editor
70+
- classReference: Toolbox.Editor.Drawers.DisableAttributeDrawer, Toolbox.Editor
71+
- classReference: Toolbox.Editor.Drawers.DisableIfAttributeDrawer, Toolbox.Editor
72+
- classReference: Toolbox.Editor.Drawers.DisableInPlayModeAttributeDrawer, Toolbox.Editor
73+
- classReference: Toolbox.Editor.Drawers.EnableIfAttributeDrawer, Toolbox.Editor
74+
- classReference: Toolbox.Editor.Drawers.HideAttributeDrawer, Toolbox.Editor
75+
- classReference: Toolbox.Editor.Drawers.HideDisabledIfAttributeDrawer, Toolbox.Editor
76+
- classReference: Toolbox.Editor.Drawers.HideIfAttributeDrawer, Toolbox.Editor
77+
- classReference: Toolbox.Editor.Drawers.ShowDisabledIfAttributeDrawer, Toolbox.Editor
78+
- classReference: Toolbox.Editor.Drawers.ShowIfAttributeDrawer, Toolbox.Editor
79+
- classReference: Toolbox.Editor.Drawers.ShowWarningIfAttributeDrawer, Toolbox.Editor
8080
selfPropertyDrawerHandlers:
81-
- classReference: Toolbox.Editor.Drawers.DynamicMinMaxSliderAttributeDrawer, Toolbox-Editor
82-
- classReference: Toolbox.Editor.Drawers.DynamicRangeAttributeDrawer, Toolbox-Editor
83-
- classReference: Toolbox.Editor.Drawers.IgnoreParentAttributeDrawer, Toolbox-Editor
84-
- classReference: Toolbox.Editor.Drawers.InLineEditorAttributeDrawer, Toolbox-Editor
85-
- classReference: Toolbox.Editor.Drawers.RegexValueAttributeDrawer, Toolbox-Editor
81+
- classReference: Toolbox.Editor.Drawers.DynamicMinMaxSliderAttributeDrawer, Toolbox.Editor
82+
- classReference: Toolbox.Editor.Drawers.DynamicRangeAttributeDrawer, Toolbox.Editor
83+
- classReference: Toolbox.Editor.Drawers.IgnoreParentAttributeDrawer, Toolbox.Editor
84+
- classReference: Toolbox.Editor.Drawers.InLineEditorAttributeDrawer, Toolbox.Editor
85+
- classReference: Toolbox.Editor.Drawers.RegexValueAttributeDrawer, Toolbox.Editor
8686
listPropertyDrawerHandlers:
87-
- classReference: Toolbox.Editor.Drawers.ReorderableListAttributeDrawer, Toolbox-Editor
87+
- classReference: Toolbox.Editor.Drawers.ReorderableListAttributeDrawer, Toolbox.Editor
8888
- classReference: Toolbox.Editor.Drawers.ReorderableListExposedAttributeDrawer,
89-
Toolbox-Editor
90-
- classReference: Toolbox.Editor.Drawers.ScrollableItemsAttributeDrawer, Toolbox-Editor
91-
targetTypeDrawerHandlers: []
89+
Toolbox.Editor
90+
- classReference: Toolbox.Editor.Drawers.ScrollableItemsAttributeDrawer, Toolbox.Editor
91+
targetTypeDrawerHandlers:
92+
- classReference: Toolbox.Editor.Drawers.SerializedDictionaryDrawer, Toolbox.Editor

Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/AssetPreviewAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
namespace UnityEngine
45
{
@@ -8,6 +9,7 @@ namespace UnityEngine
89
/// <para>Supported types: any <see cref="Object"/>.</para>
910
/// </summary>
1011
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
12+
[Conditional("UNITY_EDITOR")]
1113
public class AssetPreviewAttribute : PropertyAttribute
1214
{
1315
public AssetPreviewAttribute(float width = 64, float height = 64, bool useLabel = true)

Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ChildObjectOnlyAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
namespace UnityEngine
45
{
@@ -8,6 +9,7 @@ namespace UnityEngine
89
/// <para>Supported types: <see cref="GameObject"/> and any <see cref="Component"/>.</para>
910
/// </summary>
1011
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
12+
[Conditional("UNITY_EDITOR")]
1113
public class ChildObjectOnlyAttribute : PropertyAttribute
1214
{ }
1315
}

Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ClampAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
namespace UnityEngine
45
{
@@ -8,6 +9,7 @@ namespace UnityEngine
89
/// <para>Supported types: <see cref="int"/>, <see cref="float"/>, <see cref="double"/>.</para>
910
/// </summary>
1011
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
12+
[Conditional("UNITY_EDITOR")]
1113
public class ClampAttribute : PropertyAttribute
1214
{
1315
public ClampAttribute(float minValue, float maxValue)

Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/DirectoryAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23

34
namespace UnityEngine
45
{
@@ -8,6 +9,7 @@ namespace UnityEngine
89
/// <para>Supported types: <see cref="string"/>.</para>
910
/// </summary>
1011
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
12+
[Conditional("UNITY_EDITOR")]
1113
public class DirectoryAttribute : PropertyAttribute
1214
{
1315
/// <param name="relativePath">Relative path from ProjectName/Assets directory</param>

0 commit comments

Comments
 (0)