-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement DisableInEditModeAttribute & Drawer
- Loading branch information
Showing
7 changed files
with
71 additions
and
30 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Assets/Editor Toolbox/Editor/Drawers/Toolbox/Condition/DisableInEditModeAttributeDrawer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Toolbox.Editor.Drawers | ||
{ | ||
public class DisableInEditModeAttributeDrawer : ToolboxConditionDrawer<DisableInEditModeAttribute> | ||
{ | ||
protected override PropertyCondition OnGuiValidateSafe(SerializedProperty property, DisableInEditModeAttribute attribute) | ||
{ | ||
return !EditorApplication.isPlayingOrWillChangePlaymode ? PropertyCondition.Disabled : PropertyCondition.Valid; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../Editor Toolbox/Editor/Drawers/Toolbox/Condition/DisableInEditModeAttributeDrawer.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...box/Runtime/Attributes/Property/Toolbox/ConditionAttributes/DisableInEditModeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace UnityEngine | ||
{ | ||
/// <summary> | ||
/// Marks serialized field as read-only but only in the EditMode. | ||
/// | ||
/// <para>Supported types: all.</para> | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] | ||
[Conditional("UNITY_EDITOR")] | ||
public class DisableInEditModeAttribute : ToolboxConditionAttribute | ||
{ } | ||
} |
11 changes: 11 additions & 0 deletions
11
...untime/Attributes/Property/Toolbox/ConditionAttributes/DisableInEditModeAttribute.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters