public virtual void OnEnable()
        {
            targetType = target.GetType();
            shouldOverrideInspector = targetType.IsDefined(typeof(OverrideInspectorAttribute), true);
            if (!shouldOverrideInspector)
            {
                return;
            }

            shouldBeDrawed = !DontDrawInspectorIfAttribute.TryFindInvalidAttribute(target, out dontDrawAttribute);
            if (!shouldBeDrawed)
            {
                return;
            }

            inspectorDrawer = InspectorDrawer.Create(target, serializedObject.GetIterator());
            inspectorDrawer.OnEnable();

            EditorApplication.update += Repaint;
        }
Exemplo n.º 2
0
        private static void ValidateDontDrawAttributesOfComponent(MonoBehaviour behaviour)
        {
            var type = behaviour.GetType();
            DontDrawInspectorIfAttribute invalidAttribute;
            var message = string.Empty;

            if (DontDrawInspectorIfAttribute.TryFindInvalidAttribute(behaviour, out invalidAttribute))
            {
                error_count++;
                if (invalidAttribute.IsMissingFunction)
                {
                    message = string.Format("The attribute 'DontDrawInspectorIfAttribute'of the component {0}  refers to a missing method -> '{1}'", type.Name, invalidAttribute.MethodName);
                    Debug.LogError(message, behaviour);
                }
                else
                {
                    message = string.Format("The attribute 'DontDrawInspectorIfAttribute' of the component {0} has the error -> '{1}'", type.Name, invalidAttribute.Message);
                    Debug.LogError(message, behaviour);
                }
            }
        }