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.

Methods

InitializeSAM_Gradual()

public void InitializeSAM_Gradual()

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

If you want to be notified when the Initialization completes, subscribe to the ComponentManagerInitialized event on the scene's Component Manager before calling this method.


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.


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.