This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
ARPlusSystem/ARPlusSystem-250418/Assets/ARLocation/Editor/ConditionalPropertyDrawer.cs

27 lines
790 B
C#
Raw Permalink Normal View History

using UnityEngine;
using UnityEditor;
namespace ARLocation
{
[CustomPropertyDrawer(typeof(ConditionalPropertyAttribute))]
public class ConditionalPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var conditionalAttribute = (ConditionalPropertyAttribute) attribute;
var name = conditionalAttribute.Name;
var path = property.propertyPath;
var prop = property.serializedObject.FindProperty(path.Replace(property.name, name));
if (prop != null)
{
if (prop.boolValue)
{
EditorGUI.PropertyField(position, property);
}
}
}
}
}