Forum rules - please read before posting.

Set parameters of ActionListAsset (script)

edited February 2018 in Technical Q&A
Hello !
I'm asking for some help today because I got a little problem.
I'm trying to create actions from script, and I want to run an ActionList that is in my Assets folder.

I found a similar topic, but it didn't help me.. 

ActionRunActionList playDialogue = ScriptableObject.CreateInstance("ActionRunActionList") as ActionRunActionList;

playDialogue.listSource = ActionRunActionList.ListSource.AssetFile;

playDialogue.setParameters = true;

playDialogue.invActionList = Resources.Load("ActionLists/PlayDialogueAL", typeof(ActionListAsset)) as ActionListAsset;

playDialogue.localParameters[0].SetValue(1);

But it does not work, because the list localParameters is empty.

I tried to fill it but I don't know how to get the IDs of the parameters.

playDialogue.localParameters.Add(new ActionParameter(1));

works but I get warnings so.. that's not a good way

Did I do something wrong ? If anybody knows a solution, I would appreciate to know it :)

Thank you !

Comments

  • Welcome to the community, @Erwan.

    A parameter's ID number is shown to the left of it's label when defined in the ActionList properties.

    If you're going to the trouble of running a parameterised ActionList asset through code, then it's probably best to just skip the ActionRunActionList instance and just set the parameters directly and then run it.  That's essentially how ActionRunActionList works:

    ActionListAsset playDialogueAL = Resources.Load ("ActionLists/PlayDialogueAL", typeof (ActionListAsset)) as ActionListAsset;
    playDialogueAL.parameters[0].SetValue (1);
    playDialogueAL.Interact ();
  • edited February 2018
    Hello @ChrisIceBox, thank you for your very fast answer !

    I'm trying to make an Editor Window to create actions from a file, to make it easier.

    But I would like to be able to manage these actions after I created it, if I want to, that's why I want the ActionRunActionList.

    I don't understand why the parameters list of my ActionListAsset is filled, and the localParameters are not when I set invActionList to the ActionListAsset.

    I tried to manually Add a localParameter 

    playDialogue.localParameters.Add(new ActionParameter(myActionListAsset.parameters[0].ID));

    But I get warnings. Parameter mismatch detected - please check the 'ActionList: Run' Action for its parameter values.

    Setting the value to myActionListAsset.parameters[0] and setting myActionListAsset to invActionList doest not work..

    Thank you again, I hope I'll find a solution :p
  • edited February 2018

    We will, don't worry.

    The error message displays if the number of parameters present in the asset do not match those listed in the ActionList: Run Action.

    This normally occurs if you add more parameters to the asset after setting up the Action.

    AC checks for this match at runtime and when viewing the Action's UI, and resizes the Action's list of parameters accordingly.

    How many parameters does the asset have? You will need to add the same number of parameters to the ActionRunActionList.

    If you're not viewing the default UI, you could try invoking it manually - to force the check - by running the Action's ShowGUI method. Otherwise, you could look copying code from the the private SyncLists method.

  • Try this code:
    http://pasteall.org/846186/csharp

    Attach it to a Cutscene in your scene that has no Actions except for the default.  Make a new ActionList asset file that has a single String parameter, and then pass that to speech text using Dialogue: Play speech.

    (You can insert a parameter into a speech with [param:0])

    Have the script above refer to both the Cutscene and the asset file in the Inspector fields, and then run the scene.  The Cutscene should change to the ActionList: Run Action, and then set the asset's parameter correctly when Run now is clicked.
  • Thank you !

    The warnings disappeared when I set all the parameters.

    I used this code : 


    I probably could enter IDs like 1, 2, 3 ...

    But it's perfectly working for now

    thanks again !
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.