ORK and Two EventSystems

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK and Two EventSystems

Post by Tony Li »

Whew! I was just working on this, and I couldn't figure out how to reproduce the issue you described. Sorry something in your original project went corrupt. If you notice any issues in the new project, just let me know.
chud575
Posts: 50
Joined: Thu May 11, 2017 10:57 am

Re: ORK and Two EventSystems

Post by chud575 »

Hi Tony,

OK well after some testing, I'm back to this same problem. I keep trying to reproduce it stably but basically, in your test scene, it requires some combination of:

1. Disabling the existing eventsystem (so that two arent present)
2. Switching ORK to Unity UI from Legacy
3. Updating the GUI skin with UI Prefabs

EDIT-
Ok, try this:
1. Load DM and ORK
2. Unpack the demo
3. Unpack your third party ork support
4. Load 0 Main Menu scene
5. disable the event system game object (EDIT: Do this in 1 Town scene as well)
6a. add JRPG2 Unity UI Dialogue UI to DM/Canvas
6b. set the controller continue button to always
6c. set dialogue ui (jrpg2) to Allow Steal Focus and disable Add Event System If Needed
7. go to ORK Framework, and switch to Unity UI (add a font)
8. Play the game, press new game, go talk to Green Pants

Result - no keyboard support
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK and Two EventSystems

Post by Tony Li »

Thanks for the steps. I'll try to reproduce the issue today and get back to you with a solution.
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK and Two EventSystems

Post by Tony Li »

I'm just getting up to speed on ORK Framework's custom EventSystem, so please bear with me if we need to address something else after fixing the auto-focus issue.

The reason why the Dialogue System isn't auto-focusing is because ORK's EventSystem hasn't set itself as the current EventSystem. Unity doesn't always guarantee that components in a scene will start in any particular order. Depending on the order that components start, ORK's EventSystem might or might not be marked as the current EventSystem. When the Dialogue System tries to reference UnityEngine.EventSystems.EventSystem.current and it returns null, it's not able to tell the current EventSystem to focus a UI element.

Try adding this script to the Dialogue Manager. If ORK hasn't set EventSystem.current, this script will do it at the start of the conversation.

SetCurrentEventSystemOnConversationStart.cs

Code: Select all

using UnityEngine;

public class SetCurrentEventSystemOnConversationStart : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    {
        if (UnityEngine.EventSystems.EventSystem.current == null)
        {
            UnityEngine.EventSystems.EventSystem.current = FindObjectOfType<UnityEngine.EventSystems.EventSystem>();
        }
    }
}
That fixed the auto-focus issue in my reproduction project.

However, I have to confess that, once it's auto-focused, I haven't yet figured out how to navigate Unity UI using ORK's custom EventSystem -- not just in the Dialogue System, but in any Unity UI window. The arrow keys don't seem to navigate. I might not have configured the controls properly in the ORK Framework window. Most of my development experience with ORK has been under the hood, working with custom events and underlying data. So I'm still fumbling around a bit with the input controls, but I wanted to at least post the auto-focus thing above so you're not left waiting for too long.
User avatar
Tony Li
Posts: 21070
Joined: Thu Jul 18, 2013 1:27 pm

Re: ORK and Two EventSystems

Post by Tony Li »

Okay, I believe I have it figured out. When ORK sets up its own EventSystem, it disables standard Unity UI navigation. The Extras page has an updated ORK Support package that will also be in version 1.7.1. It adds a new script Unity UI Dialogue UI ORK Bridge that does some EventSystem fixup when a conversation starts. It undoes the fixup when the conversation ends. It also exposes the Fix and Unfix methods in case you need to support navigation in any other of your own Unity UIs outside of ORK. You can download the support package directly right here.
Post Reply