docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ScenarioBase

    Derive ScenarioBase to implement a custom scenario

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    ScenarioBase
    Scenario<T>
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.Perception.Randomization.Scenarios
    Assembly: Unity.Perception.Runtime.dll
    Syntax
    [DefaultExecutionOrder(-1)]
    public abstract class ScenarioBase : MonoBehaviour

    Fields

    configuration

    An external text asset that is loaded when the scenario starts to configure scenario settings

    Declaration
    public TextAsset configuration
    Field Value
    Type Description
    TextAsset

    Properties

    activeRandomizers

    Enumerates over all enabled randomizers

    Declaration
    public IEnumerable<Randomizer> activeRandomizers { get; }
    Property Value
    Type Description
    IEnumerable<Randomizer>

    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
    int

    currentIterationFrame

    The number of frames that have elapsed since the current scenario iteration was Setup

    Declaration
    public int currentIterationFrame { get; }
    Property Value
    Type Description
    int

    framesSinceInitialization

    The number of frames that have elapsed since the scenario was initialized

    Declaration
    public int framesSinceInitialization { get; }
    Property Value
    Type Description
    int

    genericConstants

    Returns this scenario's non-typed serialized constants

    Declaration
    public abstract ScenarioConstants genericConstants { get; }
    Property Value
    Type Description
    ScenarioConstants

    isIterationComplete

    Returns whether the current scenario iteration has completed

    Declaration
    protected abstract bool isIterationComplete { get; }
    Property Value
    Type Description
    bool

    isScenarioComplete

    Returns whether the scenario has completed

    Declaration
    protected abstract bool isScenarioComplete { get; }
    Property Value
    Type Description
    bool

    isScenarioReadyToStart

    The scenario will begin on the frame this property first returns true

    Declaration
    protected abstract bool isScenarioReadyToStart { get; }
    Property Value
    Type Description
    bool

    Whether the scenario should start this frame

    randomizers

    Return the list of randomizers attached to this scenario

    Declaration
    public IReadOnlyList<Randomizer> randomizers { get; }
    Property Value
    Type Description
    IReadOnlyList<Randomizer>

    state

    The current activity state of the scenario

    Declaration
    public ScenarioBase.State state { get; }
    Property Value
    Type Description
    ScenarioBase.State

    Methods

    AddRandomizer(Randomizer)

    Append a randomizer to the end of the randomizer list

    Declaration
    public void AddRandomizer(Randomizer newRandomizer)
    Parameters
    Type Name Description
    Randomizer newRandomizer

    The Randomizer to add to the Scenario

    DelayIteration()

    Delays the current iteration by one frame. This results in OnIterationStart() being called again for the same iteration.

    Declaration
    public void DelayIteration()
    Remarks

    Must be called from within the OnIterationStart() function of a class inheriting from Randomizer.

    DeserializeConfiguration()

    Overwrites this scenario's randomizer settings and scenario constants from a JSON serialized configuration

    Declaration
    protected virtual void DeserializeConfiguration()

    GetRandomizer(int)

    Returns the randomizer present at the given index

    Declaration
    public Randomizer GetRandomizer(int index)
    Parameters
    Type Name Description
    int index

    The lookup index

    Returns
    Type Description
    Randomizer

    The randomizer present at the given index

    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
    ScenarioException

    IncrementIteration()

    This method selects what the next iteration index will be. By default, the scenario will simply progress to the next iteration, but this behaviour can be overriden.

    Declaration
    protected virtual void IncrementIteration()

    InsertRandomizer(int, Randomizer)

    Insert a randomizer at a given index within the randomizer list

    Declaration
    public void InsertRandomizer(int index, Randomizer newRandomizer)
    Parameters
    Type Name Description
    int index

    The index to place the randomizer

    Randomizer newRandomizer

    The randomizer to add to the list

    Exceptions
    Type Condition
    ScenarioException

    LoadConfigurationAsset()

    Loads and stores a JSON scenario settings configuration file before the scenario starts

    Declaration
    protected virtual void LoadConfigurationAsset()

    LoadConfigurationFromFile(string)

    Loads a scenario configuration from a file located at the given file path

    Declaration
    public void LoadConfigurationFromFile(string filePath)
    Parameters
    Type Name Description
    string filePath

    The file path of the scenario configuration file

    Exceptions
    Type Condition
    FileNotFoundException

    OnAwake()

    OnAwake is called when this scenario MonoBehaviour is created or instantiated

    Declaration
    protected virtual void OnAwake()

    OnComplete()

    OnComplete is called when this scenario's isScenarioComplete property returns true during its main update loop

    Declaration
    protected virtual void OnComplete()

    OnDestroy()

    OnDestroy is called before this scenario destroyed

    Declaration
    protected void OnDestroy()

    OnDisable()

    OnEnable is called when this scenario is disabled

    Declaration
    protected virtual void OnDisable()

    OnEnable()

    OnEnable is called when this scenario is enabled

    Declaration
    protected virtual void OnEnable()

    OnIdle()

    OnIdle is called each frame after the scenario has completed

    Declaration
    protected virtual void OnIdle()

    OnIterationEnd()

    OnIterationStart is called after each iteration has completed

    Declaration
    protected virtual void OnIterationEnd()

    OnIterationStart()

    OnIterationStart is called before a new iteration begins

    Declaration
    protected virtual void OnIterationStart()

    OnResumeSimulation()

    Tries to restore previous simulation state

    Declaration
    protected virtual void OnResumeSimulation()

    OnStart()

    OnStart is called when the scenario first begins playing

    Declaration
    protected virtual void OnStart()

    OnUpdate()

    OnUpdate is called every frame while the scenario is playing

    Declaration
    protected virtual void OnUpdate()

    Quit()

    Exit to playmode if in the Editor or quit the application if in a built player

    Declaration
    protected void Quit()

    RemoveRandomizerAt(int)

    Remove the randomizer present at the given index

    Declaration
    public void RemoveRandomizerAt(int index)
    Parameters
    Type Name Description
    int index

    The index of the randomizer to remove

    ResetRandomStateOnIteration()

    Resets SamplerState.randomState with a new seed value generated by hashing this Scenario's randomSeed with its currentIteration

    Declaration
    protected virtual void ResetRandomStateOnIteration()

    Restart()

    Restart the scenario

    Declaration
    public void Restart()

    RestartIteration()

    Set a flag, that current simulation should be restarted

    Declaration
    public void RestartIteration()

    SerializeToFile(string)

    Serializes the scenario's constants and randomizer settings to a JSON file located at the path resolved by the defaultConfigFilePath scenario property

    Declaration
    public virtual void SerializeToFile(string filePath)
    Parameters
    Type Name Description
    string filePath

    The file path to serialize the scenario to

    SerializeToJson()

    Serializes the scenario's constants and randomizer settings to a JSON string

    Declaration
    public virtual string SerializeToJson()
    Returns
    Type Description
    string

    The scenario configuration as a JSON string

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)