コード例 #1
0
ファイル: Tools.cs プロジェクト: x747510/MakerSearch
        public static void CreateUI()
        {
            var orig = GameObject.Find("CharaCustom/CustomControl/CanvasSub/SettingWindow/WinFace/F_ShapeWhole/Scroll View/Viewport/Content/SliderSet/SldInputField");

            var i = 0;

            foreach (var targetStr in targets)
            {
                var target = GameObject.Find(targetStr);

                if (i == 1 && AI_MakerSearch.isSteam)
                {
                    var color = target.transform.Find("DefaultColor");
                    var rectC = color.GetComponent <RectTransform>();
                    rectC.offsetMax = new Vector2(200, rectC.offsetMax.y);

                    var button = color.Find("Button");
                    button.GetComponent <RectTransform>().offsetMax = new Vector2(200, 0);
                }

                var cp = UnityEngine.Object.Instantiate(orig, target.transform);
                cp.name = "Search";

                var placeholderObj = cp.transform.Find("Placeholder");
                var placeholder    = placeholderObj.GetComponent <Text>();
                placeholder.text = "Search";

                UnityEngine.Object.Destroy(cp.transform.Find("SldInputField Input Caret"));

                var rect = cp.GetComponent <RectTransform>();

                if (i == 1) // Clothes
                {
                    rect.offsetMin = new Vector2(-250, 3);
                    rect.offsetMax = new Vector2(0, -383);
                }
                else
                {
                    rect.offsetMin = new Vector2(AI_MakerSearch.isSteam ? -452 : -420, 3);
                    rect.offsetMax = new Vector2(0, -383);

                    var box        = target.transform.Find("SelectBox");
                    var scrollview = box.Find("Scroll View");

                    box.GetComponent <RectTransform>().offsetMin        = new Vector2(0, -372);
                    scrollview.GetComponent <RectTransform>().offsetMin = new Vector2(0, i == 2 ? -264 : i == 4 ? -332 : -372);
                }

                var input = cp.GetComponent <InputField>();
                input.contentType    = InputField.ContentType.Standard;
                input.characterLimit = 64;

                input.onValueChanged.RemoveAllListeners();
                input.onEndEdit.RemoveAllListeners();

                input.textComponent.text = "";
                input.text = "";

                input.onValueChanged.AddListener(delegate(string text) { placeholder.enabled = text == ""; });
                input.onEndEdit.AddListener(delegate(string text)
                {
                    AI_MakerSearch.searchString = text;
                    AI_MakerSearch.Search();
                });

                fields[i] = input;

                if (i == 2)
                {
                    cp.SetActive(false);
                }

                i++;
            }
        }
コード例 #2
0
ファイル: Tools.cs プロジェクト: Mantas-2155X/MakerSearch
        public static void CreateUI()
        {
            var orig        = GameObject.Find("CharaCustom/CustomControl/CanvasSub/SettingWindow/WinFace/F_ShapeWhole/Scroll View/Viewport/Content/SliderSet/SldInputField");
            var resetButton = GameObject.Find("CharaCustom/CustomControl/CanvasSub/SettingWindow/WinClothes/DefaultWin/C_Clothes/Setting/Setting01/DefaultColor");

            for (var i = 0; i < targets.Length; i++)
            {
                var idx = i;

                var target = GameObject.Find(targets[i]);

                if (i == 1 && AI_MakerSearch.isSteam)
                {
                    var color = target.transform.Find("DefaultColor");
                    var rectC = color.GetComponent <RectTransform>();
                    rectC.offsetMax = new Vector2(200, rectC.offsetMax.y);

                    var cButton = color.Find("Button");
                    cButton.GetComponent <RectTransform>().offsetMax = new Vector2(200, 0);
                }

                var cp = UnityEngine.Object.Instantiate(orig, target.transform);
                cp.name = "Search";

                var placeholderObj = cp.transform.Find("Placeholder");
                var placeholder    = placeholderObj.GetComponent <Text>();
                placeholder.text = "Search";

                var caret = cp.transform.Find("SldInputField Input Caret");
                if (caret != null)
                {
                    UnityEngine.Object.Destroy(caret.gameObject);
                }

                var rect = cp.GetComponent <RectTransform>();

                var resetCopy = UnityEngine.Object.Instantiate(resetButton, target.transform);
                resetCopy.name = "Reset";

                var resetRect = resetCopy.GetComponent <RectTransform>();
                resetRect.offsetMin = new Vector2(!AI_MakerSearch.isSteam ? 365 : 396, -420);
                resetRect.offsetMax = new Vector2(!AI_MakerSearch.isSteam ? 615 : 646, -440);

                var resetText = resetCopy.GetComponentInChildren <Text>();
                resetText.text = "Reset";

                if (i == 1) // Clothes
                {
                    rect.offsetMin = new Vector2(!AI_MakerSearch.isSteam ? -255 : -250, 3);
                    rect.offsetMax = new Vector2(-60, -383);
                }
                else
                {
                    rect.offsetMin = new Vector2(AI_MakerSearch.isSteam ? -452 : -420, 3);
                    rect.offsetMax = new Vector2(-60, -383);

                    var box        = target.transform.Find("SelectBox");
                    var scrollview = box.Find("Scroll View");

                    box.GetComponent <RectTransform>().offsetMin        = new Vector2(0, -372);
                    scrollview.GetComponent <RectTransform>().offsetMin = new Vector2(0, i == 2 ? -264 : i == 4 || i == 20 ? -332 : -372);
                }

                var input = cp.GetComponent <InputField>();
                input.contentType    = InputField.ContentType.Standard;
                input.characterLimit = 64;

                input.onValueChanged.RemoveAllListeners();
                input.onEndEdit.RemoveAllListeners();

                input.textComponent.text = "";
                input.text = "";

                input.onValueChanged.AddListener(delegate(string text) { placeholder.enabled = text == ""; });
                input.onEndEdit.AddListener(delegate(string text)
                {
                    AI_MakerSearch.searchString = text;
                    AI_MakerSearch.Search(idx);
                });

                var button = resetCopy.GetComponentInChildren <Button>();
                button.onClick.RemoveAllListeners();
                button.onClick.AddListener(delegate
                {
                    input.text = "";
                    AI_MakerSearch.searchString = "";
                    AI_MakerSearch.Search(idx);
                });

                var buttonRect = button.GetComponent <RectTransform>();
                buttonRect.offsetMax = new Vector2(60, 60);

                fields[i] = input;

                if (i == 2)
                {
                    cp.SetActive(false);
                }
            }
        }