Merged in zhdiv/unity-ui-extensions-i1 (pull request #35)
Master Approved-by: Simon Jackson <darkside@xna-uk.net>pull/413/head
commit
c844807864
|
@ -136,12 +136,13 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
if (_scroll_rect.horizontalScrollbar != null && _scroll_rect.horizontal)
|
||||
{
|
||||
var hscroll = _scroll_rect.horizontalScrollbar.gameObject.AddComponent<ScrollSnapScrollbarHelper>();
|
||||
|
||||
var hscroll = _scroll_rect.horizontalScrollbar.gameObject.GetOrAddComponent<ScrollSnapScrollbarHelper>();
|
||||
hscroll.ss = this;
|
||||
}
|
||||
if (_scroll_rect.verticalScrollbar != null && _scroll_rect.vertical)
|
||||
{
|
||||
var vscroll = _scroll_rect.verticalScrollbar.gameObject.AddComponent<ScrollSnapScrollbarHelper>();
|
||||
var vscroll = _scroll_rect.verticalScrollbar.gameObject.GetOrAddComponent<ScrollSnapScrollbarHelper>();
|
||||
vscroll.ss = this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
public static class ExtentionMethods
|
||||
{
|
||||
public static T GetOrAddComponent<T>(this GameObject child) where T : Component
|
||||
{
|
||||
T result = child.GetComponent<T>();
|
||||
if (result == null)
|
||||
{
|
||||
result = child.AddComponent<T>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ed85e09a894358f4782be8df50a1221a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue