Advertisement
Ilya_Bykonya

Untitled

Mar 14th, 2024
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | Source Code | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5.  
  6. namespace Utils
  7. {
  8.     public class ReadOnlyAttribute : PropertyAttribute { }
  9.  
  10.     [CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
  11.     public class ReadOnlyDrawer : PropertyDrawer
  12.     {
  13.         public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  14.         {
  15.             return EditorGUI.GetPropertyHeight(property, label, true);
  16.         }
  17.         public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  18.         {
  19.             GUI.enabled = false;
  20.             EditorGUI.PropertyField(position, property, label, true);
  21.             GUI.enabled = true;
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement