X Tutup
Skip to content

NEW: Add extra modes for controlling OnScreenStick origin and movement behaviour#1613

Merged
jimon merged 9 commits intodevelopfrom
NewOnScreenStickModes
Dec 16, 2022
Merged

NEW: Add extra modes for controlling OnScreenStick origin and movement behaviour#1613
jimon merged 9 commits intodevelopfrom
NewOnScreenStickModes

Conversation

@andrew-oc
Copy link
Contributor

@andrew-oc andrew-oc commented Nov 25, 2022

Description

This adds 2 new modes of behaviour for the OnScreenStick.

The existing behaviour, now called RelativePositionWithStaticOrigin, would not move initially when the user presses the screen, even if that press was not centered on the stick. It would from then on move relatively with the user dragging motion.

In addition this PR introduces two new modes:
ExactPositionWithStaticOrigin - allows the stick to react instantly to the initial press, by actuating the control by the amount that the press is offset from the control center.

ExactPositionWithDynamicOrigin - allows the stick position to be dynamically set each time the user presses the screen.

This is based on the work from this PR contributed by user @eblabs

Changes made

  • New enum for different modes and public property to set the mode: behaviour
  • New dynamicOriginRange property to control the screen area where ExactPositionWithDynamicOrigin is valid
  • Extensive changes in the Interaction functions for integrating the new modes
  • Added tests for the new modes

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

@jamesmcgill jamesmcgill marked this pull request as ready for review December 13, 2022 15:13
@jamesmcgill jamesmcgill changed the title Add extra modes for OnScreenStick NEW: Add extra modes for controlling OnScreenStick origin position behaviour Dec 13, 2022
@jamesmcgill jamesmcgill changed the title NEW: Add extra modes for controlling OnScreenStick origin position behaviour NEW: Add extra modes for controlling OnScreenStick origin and movement behaviour Dec 13, 2022
@jamesmcgill jamesmcgill self-requested a review December 13, 2022 16:14
Copy link
Collaborator

@jamesmcgill jamesmcgill left a comment

Choose a reason for hiding this comment

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

BEST PR EVER!

rectTransform.localScale = new Vector3(1, 1, 0);
rectTransform.anchoredPosition3D = Vector3.zero;

image.sprite = SpriteUtilities.CreateCircleSprite(16, new Color32(255, 255, 255, 255));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be useful for users to override this sprite, but because it's only for Behaviour.ExactPositionWithDynamicOrigin it's probably ok for now

### Actions
- Extended input action code generator (`InputActionCodeGenerator.cs`) to support optional registration and unregistration of callbacks for multiple callback instances via `AddCallbacks(...)` and `RemoveCallbacks(...)` part of the generated code. Contribution by [Ramobo](https://github.com/Ramobo) in [#889](https://github.com/Unity-Technologies/InputSystem/pull/889).


Copy link
Contributor

Choose a reason for hiding this comment

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

Extra line?

@jimon jimon merged commit f4fb4f2 into develop Dec 16, 2022
@jimon jimon deleted the NewOnScreenStickModes branch December 16, 2022 10:05
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

X Tutup