Exemplo n.º 1
0
        public override GameObject CreateObject(Transform parent)
        {
            TextSegmentedControl prefab = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().First(x => x.name == "BeatmapDifficultySegmentedControl" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null);
            TextSegmentedControl textSegmentedControl = MonoBehaviour.Instantiate(prefab, parent, false);

            textSegmentedControl.name = "BSMLTextSegmentedControl";
            textSegmentedControl.SetField("_container", prefab.GetField <DiContainer, TextSegmentedControl>("_container"));
            (textSegmentedControl.transform as RectTransform).anchoredPosition = new Vector2(0, 0);
            foreach (Transform transform in textSegmentedControl.transform)
            {
                GameObject.Destroy(transform.gameObject);
            }
            MonoBehaviour.Destroy(textSegmentedControl.GetComponent <BeatmapDifficultySegmentedControlController>());
            return(textSegmentedControl.gameObject);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create text 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 TextSegmentedControl CreateTextSegmentedControl(RectTransform p_Parent, bool p_HideCellBackground)
        {
            TextSegmentedControl l_Prefab  = Resources.FindObjectsOfTypeAll <TextSegmentedControl>().First(x => x.name == "BeatmapDifficultySegmentedControl" && x.GetField <DiContainer, TextSegmentedControl>("_container") != null);
            TextSegmentedControl l_Control = MonoBehaviour.Instantiate(l_Prefab, p_Parent, false);

            l_Control.name = "BSMLTextSegmentedControl";
            l_Control.SetField("_container", l_Prefab.GetField <DiContainer, TextSegmentedControl>("_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 <BeatmapDifficultySegmentedControlController>());
            return(l_Control);
        }