Class ScenarioBase
Derive ScenarioBase to implement a custom scenario
Inherited Members
Namespace: UnityEngine.Experimental.Perception.Randomization.Scenarios
Syntax
[DefaultExecutionOrder(-1)]
public abstract class ScenarioBase : MonoBehaviour
Fields
quitOnComplete
If true, this scenario will quit the Unity application when it's finished executing
Declaration
[HideInInspector]
public bool quitOnComplete
Field Value
Type | Description |
---|---|
Boolean |
serializedConstantsFileName
The name of the Json file this scenario's constants are serialized to/from.
Declaration
[HideInInspector]
public string serializedConstantsFileName
Field Value
Type | Description |
---|---|
String |
Properties
activeScenario
Returns the active parameter scenario in the scene
Declaration
public static ScenarioBase activeScenario { get; }
Property Value
Type | Description |
---|---|
ScenarioBase |
currentIteration
The current iteration index of the scenario
Declaration
public int currentIteration { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
currentIterationFrame
The number of frames that have elapsed since the current scenario iteration was Setup
Declaration
public int currentIterationFrame { get; }
Property Value
Type | Description |
---|---|
Int32 |
framesSinceInitialization
The number of frames that have elapsed since the scenario was initialized
Declaration
public int framesSinceInitialization { get; }
Property Value
Type | Description |
---|---|
Int32 |
genericConstants
Returns this scenario's non-typed serialized constants
Declaration
public abstract object genericConstants { get; }
Property Value
Type | Description |
---|---|
Object |
isIterationComplete
Returns whether the current scenario iteration has completed
Declaration
public abstract bool isIterationComplete { get; }
Property Value
Type | Description |
---|---|
Boolean |
isScenarioComplete
Returns whether the entire scenario has completed
Declaration
public abstract bool isScenarioComplete { get; }
Property Value
Type | Description |
---|---|
Boolean |
randomizers
Return the list of randomizers attached to this scenario
Declaration
public IReadOnlyList<Randomizer> randomizers { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Randomizer> |
serializedConstantsFilePath
Returns the file location of the JSON serialized constants
Declaration
public string serializedConstantsFilePath { get; }
Property Value
Type | Description |
---|---|
String |
tagManager
The RandomizerTagManager attached to this scenario
Declaration
public RandomizerTagManager tagManager { get; }
Property Value
Type | Description |
---|---|
RandomizerTagManager |
Methods
CreateRandomizer<T>()
Creates a new randomizer and adds it to this scenario
Declaration
public T CreateRandomizer<T>()
where T : Randomizer, new()
Returns
Type | Description |
---|---|
T | The newly created randomizer |
Type Parameters
Name | Description |
---|---|
T | The type of randomizer to create |
Deserialize()
Deserializes constants saved in a JSON file located at serializedConstantsFilePath
Declaration
public abstract void Deserialize()
GenerateIterativeRandomSeed(Int32, UInt32)
Generates a random seed by hashing three values together: an arbitrary iteration value, the current scenario iteration, and a base random seed
Declaration
public uint GenerateIterativeRandomSeed(int iteration, uint baseSeed = 539662031U)
Parameters
Type | Name | Description |
---|---|---|
Int32 | iteration | An offset value hashed inside the seed generator |
UInt32 | baseSeed | An offset value hashed inside the seed generator |
Returns
Type | Description |
---|---|
UInt32 | The generated random seed |
GenerateRandomSeed(UInt32)
Generates a random seed by hashing the current scenario iteration with a given base random seed
Declaration
public uint GenerateRandomSeed(uint baseSeed = 539662031U)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | baseSeed | Used to offset the seed generator |
Returns
Type | Description |
---|---|
UInt32 | The generated random seed |
GetRandomizer<T>()
Finds and returns a randomizer attached to this scenario of the specified Randomizer type
Declaration
public T GetRandomizer<T>()
where T : Randomizer
Returns
Type | Description |
---|---|
T | A randomizer of the specified type |
Type Parameters
Name | Description |
---|---|
T | The type of randomizer to find |
Exceptions
Type | Condition |
---|---|
UnityEngine.Experimental.Perception.Randomization.Scenarios.ScenarioException |
GetRandomizerIndex<T>()
Returns the execution order index of a randomizer of the given type
Declaration
public int GetRandomizerIndex<T>()
where T : Randomizer, new()
Returns
Type | Description |
---|---|
Int32 | The randomizer index |
Type Parameters
Name | Description |
---|---|
T | The type of randomizer to index |
Exceptions
Type | Condition |
---|---|
UnityEngine.Experimental.Perception.Randomization.Scenarios.ScenarioException |
IncrementIteration()
Progresses the current scenario iteration
Declaration
protected virtual void IncrementIteration()
OnAwake()
This method executed directly after this scenario has been registered and initialized
Declaration
protected virtual void OnAwake()
RemoveRandomizer<T>()
Removes a randomizer of the specified type from this scenario
Declaration
public void RemoveRandomizer<T>()
where T : Randomizer, new()
Type Parameters
Name | Description |
---|---|
T | The type of scenario to remove |
ReorderRandomizer(Int32, Int32)
Moves a randomizer from one index to another
Declaration
public void ReorderRandomizer(int currentIndex, int nextIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | currentIndex | The index of the randomizer to move |
Int32 | nextIndex | The index to move the randomizer to |
Serialize()
Serializes the scenario's constants to a JSON file located at serializedConstantsFilePath
Declaration
public abstract void Serialize()