From 01060c2df0f59ec61b74771f36111e150ee43743 Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 13 May 2022 10:50:33 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=9E=E3=82=A4?= =?UTF-8?q?=E3=82=BA=E6=A9=9F=E8=83=BD=E3=82=BB=E3=83=AC=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/Scripts/ShopCustomizeSelector.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomizeSelector.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomizeSelector.cs index be5b840d..4f252e8e 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomizeSelector.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/ShopCustomizeSelector.cs @@ -25,12 +25,12 @@ namespace MyGame.Scenes.marketing.Scripts public void Initialize() { - var content = scrollRect.content; - content.DestroyAllChildrens(); + var viewport = scrollRect.viewport; + viewport.DestroyAllChildrens(); var categories = (ShopCustomizeCategory[])Enum.GetValues(typeof(ShopCustomizeCategory)); foreach (var category in categories) { - targetDict.Add(category, Instantiate(listPrefab, content)); + targetDict.Add(category, Instantiate(listPrefab, viewport)); } buttonDict.Add(ShopCustomizeCategory.Category1, signBoardButton); buttonDict.Add(ShopCustomizeCategory.Category2, decoration1Button); @@ -39,11 +39,13 @@ namespace MyGame.Scenes.marketing.Scripts buttonDict.Add(ShopCustomizeCategory.Category5, decoration2Button); // buttonDict.Add(ShopCustomizeCategory.Category6, category6Button); - initializeCompositeDisposable.Dispose(); + initializeCompositeDisposable.Clear(); buttonDict.Select(pair => pair.Value.OnClickObservable.Select(_ => pair.Key)) .Merge() + .StartWith(ShopCustomizeCategory.Category1) .ThrottleFirst(TimeSpan.FromSeconds(.2f)) - .Subscribe(ChangeCategory).AddTo(initializeCompositeDisposable); + .Subscribe(ChangeCategory) + .AddTo(initializeCompositeDisposable); } public ShopCustomizeItem GenerateItem(ShopCustomizeCategory category) @@ -68,8 +70,9 @@ namespace MyGame.Scenes.marketing.Scripts foreach (var pair in targetDict) { pair.Value.gameObject.SetActive(pair.Key == category); - buttonDict[pair.Key]?.SetActive(pair.Key == category); + buttonDict[pair.Key].SetActive(pair.Key == category); } + scrollRect.content = targetDict[category] as RectTransform; } } } \ No newline at end of file