public override GameObject CreateObject(Transform parent)
        {
            if (prefab == null)
            {
                PlatformLeaderboardViewController vc = Resources.FindObjectsOfTypeAll <PlatformLeaderboardViewController>().First();
                prefab = vc.GetField <IconSegmentedControl, PlatformLeaderboardViewController>("_scopeSegmentedControl");
            }

            IconSegmentedControl control = Object.Instantiate(prefab, parent, false);

            control.name = "BSMLVerticalIconSegmentedControl";
            control.SetField("_container", prefab.GetField <DiContainer, IconSegmentedControl>("_container"));

            RectTransform rt = control.transform as RectTransform;

            rt.anchorMin        = new Vector2(0.5f, 0.5f);
            rt.anchorMax        = new Vector2(0.5f, 0.5f);
            rt.anchoredPosition = Vector2.zero;
            rt.pivot            = new Vector2(0.5f, 0.5f);

            foreach (Transform transform in control.transform)
            {
                Object.Destroy(transform.gameObject);
            }

            return(control.gameObject);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create icon segmented control
        /// </summary>
        /// <param name="p_Parent">Parent game object transform</param>
        /// <param name="p_HideCellBackground">Should hide cell background</param>
        /// <returns>GameObject</returns>
        public static IconSegmentedControl CreateHorizontalIconSegmentedControl(RectTransform p_Parent, bool p_HideCellBackground)
        {
            IconSegmentedControl l_Prefab  = Resources.FindObjectsOfTypeAll <IconSegmentedControl>().First(x => x.name == "BeatmapCharacteristicSegmentedControl" && x.GetField <DiContainer, IconSegmentedControl>("_container") != null);
            IconSegmentedControl l_Control = MonoBehaviour.Instantiate(l_Prefab, p_Parent, false);

            l_Control.name = "BSMLIconSegmentedControl";
            l_Control.SetField("_container", l_Prefab.GetField <DiContainer, IconSegmentedControl>("_container"));
            l_Control.SetField("_hideCellBackground", p_HideCellBackground);

            RectTransform l_RectTransform = l_Control.transform as RectTransform;

            l_RectTransform.anchorMin        = Vector2.one * 0.5f;
            l_RectTransform.anchorMax        = Vector2.one * 0.5f;
            l_RectTransform.anchoredPosition = Vector2.zero;
            l_RectTransform.pivot            = Vector2.one * 0.5f;

            foreach (Transform l_Transform in l_Control.transform)
            {
                GameObject.Destroy(l_Transform.gameObject);
            }

            MonoBehaviour.Destroy(l_Control.GetComponent <BeatmapCharacteristicSegmentedControlController>());

            return(l_Control);
        }
Exemplo n.º 3
0
        public override GameObject CreateObject(Transform parent)
        {
            IconSegmentedControl prefab = Resources.FindObjectsOfTypeAll <IconSegmentedControl>().First(x => x.name == "BeatmapCharacteristicSegmentedControl" && x.GetField <DiContainer, IconSegmentedControl>("_container") != null);
            IconSegmentedControl iconSegmentedControl = MonoBehaviour.Instantiate(prefab, parent, false);

            iconSegmentedControl.name = "BSMLIconSegmentedControl";
            iconSegmentedControl.SetField("_container", prefab.GetField <DiContainer, IconSegmentedControl>("_container"));
            (iconSegmentedControl.transform as RectTransform).anchoredPosition = new Vector2(0, 0);
            foreach (Transform transform in iconSegmentedControl.transform)
            {
                GameObject.Destroy(transform.gameObject);
            }
            MonoBehaviour.Destroy(iconSegmentedControl.GetComponent <BeatmapCharacteristicSegmentedControlController>());
            return(iconSegmentedControl.gameObject);
        }