The other approach is to just reference the Menu by name:
using UnityEngine;
using AC;
public class ForceSelectObjective : MonoBehaviour
{
void OnEnable()
{
if (KickStarter.runtimeObjectives == null || KickStarter.runtimeObjectives.SelectedObjective == null) return;
var menu = PlayerMenus.GetMenuWithName("Objectives");
var inventoryBox = menu.GetElementWithGameObject(gameObject) as MenuInventoryBox;
var slot = inventoryBox.GetSlotIndex(gameObject);
if (inventoryBox.GetObjective(slot) == KickStarter.runtimeObjectives.SelectedObjective)
{
KickStarter.playerMenus.SelectUIElement(gameObject);
}
}
}
using UnityEngine;
using AC;
public class ForceSelectObjective : MonoBehaviour
{
void OnEnable()
{
if (KickStarter.runtimeObjectives == null || KickStarter.runtimeObjectives.SelectedObjective == null) return;
var menu = PlayerMenus.GetMenuWithName("Objectives");
var inventoryBox = menu.GetElementWithName("ObjectivesList") as MenuInventoryBox;
var slot = inventoryBox.GetSlotIndex(gameObject);
if (inventoryBox.GetObjective(slot) == KickStarter.runtimeObjectives.SelectedObjective)
{
KickStarter.playerMenus.SelectUIElement(gameObject);
}
}
}
Okay, so it still doesn't work, but at least now I don't have the warnings.
In previous iterations, the Description was visible, but now it isn't showing up. So basically, we're back to the initial state - no Objective is selected and the attached description isn't being displayed.
And don't worry at all. I'm happy you are willing to help me here!
The script above wouldn't affect the Description's visibility. You're saying that this last change caused it to go?
At this point, I would need to see the setup for myself to determine what's going on. If you can PM me your project (sans Library folder) with clear recreation instructions, I will take a look.
Comments
I checked my ObjectivesUI prefab and I can see the Canvas component, but the Grid component, where the buttons are placed, only has the RectTransform.
https://imgur.com/a/pNr3ruu
Odd, should work in that case.
The other approach is to just reference the Menu by name:
I'm afraid still doesn't work.
I have this error for each of the three buttons I have with the script attached.
I share some more screenshots of the setup:
https://imgur.com/a/ulJureF
Thank you for your continued patience.
Let's try this:
Okay, so it still doesn't work, but at least now I don't have the warnings.
In previous iterations, the Description was visible, but now it isn't showing up. So basically, we're back to the initial state - no Objective is selected and the attached description isn't being displayed.
And don't worry at all. I'm happy you are willing to help me here!
The script above wouldn't affect the Description's visibility. You're saying that this last change caused it to go?
At this point, I would need to see the setup for myself to determine what's going on. If you can PM me your project (sans Library folder) with clear recreation instructions, I will take a look.
The project is too big to share. I'll try to recreate the sceneario in some basic project in a few days.