Forum rules - please read before posting.

Using objective descriptions in objectives list instead of title

Hi, I'm adding an objectives list into the game and I would like to have the descriptions shown in the list, but I can't see a way to get it in the preset objectives list.
I'm using the titles to get Started-state descriptions as comma separated hints, and the script picks the hints per scene, so I don't like to change the Title structure.
Any ideas?

Comments

  • An InventoryBox set to display Objectives can only display their Titles. If you wanted to make use of it in the intended way, you'd need to move your data around, i.e. swap Title and Description texts.

    Alternatively, you could hack it by opening AC's MenuInventoryBox script and replacing "GetTitle" with "GetDescription" - but you'd need to make the same change upon updating AC.

  • Hmm. Could this be a feature idea? Maybe set a boolean whether to use the title or description - or a lambda function?

  • I'm afraid I don't see a wide-enough use for it.

    It is possible, however, to replace the Menu/InventoryBox with a purely custom UI, as all runtime objectives data is stored in the RuntimeObjectives component, and can be accessed through custom script, i.e.:

    AC.KickStarter.runtimeObjectives.GetObjectives ()
    
  • edited July 2023

    What does this InventoryBox actually contain? Is it just a list of objectives listed as in

    case AC_InventoryBoxType.Objectives: ?

    I think that creating a custom component would be a better long term solution...

  • And of course the offset included.

  • While the most robust way would be to bypass MenuInventoryBox entirely, and just read from the same source (RuntimeObjectives), you could feasibly rely on a MenuInventoryBox that was hidden.

    Its GetObjective function can be used to get an ObjectiveInstance class given a slot index. If you knew the Menu name, InventoryBox name, and slot number, you could extract the relevant data - offset being accounted for automatically:

    ObjectiveInstance objectiveInstance = (PlayerMenus.GetElementWithName ("MyMenu", "MyInventoryBox") as MenuInventoryBox).GetObjective (slotNumber);
    
  • Sorry, I don't get the last comment.

  • The InventoryBox element that displays Objectives is already gathering up the data you're looking for - just not displaying it in the way you want to. If you use a Unity UI menu with such an element that's hidden from view, you can make use of scripting to extract the data for use elsewhere.

    A Unity UI-based Objectives list will have a UI Button object for each slot. You could feasibly have a duplicate set of such slots - which are in-view - that transfer the data from one the hidden set.

    Each duplicate slot would then have a component attached that looks for its original equivalent (i.e. the one linked to the InventoryBox) and gets its data from there. Something like:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class ObjectiveDescriptionUI : MonoBehaviour
    {
    
        public int slotNumber;
        public string menuName;
        public string inventoryBoxName;
        public Text text;
    
        void Update ()
        {
            ObjectiveInstance objectiveInstance = (PlayerMenus.GetElementWithName (menuName, inventoryBoxName) as MenuInventoryBox).GetObjective (slotNumber);
            text.text = objectiveInstance.Objective.GetDescription (Options.GetLanguage ());
        }
    
    }
    
  • How would I then get the selectedObjective to be set when a button in the other list is pressed? I use a script that sets the objective/hints menu according to the selectedObjective and data related to it in the hints boolean variable string (objective-hint1-hint2 style, like 64-1-0;67-0-0;68-1-0) shows the opened hints and if the hint timer has enabled a new hint to be revealed, shows a open hint button.

  • An objective can be selected by referring to its ID number, using the SelectObjective function:

    KickStarter.runtimeObjectives.SelectObjective (objectiveInstance.Objective.ID);
    
  • I actually dealt it with another Label in the objective Button - the first Label text is just set transparent and I set the description into that other Label with a small script.
    Would another Label with description be a reasonable solution for AC in general.
    Here in a pic I demonstrate the usefulness of using the ObjectiveTitles as some sort of IDs.

    https://imgur.com/a/5Vnmgrh

    Developer can much more easily set or check objectives for example Scene/MajorTask/Objective structure.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.