9
Assets/RPGTALK/Scripts/RPGTalkCinematic/Editor.meta
generated
Normal file
9
Assets/RPGTALK/Scripts/RPGTalkCinematic/Editor.meta
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 582c3ff5f0157400ea8f12c8f9611e98
|
||||
folderAsset: yes
|
||||
timeCreated: 1505257750
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,48 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(RPGTalkCinematicBehaviour))]
|
||||
public class RPGTalkCinematicDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight (SerializedProperty property, GUIContent label)
|
||||
{
|
||||
int fieldCount = 0;
|
||||
return fieldCount * EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
SerializedProperty txtToParseProp= property.FindPropertyRelative("txtToParse");
|
||||
SerializedProperty lineToStartProp = property.FindPropertyRelative("lineToStart");
|
||||
SerializedProperty lineToBreakProp = property.FindPropertyRelative("lineToBreak");
|
||||
SerializedProperty textSpeedProp = property.FindPropertyRelative("textSpeed");
|
||||
SerializedProperty pauseUntilTalkEndProp = property.FindPropertyRelative("pauseUntilTalkEnd");
|
||||
SerializedProperty autoPass = property.FindPropertyRelative("autoPass");
|
||||
SerializedProperty secondsAutoPass = property.FindPropertyRelative("secondsAutoPass");
|
||||
|
||||
EditorGUILayout.LabelField("Put below the Text file to be parsed and become the talks!");
|
||||
EditorGUILayout.PropertyField (txtToParseProp,GUIContent.none);
|
||||
if (txtToParseProp.objectReferenceValue == null) {
|
||||
EditorGUILayout.HelpBox("If no text is setted, it will be used the same that already is in the RPGTalk reference", MessageType.Info, true);
|
||||
}
|
||||
|
||||
pauseUntilTalkEndProp.boolValue = GUILayout.Toggle(pauseUntilTalkEndProp.boolValue, "Pause Timeline while waiting for player's action?");
|
||||
autoPass.boolValue = GUILayout.Toggle(autoPass.boolValue, "Automatically Pass the Talk?");
|
||||
if (autoPass.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(secondsAutoPass,true);
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("What line should the talk start? And in what should it end?");
|
||||
EditorGUILayout.BeginHorizontal ();
|
||||
EditorGUILayout.PropertyField (lineToStartProp,GUIContent.none);
|
||||
if (pauseUntilTalkEndProp.boolValue || autoPass.boolValue) {
|
||||
EditorGUILayout.PropertyField (lineToBreakProp, GUIContent.none);
|
||||
} else {
|
||||
EditorGUILayout.HelpBox("If you not wait for player input or make the talk auto pass, each RPGTalk Cinematic Clip can only contain one line", MessageType.Info, true);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal ();
|
||||
EditorGUILayout.PropertyField (textSpeedProp);
|
||||
}
|
||||
}
|
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/Editor/RPGTalkCinematicDrawer.cs.meta
generated
Normal file
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/Editor/RPGTalkCinematicDrawer.cs.meta
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36b2de13f84614160a08b109864e1f38
|
||||
timeCreated: 1505257750
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,240 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
using RPGTALK.Timeline;
|
||||
|
||||
[Serializable]
|
||||
public class RPGTalkCinematicBehaviour : PlayableBehaviour
|
||||
{
|
||||
|
||||
//The variables of the RPGTalk that will be changed
|
||||
public TextAsset txtToParse;
|
||||
public string lineToStart = "1";
|
||||
public string lineToBreak = "-1";
|
||||
public float textSpeed = 50;
|
||||
[Tooltip("Should the timeline be paused until the player finish the talk?")]
|
||||
public bool pauseUntilTalkEnd;
|
||||
|
||||
RPGTalk m_TrackBinding;
|
||||
bool m_FirstFrameHappened;
|
||||
bool reachedFinal;
|
||||
|
||||
//Saving the defaults
|
||||
TextAsset m_txtToParse;
|
||||
string m_lineToStart = "1";
|
||||
string m_lineToBreak = "-1";
|
||||
float m_textSpeed = 50;
|
||||
bool m_enableQuickSkip = true;
|
||||
bool m_enablePass = true;
|
||||
RPGTalkTimeline rpgTime;
|
||||
|
||||
//AutoPass
|
||||
public bool autoPass;
|
||||
public float secondsAutoPass;
|
||||
double[] startTime;
|
||||
|
||||
// Playable playableObj;
|
||||
|
||||
|
||||
//Each frame of the behaviour
|
||||
public override void ProcessFrame (Playable playable, FrameData info, object playerData)
|
||||
{
|
||||
m_TrackBinding = playerData as RPGTalk;
|
||||
if (!m_FirstFrameHappened) {
|
||||
OnBehaviourPlay (playable, info);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//for now, we wont support spped changes into timeline
|
||||
if(m_TrackBinding.actualTextSpeed != textSpeed){
|
||||
m_TrackBinding.actualTextSpeed = textSpeed;
|
||||
}
|
||||
|
||||
|
||||
if(m_TrackBinding.cutscenePosition > m_TrackBinding.rpgtalkElements.Count)
|
||||
{
|
||||
m_TrackBinding.cutscenePosition = m_TrackBinding.rpgtalkElements.Count;
|
||||
}
|
||||
|
||||
|
||||
//The current character will be calculated based on the textspeed and the time of the playable
|
||||
float currentChar = m_TrackBinding.actualTextSpeed * (float)(playable.GetTime() - startTime[m_TrackBinding.cutscenePosition - 1] );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (currentChar >= 0)
|
||||
{
|
||||
//only change it if there is something new to change and we are not paused
|
||||
if (Mathf.Min(currentChar, m_TrackBinding.rpgtalkElements[m_TrackBinding.cutscenePosition - 1].dialogText.Length)
|
||||
!= m_TrackBinding.currentChar && (!rpgTime || !rpgTime.isPaused))
|
||||
{
|
||||
m_TrackBinding.currentChar = currentChar;
|
||||
m_TrackBinding.PutRightTextToShow();
|
||||
}
|
||||
}
|
||||
|
||||
//if we are autopassing it
|
||||
if (autoPass)
|
||||
{
|
||||
//If we still have more in that talk...
|
||||
if (m_TrackBinding.cutscenePosition < m_TrackBinding.rpgtalkElements.Count)
|
||||
{
|
||||
//If we passed the time that the last character on that cutscene should have been seen
|
||||
if (playable.GetTime() >= startTime[m_TrackBinding.cutscenePosition])
|
||||
{
|
||||
m_TrackBinding.cutscenePosition++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//If, for some reason, we are playing the timeline backwards...
|
||||
if (m_TrackBinding.cutscenePosition > 1 && playable.GetTime() < startTime[m_TrackBinding.cutscenePosition - 1])
|
||||
{
|
||||
m_TrackBinding.cutscenePosition--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//If we reached the final, check if we should pause the timeline until the player finish the talk
|
||||
if (playable.GetTime () >= playable.GetDuration () - (double)0.1) {
|
||||
if (!reachedFinal) {
|
||||
reachedFinal = true;
|
||||
if(pauseUntilTalkEnd){
|
||||
if (!rpgTime) {
|
||||
Debug.LogError ("To use the option 'Pause Until Talk End' the RpgTalk must contain a RPGTalkTimeline Component");
|
||||
} else {
|
||||
rpgTime.Pause ();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reachedFinal = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnBehaviourPlay (Playable playable, FrameData info)
|
||||
{
|
||||
if (!m_TrackBinding)
|
||||
return;
|
||||
|
||||
if (!m_FirstFrameHappened)
|
||||
{
|
||||
//on the first frame, set the defaults to recover after
|
||||
m_txtToParse = m_TrackBinding.txtToParse;
|
||||
m_lineToBreak = m_TrackBinding.lineToBreak;
|
||||
m_lineToStart = m_TrackBinding.lineToStart;
|
||||
m_textSpeed = m_TrackBinding.textSpeed;
|
||||
m_enableQuickSkip = m_TrackBinding.enableQuickSkip;
|
||||
m_enablePass = m_TrackBinding.enablePass;
|
||||
|
||||
//change the rpgTalk parameters
|
||||
if (txtToParse != null) {
|
||||
m_TrackBinding.txtToParse = txtToParse;
|
||||
}
|
||||
|
||||
//If we won't wait for player action to finish, only one line (line to start) will be allowed.
|
||||
if (!pauseUntilTalkEnd) {
|
||||
//If we didn't set neither pauseUntilTalkEnd or autoPass, then we can't have lineToBreak.
|
||||
if (!autoPass) {
|
||||
m_TrackBinding.lineToBreak = lineToStart;
|
||||
}else{
|
||||
m_TrackBinding.lineToBreak = lineToBreak;
|
||||
}
|
||||
m_TrackBinding.enablePass = false;
|
||||
} else {
|
||||
m_TrackBinding.enablePass = true;
|
||||
m_TrackBinding.lineToBreak = lineToBreak;
|
||||
}
|
||||
m_TrackBinding.lineToStart = lineToStart;
|
||||
m_TrackBinding.textSpeed = textSpeed;
|
||||
m_TrackBinding.enableQuickSkip = false;
|
||||
|
||||
m_FirstFrameHappened = true;
|
||||
m_TrackBinding.NewTalk ();
|
||||
|
||||
startTime = new double[m_TrackBinding.rpgtalkElements.Count];
|
||||
for(int i = 0; i < m_TrackBinding.rpgtalkElements.Count; i++)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
startTime[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime[i] = (m_TrackBinding.rpgtalkElements[i-1].dialogText.Length
|
||||
/ m_TrackBinding.actualTextSpeed) + secondsAutoPass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Put an event for the end of the talk
|
||||
m_TrackBinding.OnEndTalk += OnEndTalk;
|
||||
|
||||
if (m_TrackBinding.GetComponent<RPGTalkTimeline> ()) {
|
||||
rpgTime = m_TrackBinding.GetComponent<RPGTalkTimeline> ();
|
||||
}
|
||||
|
||||
// playableObj = playable;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OnBehaviourPause (Playable playable, FrameData info)
|
||||
{
|
||||
if (!m_TrackBinding)
|
||||
return;
|
||||
|
||||
if (m_FirstFrameHappened) {
|
||||
//Let's make everything go back to the defaults
|
||||
ReturnDefaults ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGraphStop (Playable playable)
|
||||
{
|
||||
if (!m_TrackBinding)
|
||||
return;
|
||||
|
||||
if (m_FirstFrameHappened) {
|
||||
//Let's make everything go back to the defaults
|
||||
ReturnDefaults ();
|
||||
}
|
||||
}
|
||||
|
||||
void ReturnDefaults(){
|
||||
m_TrackBinding.txtToParse = m_txtToParse;
|
||||
m_TrackBinding.lineToBreak = m_lineToBreak;
|
||||
m_TrackBinding.lineToStart = m_lineToStart;
|
||||
m_TrackBinding.textSpeed = m_textSpeed;
|
||||
m_TrackBinding.enableQuickSkip = m_enableQuickSkip;
|
||||
m_TrackBinding.enablePass = m_enablePass;
|
||||
|
||||
m_FirstFrameHappened = false;
|
||||
m_TrackBinding.EndTalk();
|
||||
m_TrackBinding.OnEndTalk -= OnEndTalk;
|
||||
|
||||
rpgTime = null;
|
||||
}
|
||||
|
||||
void OnEndTalk(){
|
||||
//When a talk has finished, should we resume the timeline?
|
||||
if(pauseUntilTalkEnd){
|
||||
if (rpgTime) {
|
||||
rpgTime.Resume ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicBehaviour.cs.meta
generated
Normal file
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicBehaviour.cs.meta
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1419de531726344bea35c82b56b9a412
|
||||
timeCreated: 1505257750
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
[Serializable]
|
||||
public class RPGTalkCinematicClip : PlayableAsset, ITimelineClipAsset
|
||||
{
|
||||
public RPGTalkCinematicBehaviour template = new RPGTalkCinematicBehaviour ();
|
||||
|
||||
public ClipCaps clipCaps
|
||||
{
|
||||
get { return ClipCaps.None; }
|
||||
}
|
||||
|
||||
public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)
|
||||
{
|
||||
var playable = ScriptPlayable<RPGTalkCinematicBehaviour>.Create (graph, template);
|
||||
return playable;
|
||||
}
|
||||
|
||||
}
|
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicClip.cs.meta
generated
Normal file
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicClip.cs.meta
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 479ec74219d674ef8b34abb60a3e4c46
|
||||
timeCreated: 1505257750
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
[TrackColor(0.8000001f, 0f, 0f)]
|
||||
[TrackClipType(typeof(RPGTalkCinematicClip))]
|
||||
[TrackBindingType(typeof(RPGTalk))]
|
||||
public class RPGTalkCinematicTrack : TrackAsset
|
||||
{
|
||||
|
||||
}
|
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicTrack.cs.meta
generated
Normal file
12
Assets/RPGTALK/Scripts/RPGTalkCinematic/RPGTalkCinematicTrack.cs.meta
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae73b500806184683984c426a823655a
|
||||
timeCreated: 1505257750
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user