Interaction newCaptureInteraction = SceneManager.AddPrefab( "Logic", "Interaction", true, false, true ).GetComponent<Interaction>( );
newCaptureInteraction.gameObject.name = AdvGame.UniqueName( hotspotGameObject.name + ": Capture" );
newCaptureInteraction.useParameters = true;
// Setup hotspot button
hotspotScript.useButtons.Add( new Button( ) );
hotspotScript.useButtons[0].iconID = 0;
hotspotScript.useButtons[0].isDisabled = false;
hotspotScript.useButtons[0].playerAction = PlayerAction.DoNothing;
hotspotScript.useButtons[0].interaction = newCaptureInteraction;
// Setup "Capture" action
ActionRunActionList newCaptureActionList = new ActionRunActionList( );
newCaptureActionList.listSource = ActionRunActionList.ListSource.AssetFile;
// Setup the action list by first loading the asset
ActionListAsset actionListAsset = ( ActionListAsset ) Resources.Load( "CaptureObject" ) as ActionListAsset;
actionListAsset.parameters[0].SetValue( newBaseObject );
actionListAsset.parameters[1].SetValue( newInventoryItem.id );
actionListAsset.parameters[2].SetValue( hotspotScript );
newCaptureActionList.invActionList = actionListAsset;
newCaptureInteraction.actions.Add( newCaptureActionList );
Comments
The ActionListAsset should only be referenced in the code so far as assigning the "listSource" goes.
You should instead set the values within the ActionRunActionList Action:
newCaptureActionList.setParameters = true;
newCaptureActionList.localParameters[0].SetValue (newBaseObjects);
// etc
This will cause the parameter values to be transferred to the asset file when the Action itself is run - not when the code is.