Forum rules - please read before posting.

Pop Up type as Action List parameter

I often wish it was possible to specify a pop up value as a parameter to an action list.
It would be so convenient to have a specification of the different values rather than to rely on a number or a string, not to mention the increased readability of using one pop up switch action rather than tons of stacked checks.

So my first question is if this is already possible but I missed it?

And if not, would it be something worth considering? I would love to be able to specify the pop up values in the parameters UI for the action list.

Thanks!

Comments

  • Likely a workaround would be best, but I shall think on this.

  • This isn't currently possible, however the introduction of "PopUp presets" in AC v1.69 does allow for some flexibility.

    A custom Action can be used to create a "PopUp switch" that takes a preset (defined in the Variables Manager) as well as an Integer parameter:

    using UnityEngine;
    using System.Collections.Generic;
    
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionParamPopUp : ActionCheckMultiple
        {
    
            public int popUpPresetID = 0;
            public int parameterID = -1;
    
            private int parameterValue;
    
    
            public ActionParamPopUp ()
            {
                this.isDisplayed = true;
                category = ActionCategory.ActionList;
                title = "Pop Up parameter switch";
            }
    
    
            public override void AssignValues (List<ActionParameter> parameters)
            {
                parameterValue = AssignInteger (parameters, parameterID, parameterValue);
    
                base.AssignValues (parameters);
            }
    
    
            public override ActionEnd End (List<Action> actions)
            {
                return ProcessResult (parameterValue, actions);
            }
    
    
            #if UNITY_EDITOR
    
            override public void ShowGUI (List<ActionParameter> parameters)
            {
                parameterID = Action.ChooseParameterGUI ("Integer parameter:", parameters, parameterID, ParameterType.Integer);
    
                if (KickStarter.variablesManager == null)
                {
                    EditorGUILayout.HelpBox ("No Variables Manager assigned!", MessageType.Warning);
                    return;
                }
    
                if (KickStarter.variablesManager.popUpLabelData == null || KickStarter.variablesManager.popUpLabelData.Count == 0)
                {
                    EditorGUILayout.HelpBox ("No PopUp presets defined!", MessageType.Warning);
                    return;
                }
    
                // Set preset
                List<string> popUpPresetLabels = new List<string>();
                int j = 0;
                for (int i=0; i<KickStarter.variablesManager.popUpLabelData.Count; i++)
                {
                    popUpPresetLabels.Add (KickStarter.variablesManager.popUpLabelData[i].EditorLabel);
                    if (popUpPresetID == KickStarter.variablesManager.popUpLabelData[i].ID)
                    {
                        j = i;
                    }
                }
                j = EditorGUILayout.Popup ("Label preset:", j, popUpPresetLabels.ToArray ());
                popUpPresetID = KickStarter.variablesManager.popUpLabelData[j].ID;
    
                PopUpLabelData labelData = KickStarter.variablesManager.GetPopUpLabelData (popUpPresetID);
                numSockets = labelData.Length;
            }
    
    
            override public void SkipActionGUI (List<Action> actions, bool showGUI)
            {
                if (numSockets < 0)
                {
                    numSockets = 0;
                }
    
                if (numSockets < endings.Count)
                {
                    endings.RemoveRange (numSockets, endings.Count - numSockets);
                }
                else if (numSockets > endings.Count)
                {
                    if (numSockets > endings.Capacity)
                    {
                        endings.Capacity = numSockets;
                    }
                    for (int i=endings.Count; i<numSockets; i++)
                    {
                        ActionEnd newEnd = new ActionEnd ();
                        if (i > 0)
                        {
                            newEnd.resultAction = ResultAction.Stop;
                        }
                        endings.Add (newEnd);
                    }
                }
    
                if (KickStarter.variablesManager == null)
                {
                    return;
                }
    
                PopUpLabelData labelData = KickStarter.variablesManager.GetPopUpLabelData (popUpPresetID);
                if (labelData == null) return;
    
                string[] popUpLabels = labelData.GenerateEditorPopUpLabels ();
    
                foreach (ActionEnd ending in endings)
                {
                    if (showGUI)
                    {
                        EditorGUILayout.Space ();
                        int i = endings.IndexOf (ending);
                        ending.resultAction = (ResultAction) EditorGUILayout.EnumPopup ("If = '" + popUpLabels[i] + "':", (ResultAction) ending.resultAction);
                    }
    
                    if (ending.resultAction == ResultAction.RunCutscene && showGUI)
                    {
                        if (isAssetFile)
                        {
                            ending.linkedAsset = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList to run:", ending.linkedAsset, typeof (ActionListAsset), false);
                        }
                        else
                        {
                            ending.linkedCutscene = (Cutscene) EditorGUILayout.ObjectField ("Cutscene to run:", ending.linkedCutscene, typeof (Cutscene), true);
                        }
                    }
                    else if (ending.resultAction == ResultAction.Skip)
                    {
                        SkipActionGUI (ending, actions, showGUI);
                    }
                }
            }
    
            #endif
    
        }
    
    }
    
  • Interesting! Might this be something that you add in an upcoming release?

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.