SAMInitializer Class

public class SAMInitializer : MonoBehaviour

This component can be added to the scene and used to Initialize SAM, either immediately (over two frames) or gradually over multiple frames (note, the component is added automatically when using the Default SAM Setup command).

The class has be configured in a generic way to update a slider value and text if you wish. To use these features, add one of the built in SAMText and/or SAMSlider components to their corresponding UI component, or create and add a custom SAMText and/or SAMSlider to the scene. Then assign those components to the appropriate fields via the inspector.

The Initializer is also capable of activating and/or deactivating objects before and/or after the Initialization occurs. Just add the objects to the appropriate lists.

Initialization can be triggered via another script, by hooking into a button's On Click event, or through whatever other means you have available to you.

Properties

Name Type Description
IsInitialized bool

Gets a value indicating whether SAM has been initialized.

Methods

InitializeSAM_Gradual()

public void InitializeSAM_Gradual()

Initializes SAM gradually. This will call ComponentManager.InitializeGradually, which will execute over multiple frames.

If you need to track when the Initialization completes, you have three options:

1) Check the IsInitialized property and wait for it to return true.

2) Subscribe to the ComponentManagerInitialized event on the scene's Component Manager before calling this method.

3) Use the InitializeSAM_GradualCoroutine method instead, calling it like a coroutine.


InitializeSAM_GradualCoroutine()

public IEnumerator<YieldInstruction> InitializeSAM_GradualCoroutine()

Initializes SAM gradually. This will call ComponentManager.InitializeGradually, which will execute over multiple frames.

This method is similar to InitializeSAM_Gradual, except that this method can be used as a coroutine or otherwise iterated

Returns

IEnumerator<YieldInstruction>
An IEnumerator<YieldInstruction> that can be iterated over or used as a coroutine. See the YieldInstruction page for more info.


InitializeSAM_Immediate()

public void InitializeSAM_Immediate()

Initializes SAM immediately. This will call ComponentManager.Initialize, which will execute over this frame and the following frame to initialize everything regarding SAM. Because initialization is not completed in the same frame that this method is called, you should rely on the OnInitialized callback to perform other actions that rely on initialization to be fully completed.


SetProgress(float)

public void SetProgress(float progress)

Sets the progress used by the Progress Slider and Text (if neither are assigned, this will do nothing).

Normally you would not need to call this method, as the SAMInitializer automatically does so while the Component Manager is being initialized gradually.

However, if you have additional operations being run before and/or after the Component Manager is initialized, and these operations also take time, you may wish for their progress to be tracked by the Progress Slider and Text.

In these instances, you can call this method in order to update the Slider and Text. When doing so, you must decide how much progress to allocate for each operations runtime, including the Component Manager's Gradual Initialization. You can define this allocation using the Progress Start and Progress End settings. As the Component Manager's Initialization Progress runs from 0f to 1f, the SAM Initializer will lerp between Progress Start and Progress End and set the Progress Slider and Text to the lerped value.

If the Component Manager's initialization takes up the bulk of the loading screen time, you should not need to call this method manually, however you should make sure to set Progress Start to 0 and Progress End to 1.

Parameters

Name Type Description
progress float

The overall progress, as a value between 0 and 1f, that the SAM Initializer's Progress Slider and/or Text are tracking.