Pages 1
Universal Fighting Engine Forum We are no longer using the forum to answer questions due to bot attacks. Please use our discord instead: https://discord.gg/hGMZhF7 |
You are not logged in. Please login or register.
Universal Fighting Engine Forum → UFE 1 Source (Deprecated) → Combine cinema director and ufe3d for better cutscenes [tutorial]
Ok so what I did was I took the example scene from cinema director and parented everything in that hierarchy into an empty gameobject. Then I saved that as a prefab. Doing this to every cutscene you make with cinema director should work no problem (in theory).
then I made StoryModeVideoScreen.cs look as such (I mainly changed things in the LoadMovie Ienumerator)
using CinemaDirector;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StoryModeVideoScreen : StoryModeScreen {
#region public class properties
public static readonly string Data = "%Data%";
public static readonly string Persistent = "%Persistent%";
public static readonly string StreamingAssets = "%StreamingAssets%";
public static readonly string Temp = "%Temp%";
#endregion
#region public instance properties
//public MovieTexture movie;
public GameObject CSprefab;
[SerializeField]
private Cutscene cs;
[SerializeField]
GameObject clone;
// The name of the video file in the StreamingAssets folder
public bool skippable = true;
public bool stopMusicImmediatelyAfterSkippingVideo = true;
public bool stopVideoImmediatelyAfterSkippingVideo = true;
public float delayBeforePlayingVideo = 0.05f;
public float delayAfterSkippingVideo = 0.05f;
#endregion
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_WP8 || UNITY_IOS)
public override void OnShow (){
base.OnShow ();
Handheld.PlayFullScreenMovie(
this.mobilePlatformsPath,
Color.black,
FullScreenMovieControlMode.Hidden,
FullScreenMovieScalingMode.AspectFill
);
this.GoToNextScreen();
}
#elif !UNITY_EDITOR && UNITY_WEBGL
public override void OnShow (){
base.OnShow ();
this.GoToNextScreen();
}
#else
public override void OnShow (){
base.OnShow ();
this.transform.parent = null;
this.transform.localPosition = Vector3.zero;
this.transform.localRotation = Quaternion.identity;
this.transform.localScale = Vector3.one;
this.StartCoroutine(this.LoadMovie());
}
protected virtual IEnumerator LoadMovie(){
clone = Instantiate(CSprefab, Vector3.zero, Quaternion.identity) as GameObject;
cs = clone.GetComponentInChildren<Cutscene>();
// Assign the movie to a GUITexture...
GUITexture guiTexture = this.GetComponent<GUITexture>();
if (guiTexture == null){
guiTexture = this.gameObject.AddComponent<GUITexture>();
}
//AudioClip audio = movie.audioClip;
//guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
//guiTexture.texture = movie;
// Wait the min delay before starting playing the video
if (this.delayBeforePlayingVideo > 0){
guiTexture.color = Color.black;
yield return new WaitForSeconds(this.delayBeforePlayingVideo);
}
guiTexture.color = Color.white;
// Wait until we have enough information to start playing the movie...
while (CSprefab == null){
yield return null;
}
// When we're ready to start playing the image, resize the texture
//guiTexture.pixelInset = new Rect(0.5f * Screen.width, 0.5f * Screen.height, 0f, 0f);
// Start playing the movie
//cs.Play();
while (cs.state == Cutscene.CutsceneState.Inactive) { yield return null; }
//-------------------------------------------------------------------------------------------------------------
// We need to enable the sound during the duration of the movie because it doesn't matter the user settings,
// we want him to hear the AudioClip. However, we need to play this sound as music because Unity won't allow
// us to play streamed audio as SoundFX (Unity doesn't throw an error, but the AudioClip isn't played).
//-------------------------------------------------------------------------------------------------------------
Camera.main.GetComponent<AudioListener>().enabled = false;
bool musicEnabled = UFE.GetMusic();
bool musicLooped = UFE.IsMusicLooped();
float musicVolume = UFE.GetMusicVolume();
AudioClip clip = UFE.GetMusicClip();
//UFE.SetMusic(true);
UFE.LoopMusic(false);
//UFE.SetMusicVolume(1f);
//UFE.PlayMusic(audio);
//-------------------------------------------------------------------------------------------------------------
// After the video finish, restore the original audio settings.
//-------------------------------------------------------------------------------------------------------------
while(cs.state == Cutscene.CutsceneState.Playing && !(cs.IsSkippable && Input.anyKeyDown)){ yield return null; }
//-------------------------------------------------------------------------------------------------------------
// Check if the video has been skipped. In that case, wait for the "delay after skipping video" time.
//-------------------------------------------------------------------------------------------------------------
if (cs.state == Cutscene.CutsceneState.Playing && this.delayAfterSkippingVideo > 0f){
if (this.stopMusicImmediatelyAfterSkippingVideo){
UFE.StopMusic();
}
if (this.stopVideoImmediatelyAfterSkippingVideo){
//movie.Stop();
Camera.main.GetComponent<AudioListener>().enabled = true;
cs.Skip();
print("killing the cutscene");
GameObject.DestroyImmediate(clone);
guiTexture.color = Color.black;
}
yield return new WaitForSeconds(this.delayAfterSkippingVideo);
}
//-------------------------------------------------------------------------------------------------------------
// If we haven't done it yet, stop the video, the audio and free the used memory
//-------------------------------------------------------------------------------------------------------------
print("were done");
UFE.StopMusic();
//cs.Skip();
//movie.Stop();
//GameObject.DestroyObject(clip);
GameObject.DestroyImmediate(clone);
Camera.main.GetComponent<AudioListener>().enabled = true;
//-------------------------------------------------------------------------------------------------------------
// Finally, restore the original audio settings...
//-------------------------------------------------------------------------------------------------------------
UFE.SetMusic(musicEnabled);
UFE.LoopMusic(musicLooped);
UFE.SetMusicVolume(musicVolume);
UFE.PlayMusic(clip);
//-------------------------------------------------------------------------------------------------------------
// And go to the next screen
//-------------------------------------------------------------------------------------------------------------
this.GoToNextScreen();
}
#endif
}
if you have trouble exposing the state from Cutscene.cs inside cinema director, what I did was just change that from private to public. so that should do it.
How can i use this cinema director cut scene in player intro ?
Universal Fighting Engine Forum → UFE 1 Source (Deprecated) → Combine cinema director and ufe3d for better cutscenes [tutorial]
Powered by PunBB, supported by Informer Technologies, Inc.