Hey there,
I'm trying to have my player's ProximitySelector's use message change based on the current input scheme being used. I'm using TextMeshPro's rich text system to incorporate sprites into the use message to show keyboard/controller buttons.
I have no issues setting the use message through the player's ProximitySelector component at Start(), but changing the "defaultUseMessage" after this seems to do nothing. I can only guess this is due to an external component taking the reins after receiving this value at the start.
Just wondering if there's a clean way I can change the use message through script at runtime.
Thanks so much for your time!
Changing the "Use message" at runtime.
Re: Changing the "Use message" at runtime.
Hi,
The SelectorUseStandardUIElements component caches the use message. After changing the use message at runtime, call the SelectorUseStandardUIElements's ConnectDelegates() to update the use message. Here's an example script that changes the use message to "USE: <Space>" when you press [F1]:
The SelectorUseStandardUIElements component caches the use message. After changing the use message at runtime, call the SelectorUseStandardUIElements's ConnectDelegates() to update the use message. Here's an example script that changes the use message to "USE: <Space>" when you press [F1]:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
[RequireComponent(typeof(Selector))]
[RequireComponent(typeof(SelectorUseStandardUIElements))]
public class ChangeUseMessage : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.F1))
{
GetComponent<Selector>().defaultUseMessage = "USE: <Space>";
GetComponent<SelectorUseStandardUIElements>().ConnectDelegates();
}
}
}
Re: Changing the "Use message" at runtime.
Hi Tony,
Thank you so much! This is exactly what I needed! As always, you're at the top of your game!
I appreciate the help and hope you have a good one!
Thank you so much! This is exactly what I needed! As always, you're at the top of your game!
I appreciate the help and hope you have a good one!
Re: Changing the "Use message" at runtime.
Glad to help!