After updating to v1.66.1, during subtitle pops up the line speaker = menuSpeech.GetSpeakingCharacter(); gives the error of:
NullReferenceException: Object reference not set to an instance of an object
UpdateDummyTextAndSetArrowSize_DuplicateForEachLine_SuperText.Start () (at Assets/Ricky/Scripts/UI/Dialog/UpdateDummyTextAndSetArrowSize_DuplicateForEachLine_SuperText.cs:60)
Related scripts are:
**
private Speech menuSpeech;
private Char speaker;
private void OnEnable ()
{
Menu menu = KickStarter.playerMenus.GetMenuWithCanvas (GetComponent Canvas);
menuSpeech = menu.speech;
if (menuSpeech != null) {
dummySuperText.text = menuSpeech.log.fullText;
}
}
private void Start()
{
speaker = menuSpeech.GetSpeakingCharacter ();
if (speaker != null)
superText.color = speaker.speechColor;
}
**
It also says something like "The character has been upgraded temporally, check the inspector to upgrade it permanently" at some point during test play in the Editor. Is this related?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You're null-checking for your speaker variable, so I'd say it's that "menuSpeech" hasn't been assigned and that GetSpeakingCharacter is not the issue.
Have you tried moving the code in Start() to the end of the OnEnable() function?
No. See the upgrade notes concerning the new "Facing directions" field. The Console message should be heeded by viewing your character's Inspector outside of runtime.
You are right, it is the menuSpeech = menu.speech; somehow returns null to menuSpeech.
I used Debug.log to test and found if this script:
**
Menu menu = KickStarter.playerMenus.GetMenuWithCanvas (GetComponent Canvas);
menuSpeech = menu.speech;
**
is in OnEnable(), menuSpeech is null.
If it is in Start(), menuSpeech isn't null, but the script:
**
if (menuSpeech != null) {
dummySuperText.text = menuSpeech.log.fullText;
}
panelSizeX = dummySuperText.textMesh.bounds.size.x;
**
which is under menuSpeech = menu.speech; in Start(), cannot use panelSizeX to correctly set the dialog bubble size that fit the full text.
Before the AC version update there wasn't this issue. Are there fundamental changes in AC speech menu?
What version were you updating from?
I don't understand your issue now. In what way can you not use panelSizeX? Is it giving you an error? Is dummySuperText.text not filled?
Please elaborate on the problem so that I can recreate - post the full script, and screens of your Menu properties / UI prefab.
I updated from 1.65.2
I think the main issue is that menuSpeech = menu.speech; doesn't work in OnEnable() now. But it only works in Start().
I need dummySuperText.text = menuSpeech.log.fullText; to be in OnEnable() because I wish to set the Subtitle panel size by panelSizeX = dummySuperText.textMesh.bounds.size.x;.
I found that while panelSizeX = dummySuperText.textMesh.bounds.size.x; can be used in Start(), dummySuperText.text = menuSpeech.log.fullText; has to be in OnEnable() to work correctly.
Currently I am using
dialog = FindObjectOfType ();
and
dummySuperText.text = dialog.GetLatestSpeech().log.fullText;
in OnEnable() to achieve the effect. But I guess using FindObjectOfType is less desirable for performance consideration.
Why is this? In what way is it failing if you put in Start()?
If I'm to recreate this, I'll need the full script as well as details on how your Canvas is set up. This is using TextMeshPro?
Recreated, will address.