add AddListener helper for IL2CPP, cleanup some unity extensions

This commit is contained in:
sinaioutlander
2020-11-13 23:14:57 +11:00
parent eedb7dd76f
commit eb693eceb5
23 changed files with 136 additions and 282 deletions

View File

@ -33,11 +33,7 @@ namespace UnityExplorer.UI.Shared
this.sliderScroller = sliderScroller;
this.inputField = inputField;
#if MONO
inputField.onValueChanged.AddListener(OnTextChanged);
#else
inputField.onValueChanged.AddListener(new Action<string>(OnTextChanged));
#endif
inputRect = inputField.GetComponent<RectTransform>();
layoutElement = inputField.gameObject.AddComponent<LayoutElement>();

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using UnityExplorer.Config;
using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Helpers;
namespace UnityExplorer.UI.Shared
{
@ -184,11 +185,9 @@ namespace UnityExplorer.UI.Shared
GameObject leftBtnObj = UIFactory.CreateButton(m_pageUIHolder, new Color(0.15f, 0.15f, 0.15f));
Button leftBtn = leftBtnObj.GetComponent<Button>();
#if CPP
leftBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Left); }));
#else
leftBtn.onClick.AddListener(() => { TurnPage(Turn.Left); });
#endif
Text leftBtnText = leftBtnObj.GetComponentInChildren<Text>();
leftBtnText.text = "◄";
LayoutElement leftBtnLayout = leftBtnObj.AddComponent<LayoutElement>();
@ -206,11 +205,9 @@ namespace UnityExplorer.UI.Shared
GameObject rightBtnObj = UIFactory.CreateButton(m_pageUIHolder, new Color(0.15f, 0.15f, 0.15f));
Button rightBtn = rightBtnObj.GetComponent<Button>();
#if CPP
rightBtn.onClick.AddListener(new Action(() => { TurnPage(Turn.Right); }));
#else
rightBtn.onClick.AddListener(() => { TurnPage(Turn.Right); });
#endif
Text rightBtnText = rightBtnObj.GetComponentInChildren<Text>();
rightBtnText.text = "►";
LayoutElement rightBtnLayout = rightBtnObj.AddComponent<LayoutElement>();

View File

@ -25,15 +25,10 @@ public class SliderScrollbar
this.m_slider = slider;
this.m_scrollRect = scrollbar.transform.parent.GetComponent<RectTransform>();
#if MONO
this.m_scrollbar.onValueChanged.AddListener(this.OnScrollbarValueChanged);
this.m_slider.onValueChanged.AddListener(this.OnSliderValueChanged);
#else
this.m_scrollbar.onValueChanged.AddListener(new Action<float>(this.OnScrollbarValueChanged));
this.m_slider.onValueChanged.AddListener(new Action<float>(this.OnSliderValueChanged));
#endif
this.m_scrollbar.onValueChanged.AddListener(this.OnScrollbarValueChanged);
this.m_slider.onValueChanged.AddListener(this.OnSliderValueChanged);
this.RefreshVisibility();
this.RefreshVisibility();
this.m_slider.Set(1f, false);
}