ShowOnlyAttribute

This commit is contained in:
Simon Lübeß 2024-04-04 15:23:38 +02:00
parent 13472c4a72
commit 06b096b907
4 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ShowOnlyAttribute))]
public class ShowOnlyDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property,
GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position,
SerializedProperty property,
GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: adbb53bc6865b2f44adf93532a11a80e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
using UnityEngine;
/// <summary>
/// Das Feld wird im Inspector nur angezeigt und kann nicht verändert werden.
/// </summary>
public class ShowOnlyAttribute : PropertyAttribute
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4218f171d49f43e9aaa8d2856e98fc06
timeCreated: 1712225177