//============= Copyright (c) Ludic GmbH, All rights reserved. ============== // // Purpose: Part of the My Behaviour Tree Controller Code // //============================================================================= using System; using System.Reflection; #if UNITY_EDITOR using UnityEditor; using UnityEngine; [CustomPropertyDrawer(typeof(HideAttributeinSubClassAttribute))] public class HideAttributeinSubClassDrawer : PropertyDrawer { private bool IsVisible(SerializedProperty serializedProperty) { return serializedProperty.serializedObject.targetObject.GetType().GetMethod("SetAlpha").DeclaringType == serializedProperty.serializedObject.targetObject.GetType(); } public override void OnGUI(Rect rect, SerializedProperty serializedProperty, GUIContent content) { if (IsVisible(serializedProperty)) { EditorGUI.PropertyField(rect, serializedProperty); } } public override float GetPropertyHeight(SerializedProperty serializedProperty, GUIContent content) { if (IsVisible(serializedProperty)) return base.GetPropertyHeight(serializedProperty, content); else return 0; } } #endif public class HideAttributeinSubClassAttribute : Attribute { }