Remix properties panel now scrolls correctly when the curor is over an inputfield (#395)

Co-authored-by: Jenny Crowe <jakobwcrowe@berkeley.edu>
This commit is contained in:
Jenny Crowe 2023-04-18 18:49:19 -07:00 committed by GitHub
parent 1a350640fc
commit b3f48e50a7
4 changed files with 102 additions and 11 deletions

View File

@ -26,6 +26,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527515335633065} - {fileID: 5427527515335633065}
m_Father: {fileID: 5427527515912594980} m_Father: {fileID: 5427527515912594980}
@ -64,6 +65,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527515894244509} - {fileID: 5427527515894244509}
m_Father: {fileID: 5427527515991567133} m_Father: {fileID: 5427527515991567133}
@ -123,7 +125,7 @@ GameObject:
- component: {fileID: 5427527514471909770} - component: {fileID: 5427527514471909770}
- component: {fileID: 5427527514471909773} - component: {fileID: 5427527514471909773}
- component: {fileID: 5427527514471909772} - component: {fileID: 5427527514471909772}
- component: {fileID: 5427527514471909771} - component: {fileID: 17440954914857642}
m_Layer: 5 m_Layer: 5
m_Name: Options m_Name: Options
m_TagString: Untagged m_TagString: Untagged
@ -141,6 +143,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527515686438558} - {fileID: 5427527515686438558}
- {fileID: 5427527515912594980} - {fileID: 5427527515912594980}
@ -190,7 +193,7 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!114 &5427527514471909771 --- !u!114 &17440954914857642
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -199,7 +202,7 @@ MonoBehaviour:
m_GameObject: {fileID: 5427527514471909769} m_GameObject: {fileID: 5427527514471909769}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} m_Script: {fileID: 11500000, guid: 29e13e4aab38b094e9616c5538810fe2, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Content: {fileID: 5427527515324160294} m_Content: {fileID: 5427527515324160294}
@ -213,9 +216,9 @@ MonoBehaviour:
m_Viewport: {fileID: 5427527515686438558} m_Viewport: {fileID: 5427527515686438558}
m_HorizontalScrollbar: {fileID: 0} m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 5427527515912594981} m_VerticalScrollbar: {fileID: 5427527515912594981}
m_HorizontalScrollbarVisibility: 2 m_HorizontalScrollbarVisibility: 0
m_VerticalScrollbarVisibility: 2 m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3 m_HorizontalScrollbarSpacing: 0
m_VerticalScrollbarSpacing: -3 m_VerticalScrollbarSpacing: -3
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -248,6 +251,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5427527515686438558} m_Father: {fileID: 5427527515686438558}
m_RootOrder: 0 m_RootOrder: 0
@ -325,6 +329,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5427527513914945896} m_Father: {fileID: 5427527513914945896}
m_RootOrder: 0 m_RootOrder: 0
@ -401,6 +406,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527515324160294} - {fileID: 5427527515324160294}
m_Father: {fileID: 5427527514471909770} m_Father: {fileID: 5427527514471909770}
@ -490,6 +496,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5427527514369731111} m_Father: {fileID: 5427527514369731111}
m_RootOrder: 0 m_RootOrder: 0
@ -625,6 +632,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527513914945896} - {fileID: 5427527513914945896}
m_Father: {fileID: 5427527514471909770} m_Father: {fileID: 5427527514471909770}
@ -751,6 +759,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5427527514471909770} - {fileID: 5427527514471909770}
- {fileID: 5427527514369731111} - {fileID: 5427527514369731111}

View File

@ -29,6 +29,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409624780063834} - {fileID: 8717409624780063834}
m_Father: {fileID: 8717409623454252794} m_Father: {fileID: 8717409623454252794}
@ -118,6 +119,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409624223196553} - {fileID: 8717409624223196553}
m_Father: {fileID: 8717409624830382243} m_Father: {fileID: 8717409624830382243}
@ -177,7 +179,7 @@ GameObject:
- component: {fileID: 8717409623454252794} - component: {fileID: 8717409623454252794}
- component: {fileID: 8717409623454252775} - component: {fileID: 8717409623454252775}
- component: {fileID: 8717409623454252772} - component: {fileID: 8717409623454252772}
- component: {fileID: 8717409623454252773} - component: {fileID: 8745786445770459738}
m_Layer: 5 m_Layer: 5
m_Name: Options m_Name: Options
m_TagString: Untagged m_TagString: Untagged
@ -195,6 +197,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409623072351515} - {fileID: 8717409623072351515}
- {fileID: 8717409623676242996} - {fileID: 8717409623676242996}
@ -244,7 +247,7 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!114 &8717409623454252773 --- !u!114 &8745786445770459738
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -253,7 +256,7 @@ MonoBehaviour:
m_GameObject: {fileID: 8717409623454252795} m_GameObject: {fileID: 8717409623454252795}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} m_Script: {fileID: 11500000, guid: 29e13e4aab38b094e9616c5538810fe2, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Content: {fileID: 8717409624780063834} m_Content: {fileID: 8717409624780063834}
@ -267,10 +270,10 @@ MonoBehaviour:
m_Viewport: {fileID: 8717409623072351515} m_Viewport: {fileID: 8717409623072351515}
m_HorizontalScrollbar: {fileID: 0} m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 8717409623676242999} m_VerticalScrollbar: {fileID: 8717409623676242999}
m_HorizontalScrollbarVisibility: 2 m_HorizontalScrollbarVisibility: 0
m_VerticalScrollbarVisibility: 2 m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3 m_HorizontalScrollbarSpacing: 0
m_VerticalScrollbarSpacing: -3 m_VerticalScrollbarSpacing: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
@ -303,6 +306,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409624215846678} - {fileID: 8717409624215846678}
m_Father: {fileID: 8717409623454252794} m_Father: {fileID: 8717409623454252794}
@ -426,6 +430,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409625038176266} - {fileID: 8717409625038176266}
m_Father: {fileID: 8717409623676242996} m_Father: {fileID: 8717409623676242996}
@ -464,6 +469,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 8717409623306401521} m_Father: {fileID: 8717409623306401521}
m_RootOrder: 0 m_RootOrder: 0
@ -598,6 +604,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 8717409623072351515} m_Father: {fileID: 8717409623072351515}
m_RootOrder: 0 m_RootOrder: 0
@ -676,6 +683,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8717409623454252794} - {fileID: 8717409623454252794}
- {fileID: 8717409623306401521} - {fileID: 8717409623306401521}
@ -818,6 +826,7 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 8717409624215846678} m_Father: {fileID: 8717409624215846678}
m_RootOrder: 0 m_RootOrder: 0

View File

@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace HeavenStudio.Editor
{
// Thank you Unity forums!
// https://forum.unity.com/threads/scroll-view-does-not-scroll-with-mousewheel-when-mouse-is-over-a-button-inside-the-scroll-view.848848/
public class ChiScrollRect : ScrollRect, IPointerEnterHandler, IPointerExitHandler
{
private static string mouseScrollWheelAxis = "Mouse ScrollWheel";
private bool swallowMouseWheelScrolls = true;
private bool isMouseOver = false;
public void OnPointerEnter(PointerEventData eventData)
{
isMouseOver = true;
}
public void OnPointerExit(PointerEventData eventData)
{
isMouseOver = false;
}
private void Update()
{
// Detect the mouse wheel and generate a scroll. This fixes the issue where Unity will prevent our ScrollRect
// from receiving any mouse wheel messages if the mouse is over a raycast target (such as a button).
if (isMouseOver && IsMouseWheelRolling())
{
var delta = UnityEngine.Input.GetAxis(mouseScrollWheelAxis);
PointerEventData pointerData = new PointerEventData(EventSystem.current);
pointerData.scrollDelta = new Vector2(0f, delta * scrollSensitivity);
swallowMouseWheelScrolls = false;
OnScroll(pointerData);
swallowMouseWheelScrolls = true;
}
}
public override void OnScroll(PointerEventData data)
{
if (IsMouseWheelRolling() && swallowMouseWheelScrolls)
{
// Eat the scroll so that we don't get a double scroll when the mouse is over an image
}
else
{
base.OnScroll(data);
}
}
private static bool IsMouseWheelRolling()
{
return UnityEngine.Input.GetAxis(mouseScrollWheelAxis) != 0;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29e13e4aab38b094e9616c5538810fe2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: