Tony Li wrote: ↑Wed Oct 07, 2020 8:42 pm
You may need to set the PC node's Sequence to make it do something. If it's blank, it may skip immediately to the next node.
Not sure if I understand this, I'm passing through that PROGRESS CHECK state in the conversation, where I have 2 sequence commands like I showed you before:
Code: Select all
AnimatorPlayWait(HideLeft, Dialogue Panel);
Continue();
But on the other hand, the big conversation that contains all the others had no Actor or Conversant assigned, so I tried with both assigning the Player and the NPC (we only have these 2), no luck.
So I suppose you're talking about having some sequencer command, and I do have 2.
-
About the script:
I did what you told me, the coee you passed me (thanks!) had 2 problems:
- It didn't find the UITextField method, so I had to add PixelCrushers. before it.
- there was no animator declared, so it didn't know which animator to check the state of, in the last method, so I added it at the beginning
So here's the new code I tried with (the ciao, ciao2 and ciao3 Debug.Logs are for making sure it enters the methods, which it does, but still no difference):
Code: Select all
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
using System;
using PixelCrushers.DialogueSystem;
public class MountainUISubtitlePanel : StandardUISubtitlePanel
{
public Animator animator;
public override void SetContent(Subtitle subtitle)
{
Debug.Log("ciao");
// Make sure we run the StartTypingWhenFocused coroutine:
delayTypewriterUntilOpen = true;
hasFocus = false;
// Call the base method. With the values above set, we know it will call StartTypingWhenFocused.
base.SetContent(subtitle);
}
// Override this method to wait until the animator is at the end of the Show() state.
public override IEnumerator StartTypingWhenFocused(PixelCrushers.UITextField subtitleText, string text, int fromIndex)
{
Debug.Log("ciao2");
subtitleText.text = string.Empty;
float timeout = Time.realtimeSinceStartup + 5f; // This is just a safety valve to prevent infinite loops.
while (!IsAtEndOfShowState() && Time.realtimeSinceStartup < timeout)
{
yield return null;
}
subtitleText.text = text;
TypewriterUtility.StartTyping(subtitleText, text, fromIndex);
}
// This function returns true if we're at the end of the Show() state.
protected bool IsAtEndOfShowState()
{
Debug.Log("ciao3");
var currentAnimatorState = animator.GetCurrentAnimatorStateInfo(0);
return currentAnimatorState.IsName("Show") &&
currentAnimatorState.normalizedTime >= 0.99f; // Give floating point error margin.
}
}
The original StandardUISubtitlePanel had a method which was protected, so I couldn't override it (don't remember if it was SetContent() itself or StartTypingWhenFocused() ) anyway, I changed it from protected to public, that's the only edit I did to the original files.
Then, being my new one a subclass deriving from the StandardUISubtitlePanel, it used the same Inspector GUI, which was encapsulated in another script called
StandardUISubtitlePanelEditor. I didn't want to make modifications on the original stuff, so I created an Editor script that applies a new GUI only to my script, which is this one (the only difference is I tried to add an animator field, to give it the Dialogue Panel one):
Code: Select all
// Copyright (c) Pixel Crushers. All rights reserved.
using UnityEngine;
using UnityEditor;
namespace PixelCrushers.DialogueSystem
{
[CustomEditor(typeof(MountainUISubtitlePanel), true)]
public class MountainUISubtitlePanelEditor : StandardUISubtitlePanelEditor
{
public new void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.LabelField("Dialogue Panel reference", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("animator"), true);
EditorGUILayout.LabelField("UI Elements", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("panel"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("portraitImage"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("portraitName"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("subtitleText"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("continueButton"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onlyShowNPCPortraits"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("useAnimatedPortraits"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("accumulateText"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("addSpeakerName"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("addSpeakerNameFormat"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("delayTypewriterUntilOpen"), true);
EditorGUILayout.LabelField(new GUIContent("Navigation", "Joystick/keyboard navigation settings."), EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("firstSelected"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("focusCheckFrequency"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("refreshSelectablesFrequency"), true);
var selectPreviousOnDisableProperty = serializedObject.FindProperty("selectPreviousOnDisable");
if (selectPreviousOnDisableProperty != null) EditorGUILayout.PropertyField(selectPreviousOnDisableProperty); // Not present in older versions of UIPanel.
EditorGUILayout.LabelField("Visibility", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(serializedObject.FindProperty("visibility"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("startState"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("showAnimationTrigger"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("hideAnimationTrigger"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("focusAnimationTrigger"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("unfocusAnimationTrigger"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_hasFocus"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onOpen"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onClose"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onFocus"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onUnfocus"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("onBackButtonDown"), true);
serializedObject.ApplyModifiedProperties();
}
}
}
But I cannot seem to be able to make the new field appear.
Your inspector debug mode was really helpful because in that way I can tell my subclass which animator it needs to check anyway, even without the field serialized.
-
Anyway, despite now the subclass is integrated, put into the Subtitle Panel and no errors in console... still no change, still the typewriter effect starts no matter what's happening to the Dialogue Panel.
Tony Li wrote: ↑Wed Oct 07, 2020 8:42 pm
FlaconiaUnited wrote: ↑Thu Oct 08, 2020 12:46 am
should I just change the conditions nedeed to enter the IF/ELSE to that specific state of the animator?
I'm sorry; I don't understand that. But the subclass may do the trick for you.
Sorry, nothing important here, I just wasn't understand how to structure all this but then you've been clear, never mind.
So, any other ideas on how to achieve this?
I'm starting to think that if animating the UI this way is something so hard to achieve maybe it doesn't make much sense, but I feel a little bit limited to not being able to animate the UI the way I want...