浏览代码

Updated Game Options package

/main
Thomas ICHÉ 5 年前
当前提交
8a085f1c
共有 6 个文件被更改,包括 98 次插入0 次删除
  1. 13
      LocalPackages/net.peeweek.game-options/Prefabs/GameOptionEntryDropDown Variant.prefab
  2. 3
      LocalPackages/net.peeweek.game-options/Runtime/HDRP/HDRPCameraOption.cs
  3. 8
      LocalPackages/net.peeweek.game-options/Runtime/Utility.meta
  4. 63
      LocalPackages/net.peeweek.game-options/Runtime/Utility/DropDownAutoScrollOnChange.cs
  5. 11
      LocalPackages/net.peeweek.game-options/Runtime/Utility/DropDownAutoScrollOnChange.cs.meta

13
LocalPackages/net.peeweek.game-options/Prefabs/GameOptionEntryDropDown Variant.prefab


- component: {fileID: 1879661270}
- component: {fileID: 1879661269}
- component: {fileID: 1879661268}
- component: {fileID: 2667812003656470357}
m_Layer: 5
m_Name: Template
m_TagString: Untagged

m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &2667812003656470357
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1879661266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c1c514756d7937947a07c73de5951227, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2039768715
GameObject:
m_ObjectHideFlags: 0

3
LocalPackages/net.peeweek.game-options/Runtime/HDRP/HDRPCameraOption.cs


public override void Apply()
{
if (s_Cameras == null)
return;
foreach (var camera in s_Cameras)
{
camera.antialiasing = antiAliasing;

8
LocalPackages/net.peeweek.game-options/Runtime/Utility.meta


fileFormatVersion: 2
guid: 92c6fb5868d98604d9799e7a07675897
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

63
LocalPackages/net.peeweek.game-options/Runtime/Utility/DropDownAutoScrollOnChange.cs


/* DropDownAutoScrollOnChange
* --------------------------
* Updates scrolling when selection changes inside a drop down panel when selection changes.
* This scripts patches the inability of ScrollRects to handle correct scrolling upon selection change.
*
* Adepted From:
* https://answers.unity.com/questions/1169028/unity-dropdown-doesnt-scroll-when-navigating-with.html
*/
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace GameOptionsUtility.Utility
{
[RequireComponent(typeof(ScrollRect))]
internal class DropDownAutoScrollOnChange : MonoBehaviour
{
RectTransform scrollRectTransform;
RectTransform contentPanel;
RectTransform selectedRectTransform;
GameObject lastSelected;
void Start()
{
scrollRectTransform = GetComponent<RectTransform>();
}
void Update()
{
// Lazy Get
if (contentPanel == null)
contentPanel = GetComponent<ScrollRect>().content;
GameObject selected = EventSystem.current.currentSelectedGameObject;
if (selected == null)
return;
if (selected.transform.parent != contentPanel.transform)
return;
if (selected == lastSelected)
return;
selectedRectTransform = selected.GetComponent<RectTransform>();
float yPos = -(selectedRectTransform.localPosition.y) - (selectedRectTransform.rect.height / 2);
float yContent = contentPanel.anchoredPosition.y;
float maxHeight = scrollRectTransform.rect.height - selectedRectTransform.rect.height;
float delta = yPos - yContent;
if (delta < 0)
yContent = yPos;
else if (delta > maxHeight)
yContent = yPos - maxHeight;
else
return;
contentPanel.anchoredPosition = new Vector2(contentPanel.anchoredPosition.x, yContent);
lastSelected = selected;
}
}
}

11
LocalPackages/net.peeweek.game-options/Runtime/Utility/DropDownAutoScrollOnChange.cs.meta


fileFormatVersion: 2
guid: c1c514756d7937947a07c73de5951227
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存