Exemplo n.º 1
0
        public static ObjectValidation NullReference(Behaviour behaviour, string description = null)
        {
            FieldInfo[] nullFields = Stratus.Utilities.Reflection.GetFieldsWithNullReferences(behaviour);
            if (nullFields.Empty())
            {
                return(null);
            }

            string label = behaviour.GetType().Name;

            if (description != null)
            {
                label += $" {description}";
            }

            string msg = $"{label} has the following fields currently set to null:";

            foreach (var f in nullFields)
            {
                msg += $"\n - <i>{f.Name}</i>";
            }
            ObjectValidation validation = new ObjectValidation(msg, Level.Warning, behaviour);

            return(validation);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Concatenates two validation messages together, provided they are to the same target.
        /// The level is raised to the highest of the two.
        /// </summary>
        /// <param name="other"></param>
        public void Add(ObjectValidation other)
        {
            if (other == null || other.target != this.target)
            {
                return;
            }

            message += other.message;
            if (other.type > this.type)
            {
                this.type = other.type;
            }
        }
Exemplo n.º 3
0
 private void RemoveMessage(ObjectValidation message)
 {
     endOfFrameRequests.Add(() => { messages.Remove(message); });
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a validation message on top of the editor
 /// </summary>
 /// <param name="message"></param>
 /// <param name="type"></param>
 /// <param name="target"></param>
 public void AddMessage(ObjectValidation message)
 {
     messages.Add(message);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Adds a validation message on top of the editor
        /// </summary>
        /// <param name="message"></param>
        /// <param name="type"></param>
        /// <param name="target"></param>
        public void AddMessage(string message, MessageType type, UnityEngine.Object target, Func <bool> onValidate = null)
        {
            var contextMessage = new ObjectValidation(message, type.Convert(), target);

            messages.Add(contextMessage);
        }