Edit not active UI Panel Component

Hello, I am working on Inventory system. Now I implemented Equipment window and added “right click to wear” method. Everything works fine BUT! Only if Equipment panel is visible. When panel is not visible (.SetActive(false)) My method doesn’t work. Now question. It is possible to edit variables in not active UI components? Or I have to rewrite my system to .alpha = 0f/1f instead?

Thanks!!

Code of method:

public void WearItem(ContainerSlot from, CharacterEquipmentSlot to)
{
	if(from != null && to != null)
	{
		if(from.Container.containerItems[from.id].ItemType == to.equipmentPart || 
		 ((from.Container.containerItems[from.id].ItemType == ItemType.ONEHAND_WEAPON || from.Container.containerItems[from.id].ItemType == ItemType.TWOHAND_WEAPON)) && to.equipmentPart == ItemType.WEAPON)
		{
			if(from.Container.containerItems[from.id].ItemType == ItemType.TWOHAND_WEAPON)
			{
				CharacterEquipmentSlot shield = Array.Find(FindObjectsOfType<CharacterEquipmentSlot>(), slot => (slot.equipmentPart == ItemType.SHIELD));
				if(shield.Item.ItemType == ItemType.NULL)
				{
					from.Container.containerItems[from.id] = to.Item;
					to.Item = draggingItem;

					characterEquipment.RecalculateStats();
					this.HideToolTip();
				}
				else
				{
					from.Container.containerItems[from.id] = to.Item;
					to.Item = draggingItem;

					from.Container.AddItemToContainer(shield.Item.ItemId,1);
					shield.Item = new Item();

					characterEquipment.RecalculateStats();
					this.HideToolTip();
				}
			}
			else if (from.Container.containerItems[from.id].ItemType == ItemType.SHIELD)
			{
				CharacterEquipmentSlot mainHand = Array.Find(FindObjectsOfType<CharacterEquipmentSlot>(), slot => (slot.equipmentPart == ItemType.WEAPON));
				if(mainHand.Item.ItemType == ItemType.NULL || mainHand.Item.ItemType == ItemType.ONEHAND_WEAPON)
				{
					from.Container.containerItems[from.id] = to.Item;
					to.Item = draggingItem;
					
					characterEquipment.RecalculateStats();
					this.HideToolTip();
				}
				else
				{
					from.Container.containerItems[from.id] = to.Item;
					to.Item = draggingItem;
					
					from.Container.AddItemToContainer(mainHand.Item.ItemId,1);
					mainHand.Item = new Item();
					
					characterEquipment.RecalculateStats();
					this.HideToolTip();
				}
			}
			else
			{
				from.Container.containerItems[from.id] = to.Item;
				to.Item = draggingItem;

				characterEquipment.RecalculateStats();
				this.HideToolTip();
			}
		}
	}
	else if (from != null && to == null)
	{
		CharacterEquipmentSlot eqSlot;
		if(from.Container.containerItems[from.id].ItemType == ItemType.ONEHAND_WEAPON || from.Container.containerItems[from.id].ItemType == ItemType.TWOHAND_WEAPON)
		{
			eqSlot = Array.Find(FindObjectsOfType<CharacterEquipmentSlot>(), slot => (slot.equipmentPart == ItemType.WEAPON));
		}
		else
		{
			eqSlot = Array.Find(FindObjectsOfType<CharacterEquipmentSlot>(), slot => (slot.equipmentPart == from.Container.containerItems[from.id].ItemType));
		}

		this.WearItem(from, eqSlot);
		return;
	}
}

As you can see I need to get refference to CharacterEquipmentSlot “on the fly” cus “right click” on item runs that method with second parametr == null.

@JoshuaStrunk solved my problem:

Where is the script trying to access the equipment variable located and how is it trying to access it? Scripts on inactive objects will not run on their own and it can be tricky to correctly find an object once it is inactive if you don’t already have a reference to it. I just tested out the scenario in Unity 5.1 and as long as you have a reference to the Behavior you should be able to access public variables.
Is anything preventing you from storing a reference to CharacterEquipmentSlot in OnStart? It appears you only have one from your use of FindObjectsOfType. I would also recommend thinking about if this is the route you really want to take for finding objects at runtime. This would begin to break as soon as your scene has more than one character.

Thank you.