Hide Proximity Selector UI Children

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Hide Proximity Selector UI Children

Post by PayasoPrince »

Hello,

I need to be able to hide the ProximitySelectors "Name Text" & "Use Message Text" through script.

How can I do this through my Player GameObject that contains the ProximitySelector?

Image

Is it something like this?

Code: Select all

"ProximitySelector" ..transform.GetChild(1).GetChild(0)
or is there a simpler way?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide Proximity Selector UI Children

Post by Tony Li »

If you disable the ProximitySelector component, it should automatically hide its UI elements.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Hide Proximity Selector UI Children

Post by PayasoPrince »

Hmm, the ProximitySelector script that is on my player?
Disabling it doesn't seem to also disable the UI :?

Unless you meant the ProximitySelector Prefab that is on my DialogueManager. If so, can you assist with how I can syntactically disable it?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide Proximity Selector UI Children

Post by Tony Li »

Disabling the ProximitySelector on your player should tell the SelectorUseStandardUIElements component on your player to hide the StandardUISelectorElements in your canvas.
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Hide Proximity Selector UI Children

Post by PayasoPrince »

Hello Tony,

That doesn't appear to be the case for me.

Code: Select all

"this(Player)".GetComponent<ProximitySelector>().enabled = false;
This is successfully disabling my ProximitySelector component but is not removing the UI.

Please see example below:

[removed]

Any assistance would be greatly appreciated. :)
Last edited by PayasoPrince on Mon Jan 31, 2022 3:41 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide Proximity Selector UI Children

Post by Tony Li »

Sorry, I miswrote. To hide it, you can use:

Code: Select all

"this(Player)".GetComponent<SelectorUseStandardUIElements>().elements.mainGraphic.gameObject.SetActive(false);
User avatar
PayasoPrince
Posts: 104
Joined: Thu Jan 27, 2022 6:47 pm

Re: Hide Proximity Selector UI Children

Post by PayasoPrince »

This works! Thanks! :mrgreen:
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide Proximity Selector UI Children

Post by Tony Li »

Glad to help!
Post Reply