Page 1 of 1

How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 10:56 am
by CalamaBanana
Hello, beginner here. I managed to setup and customize the dialog part of the Dialogue System without much trouble, but that damn selector widget refuses to play ball. The selector itself works, but I am unable to customize the UI element.

---
Attempt one:
My "Player" has the Selector (Script) attached, logic is working fine and a selector UI element is showing up.
I took the "Basic Standard UI Selector Elements" prefab the Dialogue Manager element had preselected and made a copy of it, customized it (swapped background image, set text size ten times larger) and assigned that copy to the Dialogue Manager.

When I play the scene, it correctly loads my prefab into the scene hierarchy. But I still get the same old default selector showing up in game. The only way I can affect the look of it is changing its color in the Selector script on my Player.
---

Attempt two:
I added the Unity UI Selector Display script to my Player. This seems to not overwrite the default selector of the Selector script. I now have two active selector widgets, and only the one created(?) by the Selector script is affected by the "Selector Follow Target" script. The one created by the Unity UI Selector Display script stays at it's hardcoded position
---


I noticed the Selector script on my Player to automatically select a skin in the "Gui Skin" field when the game starts, not leaving it at "none". Might that be related?

What am I missing, or what am I doing wrong?

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 11:05 am
by Tony Li
Hi,

Remove the "Unity UI Selector Display", and keep your customized "Basic Standard UI Selector Elements". Add a "Selector Use Standard UI Elements" component to your player. That should do it. If not, let me know.

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 11:27 am
by CalamaBanana
Thanks, it now selects the correct UI element. But the "Selector Follow Target" script does not affect that element, though. It seems to create a second element not using my widget.




Widget 1 is using the correct (oversized for testing) form, but not affected by the "Selector Follow Target" script
Widget 2 is using the colors set in the "Selector" script, and an unknown formatting. I am not sure if it's created by the "Selector Follow Target", but the "Selector Follow Target" moves it into the right place.

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 1:45 pm
by Tony Li
Hi,

Import this patch from the Dialogue System Extras page: DS_SelectorUseStandardUIElements_Patch_2019-01-08.unitypackage

To download it, click on the foldout under the heading "UPDATED INTEGRATION PACKAGES". If your browser shows gibberish, right-click on the download button and select Save As....

There are some specific requirements for using Standard UI with the Selector Follow Target component. Size your main graphic to something smaller than the whole screen, such as 256 pixels wide x 128 pixels high for example, and set the anchor to Bottom Left, similarly to this:
selectorMainGraphic.png
selectorMainGraphic.png (17.49 KiB) Viewed 2616 times
---

Alternatively, you can completely omit the Selector Follow Target component, and add a "Basic Standard Usable UI" prefab to the usable GameObject. When targeting this GameObject, the Selector / ProximitySelector will show this prefab instead of the regular selector UI.

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 4:04 pm
by CalamaBanana
Thank you, I used the patch and now everything works!

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 08, 2019 4:15 pm
by Tony Li
Great! Glad to help.

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 21, 2020 1:19 pm
by AnaonTeam
Hello, our team is testing Dialogue Systeme for our gameproject. We are relatively new with unity. We are using the lastest version of the Dialogue systeme and Unity 2019.3.0f5.

We have a game object "player" with a proximity selector and we are trying to implement a custom UI for the selector. Until there every thing is fine. It works with the "Selector use standard element" script.
But when we want to use the tag or the layer exeption UI, it doesn't work. The untagged game objects still have our custom UI but the one tagged no longer displays anything.

we tried putting the different UIs in the Instantied prefabs. But maybe we have omitted something.

Additionally, we have observed that peaks at 15fps occur when the "Selector use standard element" script is added to the game object. Again we may have done something wrong. Have you already observed this phenomenon ?
For information, we also have the Quest machine in the scene, if it could be linked.

Thank you for these good assets, we are still in testing phase but your tools are very promising.

Re: How do I create/use a custom selector UI element?

Posted: Tue Jan 21, 2020 3:40 pm
by Tony Li
Hi,
AnaonTeam wrote: Tue Jan 21, 2020 1:19 pmWe have a game object "player" with a proximity selector and we are trying to implement a custom UI for the selector. Until there every thing is fine. It works with the "Selector use standard element" script.
But when we want to use the tag or the layer exeption UI, it doesn't work. The untagged game objects still have our custom UI but the one tagged no longer displays anything.

we tried putting the different UIs in the Instantied prefabs. But maybe we have omitted something.
Please add the custom UIs directly to the scene, and assign them directly to the Selector Use Standard UI Elements component's Tag Specific Elements and/or Layer Specific Elements. Do not add them to the Instantiate Prefabs component. If Use Standard UI Elements points to prefabs in the Instantiate Prefabs list, they will not match the runtime instantiated versions because they are copies.
AnaonTeam wrote: Tue Jan 21, 2020 1:19 pmAdditionally, we have observed that peaks at 15fps occur when the "Selector use standard element" script is added to the game object. Again we may have done something wrong. Have you already observed this phenomenon ?
I have not observed that phenomenon. It shouldn't happen. Here are some possibilities:
  • If you have assigned methods to the ProximitySelector's OnSelectedUsable() UnityEvent or the onSelectedUsable C# event, make sure those methods do not take too long to run.
  • Put each custom selector UI in its own Canvas. When it becomes active, the Canvas must recompute its layout. This process is fastest if the Canvas only contains the selector UI's elements.
  • Make sure the selector UI elements don't have custom scripts that run long processing on OnEnable, since OnEnable will run when it shows the selector UI.
  • Check for any messages in the Console log.
(Note: The Selector/ProximitySelector system is entirely optional. You don't have to use it if you don't want to. It's just provided as a bonus with the Dialogue System. But it should not cause extreme performance spikes when configured using the tips above.)

Re: How do I create/use a custom selector UI element?

Posted: Sat Jan 25, 2020 6:14 am
by AnaonTeam
Tank you very much for your quick response. Thanks to your tips we have manage to solve our problems.

Re: How do I create/use a custom selector UI element?

Posted: Sat Jan 25, 2020 7:15 am
by Tony Li
Glad to help!