Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #64
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
uurha committed Jul 29, 2023
1 parent 6169299 commit 7adf517
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
22 changes: 22 additions & 0 deletions Editor/EditorTools/Helpers/EditorGUIHelpers.cs
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 });
}
}
}
3 changes: 3 additions & 0 deletions Editor/EditorTools/Helpers/EditorGUIHelpers.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions Editor/EditorTools/Helpers/HideGroup.cs
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;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.uurha.bettereditortools",
"displayName": "Better Editor Tools",
"description": "Collection of useful tools for Unity Editor",
"version": "1.0.53",
"version": "1.0.55",
"unity": "2020.1",
"dependencies": {
"com.uurha.betterdatastructures": "0.1.0",
Expand Down

0 comments on commit 7adf517

Please sign in to comment.