Skip to content

Commit acfa0ba

Browse files
authored
Merge pull request #112 from arimger/develop
Develop - 0.12.12
2 parents 4985b2f + 124f866 commit acfa0ba

File tree

204 files changed

+454
-144
lines changed

Some content is hidden

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

204 files changed

+454
-144
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.12.12 [17.06.2024]
2+
3+
### Changed:
4+
- LabelWidthAttribute is now part of the Toolbox decorator attributes (can be mixed with other attributes)
5+
- Hierarchy: Script, Tag, and Layer columns are now excluded from the default settings
6+
- Possibility to change style for groups ([BeginGroup] and [BeginHorizontalGroup] attributes)
7+
- ScriptableObject Creation Wizard now accepts only ScriptableObjects marked with the [CreateInWizard] or [CreateAssetMenu] attributes
8+
9+
### Added:
10+
- NotPrefabObjectOnlyAttribute
11+
112
## 0.12.11 [05.04.2024]
213

314
### Changed:

Assets/Editor Toolbox/Editor/Drawers/Regular/LabelWidthAttributeDrawer.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

Assets/Editor Toolbox/Editor/Drawers/Regular/NotNullAttributeDrawer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,13 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU
4141
}
4242
}
4343

44-
4544
public override bool IsPropertyValid(SerializedProperty property)
4645
{
4746
return property.propertyType == SerializedPropertyType.ObjectReference;
4847
}
4948

50-
5149
private NotNullAttribute Attribute => attribute as NotNullAttribute;
5250

53-
5451
private static class Style
5552
{
5653
#if UNITY_2019_3_OR_NEWER
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace Toolbox.Editor.Drawers
5+
{
6+
[CustomPropertyDrawer(typeof(NotPrefabObjectOnlyAttribute))]
7+
public class NotPrefabObjectOnlyAttributeDrawer : ObjectValidationDrawer
8+
{
9+
protected override string GetWarningMessage()
10+
{
11+
return "Assigned object can't be a Prefab.";
12+
}
13+
14+
protected override bool IsObjectValid(Object objectValue, SerializedProperty property)
15+
{
16+
if (objectValue == null)
17+
{
18+
return false;
19+
}
20+
21+
var attribute = Attribute;
22+
if (PrefabUtility.GetPrefabAssetType(objectValue) == PrefabAssetType.NotAPrefab)
23+
{
24+
return true;
25+
}
26+
27+
if (PrefabUtility.GetPrefabInstanceStatus(objectValue) == PrefabInstanceStatus.Connected &&
28+
attribute.AllowInstancedPrefabs)
29+
{
30+
return true;
31+
}
32+
33+
return false;
34+
}
35+
36+
private NotPrefabObjectOnlyAttribute Attribute => attribute as NotPrefabObjectOnlyAttribute;
37+
}
38+
}

Assets/Editor Toolbox/Editor/Drawers/Regular/NotPrefabObjectOnlyAttributeDrawer.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.

Assets/Editor Toolbox/Editor/Drawers/Regular/ObjectValidationDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ protected virtual string GetWarningMessage()
3434

3535
protected abstract bool IsObjectValid(Object objectValue, SerializedProperty property);
3636

37-
3837
public override bool IsPropertyValid(SerializedProperty property)
3938
{
4039
return property.propertyType == SerializedPropertyType.ObjectReference;

Assets/Editor Toolbox/Editor/Drawers/Regular/SceneNameAttributeDrawer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ private void HandleTargetPicker(Rect position, SerializedProperty property)
6363
}
6464
}
6565

66-
6766
protected override float GetPropertyHeightSafe(SerializedProperty property, GUIContent label)
6867
{
6968
return SceneExists(property.stringValue)
@@ -88,13 +87,11 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU
8887
HandleTargetPicker(position, property);
8988
}
9089

91-
9290
public override bool IsPropertyValid(SerializedProperty property)
9391
{
9492
return property.propertyType == SerializedPropertyType.String;
9593
}
9694

97-
9895
private static class Style
9996
{
10097
internal static readonly float rowHeight = EditorGUIUtility.singleLineHeight;

Assets/Editor Toolbox/Editor/Drawers/Regular/SceneObjectOnlyAttributeDrawer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ private GameObject GetGameObject(Object reference)
1919
return null;
2020
}
2121

22-
2322
protected override string GetWarningMessage()
2423
{
2524
return "Assigned object has to be instantiated in the Scene.";
@@ -28,7 +27,7 @@ protected override string GetWarningMessage()
2827
protected override bool IsObjectValid(Object objectValue, SerializedProperty property)
2928
{
3029
var gameObject = GetGameObject(objectValue);
31-
return gameObject && !string.IsNullOrEmpty(gameObject.scene.name);
30+
return gameObject != null && !string.IsNullOrEmpty(gameObject.scene.name);
3231
}
3332
}
3433
}

Assets/Editor Toolbox/Editor/Drawers/Regular/SearchableEnumAttributeDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU
3434
EditorGUI.EndProperty();
3535
}
3636

37-
3837
public override bool IsPropertyValid(SerializedProperty property)
3938
{
4039
return property.propertyType == SerializedPropertyType.Enum;

Assets/Editor Toolbox/Editor/Drawers/Toolbox/Decorator/BeginGroupAttributeDrawer.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,40 @@ namespace Toolbox.Editor.Drawers
55
{
66
public class BeginGroupAttributeDrawer : ToolboxDecoratorDrawer<BeginGroupAttribute>
77
{
8+
private GUIStyle GetStyle(GroupStyle style)
9+
{
10+
switch (style)
11+
{
12+
default:
13+
case GroupStyle.Round:
14+
return Style.roundGroupBackgroundStyle;
15+
case GroupStyle.Boxed:
16+
return Style.boxedGroupBackgroundStyle;
17+
}
18+
}
19+
820
protected override void OnGuiBeginSafe(BeginGroupAttribute attribute)
921
{
10-
ToolboxLayoutHandler.BeginVertical(Style.groupBackgroundStyle);
22+
var style = GetStyle(attribute.Style);
23+
ToolboxLayoutHandler.BeginVertical(style);
1124
if (attribute.HasLabel)
1225
{
1326
GUILayout.Label(attribute.Label, EditorStyles.boldLabel);
1427
}
1528
}
1629

17-
1830
private static class Style
1931
{
20-
internal static readonly GUIStyle groupBackgroundStyle;
32+
internal static readonly GUIStyle roundGroupBackgroundStyle;
33+
internal static readonly GUIStyle boxedGroupBackgroundStyle;
2134

2235
static Style()
2336
{
24-
#if UNITY_2019_3_OR_NEWER
25-
groupBackgroundStyle = new GUIStyle("helpBox")
26-
#else
27-
groupBackgroundStyle = new GUIStyle("box")
28-
#endif
37+
roundGroupBackgroundStyle = new GUIStyle("helpBox")
38+
{
39+
padding = new RectOffset(13, 12, 5, 5)
40+
};
41+
boxedGroupBackgroundStyle = new GUIStyle("box")
2942
{
3043
padding = new RectOffset(13, 12, 5, 5)
3144
};

0 commit comments

Comments
 (0)