[Solved] Can't execute method on scriptableObject

Hello.
I Created 2 ScriptableObjects to work on my IA.

namespace Game.Units.IA.Behaviours.Conditions {
   public delegate bool DoResultDelegate();

   public class BehaviourCondition : ScriptableObject {
      protected event DoResultDelegate DoResult;
      public GameObject gameObject;

      public bool Result() {
         Debug.Log("resulting...");
         if (DoResult != null) {
            return DoResult();
         } else
            return false;
      }
   }
}
namespace Game.Units.IA.Behaviours {
   public class IABehaviour : ScriptableObject {
      #region variables
      [SerializeField] private IABehaviourType behaviourType;
      [SerializeField] private BehaviourCondition[] conditions;
      [SerializeField] private GameObject gameObject;

      protected Action OnAct;
      #endregion
      #region methods
      protected virtual void Awake() {
         if (gameObject != null)
            foreach (BehaviourCondition BC in conditions) {
               BC.gameObject = gameObject;
            }
      }

      private bool CanAct() {
         bool canAct = false;
         foreach(BehaviourCondition BC in conditions) {
            canAct = canAct && BC.Result();
         }
         return canAct;
      }
      /// <summary>
      /// executes the behaviour.
      /// </summary>
      public void Act() {
         if (CanAct()) {
            if (OnAct != null)
               OnAct();
         }
           
      }
      #endregion
      #region properties
      public IABehaviourType BehaviourType {
         get { return behaviourType; }
         set { behaviourType = value; }
      }
      public GameObject GameObject {
         get { return gameObject; }
         set { gameObject = value; }
      }
      #endregion
   }
}

On my IAController at line 16 I execute my ScriptableObject.

namespace Game.Units.IA {
   [RequireComponent(typeof(NavMeshAgent))]
   public class IAController : MonoBehaviour {
      #region variables
      [SerializeField] private IABehaviour behaviour;

      private NavMeshAgent agent;
      #endregion
      #region methods
      private void Awake() {
         agent = GetComponent<NavMeshAgent>();
         behaviour.GameObject = gameObject;
      }

      private void Update() {
         behaviour.Act();
      }
      #endregion
      #region properties
      public IABehaviour Behaviour {
         get { return behaviour; }
         set { behaviour = value; }
      }
      #endregion
   }
}

The problem is: On my IABehaviour on line 21, when i’m debugging, the variable have my scriptableObject, but it is not going through the Result method on BehaviourCondition. Why?

How are you putting your BehaviourConditions into the conditions collection? Do you get a console message if you put a debug.log just before line 21?

The obvious problem could be the collection is empty.

That’s an issue, because IABehaviour, conditions.Length is greater than 0! I did attached the scriptableobject created! When inspecting the memory, it have the values that i set on the object in the inspector. And BehaviourCondition on line 9 is not being call. The Result method not even goes when i step in (F11).

— Edit —
Ok small change and i don’t know why. I made it working now!
From:

bool canAct = false;
foreach(BehaviourCondition BC in conditions) {
   canAct = canAct && BC.Result();
}

To:

bool canAct = true;
for (int i = 0; i < conditions.Length; ++i)
   canAct = canAct && conditions[0].Result();

For some reason and I teste twice, foreach is not referencing correctly the object in the memory in my point of view, because i have the exactly values of my object, but it seems not to locate the method when calling it. It just jump to the next line.