CriManaMovieController
- The "CriManaMovieController component" is used to control movie playback in CRI Sofdec.
- In the Inspector, you can set the movie playback parameters for the CriWare.CriManaMovieController component.
For details about its parameters, please see the CriWare.CriManaMovieController .
Simple usage is shown below:
- Enter the name of a movie file from the Inspector in Unity Editor.
Note that only file name should be specified (without directory name), e.g., sample_256x256.usm. Then place the movie file in the StreamingAssets folder.
Using a custom shader
- The CriManaMovieController can change the shader used for the movie playback. Use the CriManaMovieController.player.SetShaderDispatchCallback method to change the shader.
By using this method, a callback function for the shader allocation can be registered.
For example, attaching the following class to the object to which the CriManaMovieController component has been assigned is easy.
public class AttacheUserCustomShader : MonoBehaviour {
void OnEnable () {
CriManaMovieController controller = GetComponent<CriManaMovieController>();
controller.player.SetShaderDispatchCallback(ShaderDispatch);
}
static UnityEngine.Shader ShaderDispatch(MovieInfo movieInfo,
bool additiveMode)
{
if (movieInfo.codecType != CodecType.SofdecPrime) {
Debug.LogError("Unknonw codec type");
return Shader.Find("VertexLit");
}
return Shader.Find(additiveMode ? "name of the shader used in additive blending" : "name of the shader not used in additive blending");
}
}
Please note that the registration must be done before playing the movie.
Creating a custom shader
- Usethe ShaderLab language to describe a custom shader.
Default shaders can be found at the location below. Use them as a reference to create a custom shader.
For more information about the ShaderLab language, please see the Unity reference manual.
Location of the default shaders
|
|
|
|
|
|
|
|
|
|
|
|
: Shader for rendering RGB textures
|
|
: Shader for color conversion and rendering in RGB
|
|
CriManaMovieControllerForUI
- This component is used for playing movies via the Unity UI. The basic usage is the same as the CriManaMovieController's, and the CriManaMovieControllerForUI.target doesn't receive the UnityEngine.Renderer but UnityEngine.UI.Graphic .
Attention when Destroying this Component
- When Destroy is called on this component, a stop function is called internally. This function waits until the state’s transition is complete, and also supports the discarding during playback.
Note that if the destruction is performed while rendering the textures, an unexpected issue may occur depending on the timing.
Therefore, in order to destroy the component, we recommend to explicitly stop the playback, and to waiting until the state’s transition is complete to destroy the component.
Migration from the CriManaPlayer to the CriManaMovieController
- This section explains notes about migration from the CriManaPlayer to the CriManaMovieController.
Migration in Unity Editor
- Show the object to which the CriManaPlayer has been attached in the Inspector.
- Remove the CriManaPlayer component.
- Attach the CriManaMovieController component.
The CriManaMovieController component doesn't have the following properties of the CriManaPlayer component:
- Flip Top/Bottom
- Flip Top/Bottom
- Volume
The Flip property can be replaced on a program by using the SetTextureOffset method of the Material class in Unity API.
The Volume property can be replaced with the SetVolume method of the CriMana.Player class.
Migration on script
Replace the CriManaPlayer component with the CriManaMovieController component.
The correspondence relationship of basic members in the methods and the properties are shown below:
Relationship between CriManaPlayer and CriManaMovieController
CriManaPlayer | CriManaMovieController |
SetFile | player.SetFile |
Play | player.Start |
Stop | player.Stop |
status | player.status |
An example of script replacement is shown below.
Please use it for your reference.
- CriManaPlayer (before replacement)
public GameObject movieObject;
private CriManaPlayer moviePlayer;
private CriFsBinder binder;
moviePlayer = movieObject.AddComponent<CriManaPlayer>();
moviePlayer.SetFile(binder, "sample.usm");
moviePlayer.Play();
- CriManaMovieController (after replacement)
public GameObject movieObject;
private CriManaMovieController moviePlayer;
private CriFsBinder binder;
moviePlayer = movieObject.AddComponent<CriManaMovieController>();
moviePlayer.useOriginalMaterial = true;
moviePlayer.player.SetFile(binder, "sample.usm");
moviePlayer.player.Start();