Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard optimization #1133

Merged
merged 18 commits into from
Oct 26, 2017
Merged

Conversation

Zod-
Copy link

@Zod- Zod- commented Oct 12, 2017

Fixes #853
Fixes #945

Since we have the UI raycast changes now in the master it's time to add the keyboard optimizations since I can be sure the raycasting will not cause issues.

I explained most of the optimizations already in #853 and I ended up with some additional minor changes:

  1. Add sprite atlas for icons and textures used on the keyboard so all of them can be drawn at the same time.
  2. Remove all z-positions in the canvas (this is why I needed the raycasting changes). The z-positions causes canvas batching to break and all elements will be drawn on their own.
  3. Set all highlight elements as the last sibling since that somehow broke batching for its siblings too.
  4. Disabled rich text and raycast-target on a lot of elements that didn't need it.
  5. Removed the background of the input field at the top of the keyboard. That as well broke the batching and I don't know why. The looks are almost the same so I think this its fine.

All of these changes are on the Keyboard prefab and there are no code changes involved (other than the minor refactoring I did on UICollection).
This should be tested on the HoloLens as it was pretty much unusable before due to the lag from the keyboard. Unfortunately, I won't have access to one in the next few weeks. It can also be tested in the KeyboardTest-scene.

For the sprite atlas, I also had to turn on the Sprite Packer in the new mode. This will also be required for people that want to use the keyboard. Without this setting, the performance of the keyboard will be slightly worse.
Maybe it would make sense to add this setting to the configuration steps?

private void Update()
{
#if UNITY_EDITOR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use if (Application.isEditor) instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't we have a lot of unnecessary calls to methods that won't be there otherwise?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we tag the method as [Conditional("UNITY_EDITOR")]

Copy link
Contributor

@StephenHodgson StephenHodgson Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method gets called whether it's in the editor or not cause it's a unity API


if (m_rectTransform == null)
if (rectTransform == null)
{
Debug.LogError("This component must be attached to a GameObject with a RectTransform component!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this debug log if the component is required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't

The component is required so it can't be null.
Copy link
Contributor

@SimonDarksideJ SimonDarksideJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me

@SimonDarksideJ
Copy link
Contributor

Over to you @StephenHodgson

@StephenHodgson StephenHodgson merged commit f6b353b into microsoft:master Oct 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants