consuming public boolean from inspector and using it in other class (in same script)

Hello all!
My first time, be gentle… :slight_smile:

I have a script, with 2 classes;
In 1 class, I have a public bool, which appears in the inspector.
In the other class, I want to make an If statement, depending on the value of aforementioned bool.
3 hours later and still not any wiser, I figured to pop the question here.

My code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public class Wave
{
    public bool mobTypeSoldier;
}

public class SpawnSoldier : MonoBehaviour {
public Wave mobType;

Void Update () 
{
  if (mobType.mobTypeSoldier == true)
                        Debug.Log("Soldier Assigned");
}

So the idea should be, I select in the inspector the checkbox (mob Type Soldier), and the debug log writes “Soldier Assigned”. It doesn’t need to be at runtime; Simply configuring it before the game starts should be enough.

Thanks so much in advance!

Never mind, I’ve figured it out :slight_smile: For those interested:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
     
    [System.Serializable]
    public class Wave
    {
       public bool mobTypeSoldier;
    }
     
    public class SpawnSoldier : MonoBehaviour {
    public Wave[] waves;
     
    Void Update ()
    {
      if (waves[currentWave].mobTypeSoldier == true)
      Debug.Log("Soldier Assigned");
    }

You can use multiple classes in 1 script when you r coding in basic C# but since Unity works only on GameObjects and it might not assign 2 classes on same GameObject.
Atleast never worked for me but u can use the following Script to perform ur action or define both the classes on different GameObjects.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public class Test : MonoBehaviour {
	public bool mobTypeSoldier;


	void Update () 
	{
		if (mobTypeSoldier == true)
			Debug.Log("Soldier Assigned");
	}
}