init
This commit is contained in:
commit
c7d8c303a6
499 changed files with 2349700 additions and 0 deletions
28
Assets/ABI.CCK/Scripts/Editor/ReadOnlyDrawer.cs
Executable file
28
Assets/ABI.CCK/Scripts/Editor/ReadOnlyDrawer.cs
Executable file
|
@ -0,0 +1,28 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This class contain custom drawer for ReadOnly attribute.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
|
||||
public class ReadOnlyDrawer : PropertyDrawer
|
||||
{
|
||||
/// <summary>
|
||||
/// Unity method for drawing GUI in Editor
|
||||
/// </summary>
|
||||
/// <param name="position">Position.</param>
|
||||
/// <param name="property">Property.</param>
|
||||
/// <param name="label">Label.</param>
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// Saving previous GUI enabled value
|
||||
var previousGUIState = GUI.enabled;
|
||||
// Disabling edit for property
|
||||
GUI.enabled = false;
|
||||
// Drawing Property
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
// Setting old GUI enabled value
|
||||
GUI.enabled = previousGUIState;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue