Text changes from white to black at runtime

Announcements, support questions, and discussion for Quest Machine.
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Text changes from white to black at runtime

Post by Passero »

I'm using the default quest machine prefabs but changes some images.
Didn't touch the components or anything.

It's all the text under the Quest machine canvas that is affected so also the quest in the hud which appears in black instead of white as well as all the text on buttons.
See screenshot...

I had this once before so I removed the quest machine prefab and added it again which solved the problem but it seems like as soon as I alter some things, it starts doing this.

What could cause this?

I'm only changing images for the background, positions and sizes. I'm not adding/removing/altering any of the quest machine specific components.

The weird thing is also that when I stop playing the game, the text in the editor also appears black but as soon as I open the quest machine machine prefab, it changes back to white. But when I play the game and open a quest, it changes back to black.

I also see a warning in my console that's coming from QM but not sure if it's related as I always get this warning...

Code: Select all

QuestMachine: QuestSubasset.CloneList<QuestContent>: Element 0 is null.
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.QuestMachine.QuestSubasset:CloneList(List`1) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest Subasset/QuestSubasset.cs:145)
PixelCrushers.QuestMachine.QuestStateInfo:CloneSubassetsInto(QuestStateInfo) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest State/QuestStateInfo.cs:126)
PixelCrushers.QuestMachine.QuestStateInfo:CloneSubassets(List`1, List`1) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest State/QuestStateInfo.cs:205)
PixelCrushers.QuestMachine.Quest:Clone() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:574)
PixelCrushers.QuestMachine.QuestListContainer:AddQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:178)
PixelCrushers.QuestMachine.QuestGiver:AddQuest(Quest) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:299)
PixelCrushers.QuestMachine.QuestListContainer:AddQuests(List`1) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:170)
PixelCrushers.QuestMachine.QuestListContainer:InstantiateQuestAssets() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:140)
PixelCrushers.QuestMachine.QuestListContainer:Awake() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestListContainer.cs:124)
PixelCrushers.QuestMachine.QuestGiver:Awake() (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest MonoBehaviours/Quest List/QuestGiver.cs:168)
Attachments
Capture.JPG
Capture.JPG (75.82 KiB) Viewed 1050 times
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text changes from white to black at runtime

Post by Tony Li »

Hi,

That error isn't related. To clean up the error, inspect the quest in the Quest Editor. From the gear menu in the upper right, select Debug > Delete Unused Subassets. Then inspect the quest and its nodes. Look for any blank elements in the content lists (Dialogue Text, Journal Text, etc.) and delete them. Quest Machine will continue to run fine even if you don't do this, but I think it's nice to have everything perfectly clean.

The black text issue is almost certainly an issue with the Text element's shader. Inspect the Text element. If you're using Arial, it probably uses "Default UI Material". Make sure the Tint is 255,255,255,255 (i.e., white and full alpha). Alternatively, you can create a new material, set its shader to UI/Text, and assign it to your Text elements.

It's possible that whatever material your Text elements use got changed so the alpha is zero.
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Re: Text changes from white to black at runtime

Post by Passero »

As you can see from the screenshot I attached in the original post, there is no material attached to the text elements so not sure if that could cause the issue...
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text changes from white to black at runtime

Post by Tony Li »

The material would be at the bottom of the Inspector, which is cut off in the screenshot.
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Re: Text changes from white to black at runtime

Post by Passero »

Still switches to black... See screenshot.
My custom material has tint set to white and alpha 255.
Attachments
Capture.JPG
Capture.JPG (100.09 KiB) Viewed 1041 times
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Re: Text changes from white to black at runtime

Post by Passero »

Some research shows that this appears to be a bug in Unity...
It's weird because it's only the Quest machine related UI that suffers from this. My own UI doesn't have this problem.

The difference though is that my UI uses text mesh pro but the default QM UI uses the old text elements...

The work around at the moment is to disable/enable the camera before running the project.
I'll have to do that every time from now on...
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text changes from white to black at runtime

Post by Tony Li »

It's not Quest Machine. It's an issue with the font & shader used by Unity UI text in your project. You can switch the Quest Machine UI to Text Mesh Pro if that makes it easier. Select Tools > Pixel Crushers > Common > Misc > Enable Text Mesh Pro Support. Then when you unassign a Text element you'll be able to assign a TextMeshProUGUI.
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Re: Text changes from white to black at runtime

Post by Passero »

I don't see that option... Only to enable 2D Physics which is grayed out (as I already enabled that).
And I'm not using the evaluation.... Never did... I bought it before I even used it for the first time ;)
User avatar
Tony Li
Posts: 21926
Joined: Thu Jul 18, 2013 1:27 pm

Re: Text changes from white to black at runtime

Post by Tony Li »

Sorry, wrong info. If you have the Dialogue System in the project, use the steps here: TextMesh Pro Support.

If you don't have the Dialogue System in your project, select Edit → Project Settings → Player. In the Other Settings section, add TMP_PRESENT to the Scripting Define Symbols field. If this field already contains text, put a semicolon between the existing text and TMP_PRESENT.
Passero
Posts: 32
Joined: Thu Jan 18, 2018 1:19 pm

Re: Text changes from white to black at runtime

Post by Passero »

Thanks I'll have a look.

I am in the process of re-evaluating my entire UI as before I didn't include support for controllers so because of this, I have a major effort of reworking my UI and was thinking on building my own UI for the quest machine as well so I will probably look into that. I will use TMP so it's good to have that enabled.
Post Reply