Currently I have a function to UpdateGameState(parameter).
Wasn't sure how to get this to show up is Scene Event. I'm just write specific functions that return void to get to work (e.g. UpdateCombatState(){UpdateGameState(CombatState);}
Is there another recommended way of doing this?
Thanks for your assistance.
Is there a way to pass parameters into Scene Events?
Re: Is there a way to pass parameters into Scene Events?
Hi,
Unity restricts UnityEvents such as the OnExecute() scene event to only accept primitive types or UnityEngine object types such as GameObject or Transform.
You could make those wrapper methods, or you could use a custom sequencer command instead of scene events. Example:
There are many things you could do to enhance this script, such as checking if GetSubject(1) returns null, or -- if your game states are an enum -- use something like Enum.GetNames(typeof(GameState)) to get the game state names instead of hard-coding them here. The above is just a simple example.
Unity restricts UnityEvents such as the OnExecute() scene event to only accept primitive types or UnityEngine object types such as GameObject or Transform.
You could make those wrapper methods, or you could use a custom sequencer command instead of scene events. Example:
Code: Select all
// Syntax: UpdateGameState(state, subject)
// Example: UpdateGameState(combat, OrcBoss)
public class SequencerCommandUpdateGameState : SequencerCommand
{
void Awake()
{
string state = GetParameter(0);
AI ai = GetSubject(1).GetComponent<AI>();
switch (GetParameter(0))
{
case "combat":
ai.UpdateGameState(CombatState);
break;
case "idle":
ai.UpdateGameState(IdleStatE);
break;
}
Stop();
}
}
Re: Is there a way to pass parameters into Scene Events?
I really appreciate the breakdown, thank you.
It's one thing to make a great product, it's another thing to add great support to a great product. Many thanks for your time once again.
It's one thing to make a great product, it's another thing to add great support to a great product. Many thanks for your time once again.
Re: Is there a way to pass parameters into Scene Events?
Glad to help!