This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
generated from techno-dwarf-works/unity-package-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev
- Loading branch information
Showing
4 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
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,22 @@ | ||
using System.Reflection; | ||
using Better.Tools.Runtime; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Better.EditorTools.Helpers | ||
{ | ||
public static class EditorGUIHelpers | ||
{ | ||
private static MethodInfo _defaultPropertyField; | ||
public static bool PropertyFieldSafe(Rect position, SerializedProperty property, GUIContent label) | ||
{ | ||
if (_defaultPropertyField == null) | ||
{ | ||
var type = typeof(EditorGUI); | ||
_defaultPropertyField = type.GetMethod("DefaultPropertyField", BetterEditorDefines.MethodFlags); | ||
} | ||
|
||
return (bool)_defaultPropertyField.Invoke(null, new object[] { position, property, label }); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Better.EditorTools.Helpers | ||
{ | ||
public class HideGroup : GUI.Scope | ||
public class HideGroup : EditorGUI.DisabledGroupScope | ||
{ | ||
private readonly Color _color; | ||
private readonly bool _wasEnabled; | ||
|
||
public HideGroup(bool satisfied) | ||
public HideGroup(bool satisfied) : base(satisfied) | ||
{ | ||
_color = GUI.color; | ||
if (satisfied) | ||
{ | ||
GUI.color = Color.clear; | ||
GUI.enabled = false; | ||
} | ||
_wasEnabled = GUI.enabled; | ||
} | ||
|
||
protected override void CloseScope() | ||
{ | ||
base.CloseScope(); | ||
GUI.color = _color; | ||
GUI.enabled = _wasEnabled; | ||
} | ||
} | ||
} |
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