| | 1 | | using DCL; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | public class TaskbarHUDView : MonoBehaviour |
| | 7 | | { |
| | 8 | | const string VIEW_PATH = "Taskbar"; |
| | 9 | | const string PORTABLE_EXPERIENCE_ITEMS_POOL = "PortableExperienceItems"; |
| | 10 | |
|
| | 11 | | [Header("Taskbar Animation")] |
| | 12 | | [SerializeField] internal ShowHideAnimator taskbarAnimator; |
| | 13 | |
|
| | 14 | | [Header("Left Side Config")] |
| | 15 | | [SerializeField] internal RectTransform leftWindowContainer; |
| | 16 | |
|
| | 17 | | [SerializeField] internal ShowHideAnimator leftWindowContainerAnimator; |
| | 18 | | [SerializeField] internal LayoutGroup leftWindowContainerLayout; |
| | 19 | | [SerializeField] internal GameObject voiceChatButtonPlaceholder; |
| | 20 | | [SerializeField] internal VoiceChatButton voiceChatButton; |
| | 21 | | [SerializeField] internal TaskbarButton chatButton; |
| | 22 | | [SerializeField] internal TaskbarButton friendsButton; |
| | 23 | | [SerializeField] internal ChatHeadGroupView chatHeadsGroup; |
| | 24 | |
|
| | 25 | | [Header("Right Side Config")] |
| | 26 | | [SerializeField] internal HorizontalLayoutGroup rightButtonsHorizontalLayout; |
| | 27 | |
|
| | 28 | | [SerializeField] internal TaskbarButton settingsButton; |
| | 29 | | [SerializeField] internal TaskbarButton exploreButton; |
| | 30 | | [SerializeField] internal TaskbarButton exploreV2Button; |
| | 31 | | [SerializeField] internal TaskbarButton builderInWorldButton; |
| | 32 | | [SerializeField] internal GameObject portableExperiencesDiv; |
| | 33 | | [SerializeField] internal PortableExperienceTaskbarItem portableExperienceItem; |
| | 34 | | [SerializeField] internal TaskbarButton questPanelButton; |
| | 35 | |
|
| | 36 | | [Header("More Button Config")] |
| | 37 | | [SerializeField] internal TaskbarButton moreButton; |
| | 38 | |
|
| | 39 | | [SerializeField] internal TaskbarMoreMenu moreMenu; |
| | 40 | |
|
| | 41 | | [Header("Tutorial Config")] |
| | 42 | | [SerializeField] internal RectTransform exploreTooltipReference; |
| | 43 | |
|
| | 44 | | [SerializeField] internal RectTransform moreTooltipReference; |
| | 45 | | [SerializeField] internal RectTransform socialTooltipReference; |
| | 46 | |
|
| | 47 | | [Header("Old TaskbarCompatibility (temporal)")] |
| | 48 | | [SerializeField] internal RectTransform taskbarPanelTransf; |
| | 49 | |
|
| | 50 | | [SerializeField] internal Image taskbarPanelImage; |
| | 51 | | [SerializeField] internal GameObject rightButtonsContainer; |
| | 52 | |
|
| | 53 | | internal TaskbarHUDController controller; |
| 22 | 54 | | internal bool isBarVisible = true; |
| 22 | 55 | | internal Dictionary<string, PortableExperienceTaskbarItem> activePortableExperienceItems = new Dictionary<string, Po |
| 22 | 56 | | internal Dictionary<string, PoolableObject> activePortableExperiencesPoolables = new Dictionary<string, PoolableObje |
| | 57 | | internal Pool portableExperiencesPool = null; |
| | 58 | |
|
| | 59 | | public event System.Action OnChatToggleOn; |
| | 60 | | public event System.Action OnChatToggleOff; |
| | 61 | | public event System.Action OnFriendsToggleOn; |
| | 62 | | public event System.Action OnFriendsToggleOff; |
| | 63 | | public event System.Action OnSettingsToggleOn; |
| | 64 | | public event System.Action OnSettingsToggleOff; |
| | 65 | | public event System.Action OnBuilderInWorldToggleOn; |
| | 66 | | public event System.Action OnBuilderInWorldToggleOff; |
| | 67 | | public event System.Action OnExploreToggleOn; |
| | 68 | | public event System.Action OnExploreToggleOff; |
| | 69 | | public event System.Action OnExploreV2ToggleOn; |
| | 70 | | public event System.Action OnExploreV2ToggleOff; |
| | 71 | | public event System.Action OnMoreToggleOn; |
| | 72 | | public event System.Action OnMoreToggleOff; |
| | 73 | | public event System.Action<bool> OnQuestPanelToggled; |
| | 74 | |
|
| | 75 | | internal List<TaskbarButton> GetButtonList() |
| | 76 | | { |
| 16 | 77 | | var taskbarButtonList = new List<TaskbarButton>(); |
| 16 | 78 | | taskbarButtonList.Add(chatButton); |
| 16 | 79 | | taskbarButtonList.Add(friendsButton); |
| 16 | 80 | | taskbarButtonList.AddRange(chatHeadsGroup.chatHeads); |
| 16 | 81 | | taskbarButtonList.Add(builderInWorldButton); |
| 16 | 82 | | taskbarButtonList.Add(settingsButton); |
| 16 | 83 | | taskbarButtonList.Add(exploreButton); |
| 16 | 84 | | taskbarButtonList.Add(exploreV2Button); |
| 16 | 85 | | taskbarButtonList.Add(moreButton); |
| 16 | 86 | | taskbarButtonList.Add(questPanelButton); |
| | 87 | |
|
| 16 | 88 | | using (var iterator = activePortableExperienceItems.GetEnumerator()) |
| | 89 | | { |
| 16 | 90 | | while (iterator.MoveNext()) |
| | 91 | | { |
| 0 | 92 | | taskbarButtonList.Add(iterator.Current.Value.mainButton); |
| | 93 | | } |
| 16 | 94 | | } |
| | 95 | |
|
| 16 | 96 | | return taskbarButtonList; |
| | 97 | | } |
| | 98 | |
|
| | 99 | | internal static TaskbarHUDView Create(TaskbarHUDController controller, IChatController chatController, |
| | 100 | | IFriendsController friendsController) |
| | 101 | | { |
| 11 | 102 | | var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<TaskbarHUDView>(); |
| 11 | 103 | | view.Initialize(controller, chatController, friendsController); |
| 11 | 104 | | return view; |
| | 105 | | } |
| | 106 | |
|
| | 107 | | public void Initialize(TaskbarHUDController controller, IChatController chatController, |
| | 108 | | IFriendsController friendsController) |
| | 109 | | { |
| 11 | 110 | | this.controller = controller; |
| | 111 | |
|
| 11 | 112 | | ShowBar(true, true); |
| 11 | 113 | | chatButton.transform.parent.gameObject.SetActive(false); |
| 11 | 114 | | friendsButton.transform.parent.gameObject.SetActive(false); |
| 11 | 115 | | builderInWorldButton.transform.parent.gameObject.SetActive(false); |
| 11 | 116 | | settingsButton.transform.parent.gameObject.SetActive(false); |
| 11 | 117 | | exploreButton.transform.parent.gameObject.SetActive(false); |
| 11 | 118 | | exploreV2Button.transform.parent.gameObject.SetActive(false); |
| 11 | 119 | | voiceChatButtonPlaceholder.SetActive(false); |
| 11 | 120 | | voiceChatButton.gameObject.SetActive(false); |
| | 121 | |
|
| 11 | 122 | | moreButton.gameObject.SetActive(true); |
| 11 | 123 | | moreMenu.Initialize(this); |
| 11 | 124 | | moreMenu.ShowMoreMenu(false, true); |
| | 125 | |
|
| 11 | 126 | | chatHeadsGroup.Initialize(chatController, friendsController); |
| 11 | 127 | | chatButton.Initialize(); |
| 11 | 128 | | friendsButton.Initialize(); |
| 11 | 129 | | builderInWorldButton.Initialize(); |
| 11 | 130 | | settingsButton.Initialize(); |
| 11 | 131 | | exploreButton.Initialize(); |
| 11 | 132 | | exploreV2Button.Initialize(); |
| 11 | 133 | | moreButton.Initialize(); |
| 11 | 134 | | questPanelButton.Initialize(); |
| | 135 | |
|
| 11 | 136 | | chatHeadsGroup.OnHeadToggleOn += OnWindowToggleOn; |
| 11 | 137 | | chatHeadsGroup.OnHeadToggleOff += OnWindowToggleOff; |
| | 138 | |
|
| 11 | 139 | | chatButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 140 | | chatButton.OnToggleOff += OnWindowToggleOff; |
| | 141 | |
|
| 11 | 142 | | friendsButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 143 | | friendsButton.OnToggleOff += OnWindowToggleOff; |
| | 144 | |
|
| 11 | 145 | | builderInWorldButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 146 | | builderInWorldButton.OnToggleOff += OnWindowToggleOff; |
| | 147 | |
|
| 11 | 148 | | settingsButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 149 | | settingsButton.OnToggleOff += OnWindowToggleOff; |
| | 150 | |
|
| 11 | 151 | | exploreButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 152 | | exploreButton.OnToggleOff += OnWindowToggleOff; |
| | 153 | |
|
| 11 | 154 | | exploreV2Button.OnToggleOn += OnWindowToggleOn; |
| 11 | 155 | | exploreV2Button.OnToggleOff += OnWindowToggleOff; |
| | 156 | |
|
| 11 | 157 | | moreButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 158 | | moreButton.OnToggleOff += OnWindowToggleOff; |
| | 159 | |
|
| 11 | 160 | | questPanelButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 161 | | questPanelButton.OnToggleOff -= OnWindowToggleOff; |
| 11 | 162 | | questPanelButton.OnToggleOn += OnWindowToggleOn; |
| 11 | 163 | | questPanelButton.OnToggleOff += OnWindowToggleOff; |
| | 164 | |
|
| 11 | 165 | | portableExperiencesDiv.SetActive(false); |
| | 166 | |
|
| 11 | 167 | | portableExperiencesPool = PoolManager.i.AddPool( |
| | 168 | | PORTABLE_EXPERIENCE_ITEMS_POOL, |
| | 169 | | Instantiate(portableExperienceItem.gameObject), |
| | 170 | | maxPrewarmCount: 5, |
| | 171 | | isPersistent: true); |
| | 172 | |
|
| 11 | 173 | | portableExperiencesPool.ForcePrewarm(); |
| | 174 | |
|
| 11 | 175 | | AdjustRightButtonsLayoutWidth(); |
| 11 | 176 | | } |
| | 177 | |
|
| | 178 | | public void SetBuilderInWorldStatus(bool isActive) |
| | 179 | | { |
| 1 | 180 | | builderInWorldButton.transform.parent.gameObject.SetActive(isActive); |
| 1 | 181 | | AdjustRightButtonsLayoutWidth(); |
| 1 | 182 | | } |
| | 183 | |
|
| 0 | 184 | | public void SetQuestsPanelStatus(bool isActive) { questPanelButton.transform.parent.gameObject.SetActive(isActive); |
| | 185 | |
|
| | 186 | | private void OnWindowToggleOff(TaskbarButton obj) |
| | 187 | | { |
| 6 | 188 | | if (obj == friendsButton) |
| 2 | 189 | | OnFriendsToggleOff?.Invoke(); |
| 4 | 190 | | else if (obj == chatButton) |
| 2 | 191 | | OnChatToggleOff?.Invoke(); |
| 2 | 192 | | else if (obj == settingsButton) |
| 0 | 193 | | OnSettingsToggleOff?.Invoke(); |
| 2 | 194 | | else if (obj == builderInWorldButton) |
| 0 | 195 | | OnBuilderInWorldToggleOff?.Invoke(); |
| 2 | 196 | | else if (obj == exploreButton) |
| 1 | 197 | | OnExploreToggleOff?.Invoke(); |
| 1 | 198 | | else if (obj == exploreV2Button) |
| 0 | 199 | | OnExploreV2ToggleOff?.Invoke(); |
| 1 | 200 | | else if (obj == moreButton) |
| 0 | 201 | | moreMenu.ShowMoreMenu(false); |
| 1 | 202 | | else if (obj == questPanelButton) |
| 0 | 203 | | OnQuestPanelToggled?.Invoke(false); |
| | 204 | | else |
| | 205 | | { |
| 1 | 206 | | using (var iterator = activePortableExperienceItems.GetEnumerator()) |
| | 207 | | { |
| 1 | 208 | | while (iterator.MoveNext()) |
| | 209 | | { |
| 0 | 210 | | if (iterator.Current.Value.mainButton == obj) |
| | 211 | | { |
| 0 | 212 | | iterator.Current.Value.ShowContextMenu(false); |
| 0 | 213 | | break; |
| | 214 | | } |
| | 215 | | } |
| 1 | 216 | | } |
| | 217 | | } |
| | 218 | |
|
| 6 | 219 | | if (AllButtonsToggledOff()) |
| | 220 | | { |
| 5 | 221 | | chatButton.SetToggleState(false, useCallback: false); |
| 5 | 222 | | controller.worldChatWindowHud.SetVisibility(true); |
| | 223 | | } |
| 6 | 224 | | } |
| | 225 | |
|
| | 226 | | public bool AllButtonsToggledOff() |
| | 227 | | { |
| 8 | 228 | | var btns = GetButtonList(); |
| | 229 | |
|
| 8 | 230 | | bool allToggledOff = true; |
| | 231 | |
|
| 150 | 232 | | foreach (var btn in btns) |
| | 233 | | { |
| 67 | 234 | | if (btn.toggledOn) |
| 1 | 235 | | allToggledOff = false; |
| | 236 | | } |
| | 237 | |
|
| 8 | 238 | | return allToggledOff; |
| | 239 | | } |
| | 240 | |
|
| | 241 | | private void OnWindowToggleOn(TaskbarButton obj) |
| | 242 | | { |
| 6 | 243 | | if (obj == friendsButton) |
| 2 | 244 | | OnFriendsToggleOn?.Invoke(); |
| 4 | 245 | | else if (obj == chatButton) |
| 3 | 246 | | OnChatToggleOn?.Invoke(); |
| 1 | 247 | | else if (obj == settingsButton) |
| 0 | 248 | | OnSettingsToggleOn?.Invoke(); |
| 1 | 249 | | else if (obj == builderInWorldButton) |
| 0 | 250 | | OnBuilderInWorldToggleOn?.Invoke(); |
| 1 | 251 | | else if (obj == exploreButton) |
| 0 | 252 | | OnExploreToggleOn?.Invoke(); |
| 1 | 253 | | else if (obj == exploreV2Button) |
| 0 | 254 | | OnExploreV2ToggleOn?.Invoke(); |
| 1 | 255 | | else if (obj == moreButton) |
| 0 | 256 | | moreMenu.ShowMoreMenu(true); |
| 1 | 257 | | else if (obj == questPanelButton) |
| 0 | 258 | | OnQuestPanelToggled?.Invoke(true); |
| | 259 | | else |
| | 260 | | { |
| 1 | 261 | | using (var iterator = activePortableExperienceItems.GetEnumerator()) |
| | 262 | | { |
| 1 | 263 | | while (iterator.MoveNext()) |
| | 264 | | { |
| 0 | 265 | | if (iterator.Current.Value.mainButton == obj) |
| | 266 | | { |
| 0 | 267 | | iterator.Current.Value.ShowContextMenu(true); |
| 0 | 268 | | break; |
| | 269 | | } |
| | 270 | | } |
| 1 | 271 | | } |
| | 272 | | } |
| | 273 | |
|
| 6 | 274 | | SelectButton(obj); |
| 6 | 275 | | } |
| | 276 | |
|
| | 277 | | public void SelectButton(TaskbarButton obj) |
| | 278 | | { |
| 7 | 279 | | var taskbarButtonList = GetButtonList(); |
| | 280 | |
|
| 134 | 281 | | foreach (var btn in taskbarButtonList) |
| | 282 | | { |
| 60 | 283 | | if (btn != obj) |
| | 284 | | { |
| | 285 | | // We let the use of the chat and friends windows while we are using the explore at the same time |
| 53 | 286 | | if (((btn == exploreButton || btn == exploreV2Button) && (obj == chatButton || obj == friendsButton || o |
| | 287 | | ((btn == chatButton || btn == friendsButton || btn is ChatHeadButton) && (obj == exploreButton || ob |
| | 288 | | continue; |
| | 289 | |
|
| 41 | 290 | | btn.SetToggleState(false, useCallback: true); |
| | 291 | | } |
| | 292 | | } |
| 7 | 293 | | } |
| | 294 | |
|
| 4 | 295 | | internal void OnAddChatWindow() { chatButton.transform.parent.gameObject.SetActive(true); } |
| | 296 | |
|
| 6 | 297 | | internal void OnAddFriendsWindow() { friendsButton.transform.parent.gameObject.SetActive(true); } |
| | 298 | |
|
| | 299 | | internal void OnAddSettingsWindow() |
| | 300 | | { |
| 2 | 301 | | settingsButton.transform.parent.gameObject.SetActive(true); |
| 2 | 302 | | AdjustRightButtonsLayoutWidth(); |
| 2 | 303 | | } |
| | 304 | |
|
| | 305 | | internal void OnAddExploreWindow() |
| | 306 | | { |
| 2 | 307 | | exploreButton.transform.parent.gameObject.SetActive(true); |
| 2 | 308 | | AdjustRightButtonsLayoutWidth(); |
| 2 | 309 | | } |
| | 310 | |
|
| | 311 | | internal void OnAddExploreV2Window() |
| | 312 | | { |
| 0 | 313 | | exploreV2Button.transform.parent.gameObject.SetActive(true); |
| 0 | 314 | | AdjustRightButtonsLayoutWidth(); |
| 0 | 315 | | } |
| | 316 | |
|
| 4 | 317 | | internal void OnAddHelpAndSupportWindow() { moreMenu.ActivateHelpAndSupportButton(); } |
| | 318 | |
|
| 4 | 319 | | internal void OnAddControlsMoreOption() { moreMenu.ActivateControlsButton(); } |
| | 320 | |
|
| | 321 | | internal void OnAddVoiceChat() |
| | 322 | | { |
| 0 | 323 | | voiceChatButtonPlaceholder.SetActive(true); |
| 0 | 324 | | voiceChatButton.gameObject.SetActive(true); |
| 0 | 325 | | } |
| | 326 | |
|
| | 327 | | internal void ShowBar(bool visible, bool instant = false) |
| | 328 | | { |
| 13 | 329 | | if (visible) |
| 12 | 330 | | taskbarAnimator.Show(instant); |
| | 331 | | else |
| 1 | 332 | | taskbarAnimator.Hide(instant); |
| | 333 | |
|
| 13 | 334 | | isBarVisible = visible; |
| 13 | 335 | | } |
| | 336 | |
|
| 2 | 337 | | public void SetVisibility(bool visible) { gameObject.SetActive(visible); } |
| | 338 | |
|
| | 339 | | private void OnDestroy() |
| | 340 | | { |
| 11 | 341 | | if (chatHeadsGroup != null) |
| | 342 | | { |
| 11 | 343 | | chatHeadsGroup.OnHeadToggleOn -= OnWindowToggleOn; |
| 11 | 344 | | chatHeadsGroup.OnHeadToggleOff -= OnWindowToggleOff; |
| | 345 | | } |
| | 346 | |
|
| 11 | 347 | | if (chatButton != null) |
| | 348 | | { |
| 11 | 349 | | chatButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 350 | | chatButton.OnToggleOff -= OnWindowToggleOff; |
| | 351 | | } |
| | 352 | |
|
| 11 | 353 | | if (friendsButton != null) |
| | 354 | | { |
| 11 | 355 | | friendsButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 356 | | friendsButton.OnToggleOff -= OnWindowToggleOff; |
| | 357 | | } |
| | 358 | |
|
| 11 | 359 | | if (settingsButton != null) |
| | 360 | | { |
| 11 | 361 | | settingsButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 362 | | settingsButton.OnToggleOff -= OnWindowToggleOff; |
| | 363 | | } |
| | 364 | |
|
| 11 | 365 | | if (builderInWorldButton != null) |
| | 366 | | { |
| 11 | 367 | | builderInWorldButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 368 | | builderInWorldButton.OnToggleOff -= OnWindowToggleOff; |
| | 369 | | } |
| | 370 | |
|
| 11 | 371 | | if (exploreButton != null) |
| | 372 | | { |
| 11 | 373 | | exploreButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 374 | | exploreButton.OnToggleOff -= OnWindowToggleOff; |
| | 375 | | } |
| | 376 | |
|
| 11 | 377 | | if (exploreV2Button != null) |
| | 378 | | { |
| 11 | 379 | | exploreV2Button.OnToggleOn -= OnWindowToggleOn; |
| 11 | 380 | | exploreV2Button.OnToggleOff -= OnWindowToggleOff; |
| | 381 | | } |
| | 382 | |
|
| 11 | 383 | | if (moreButton != null) |
| | 384 | | { |
| 11 | 385 | | moreButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 386 | | moreButton.OnToggleOff -= OnWindowToggleOff; |
| | 387 | | } |
| | 388 | |
|
| 11 | 389 | | if (questPanelButton != null) |
| | 390 | | { |
| 11 | 391 | | questPanelButton.OnToggleOn -= OnWindowToggleOn; |
| 11 | 392 | | questPanelButton.OnToggleOff -= OnWindowToggleOff; |
| | 393 | | } |
| 11 | 394 | | } |
| | 395 | |
|
| | 396 | | internal void AddPortableExperienceElement(string id, string name, string iconUrl) |
| | 397 | | { |
| 2 | 398 | | if (portableExperiencesPool == null) |
| 0 | 399 | | return; |
| | 400 | |
|
| 2 | 401 | | portableExperiencesDiv.SetActive(true); |
| | 402 | |
|
| 2 | 403 | | PoolableObject newPEPoolable = portableExperiencesPool.Get(); |
| 2 | 404 | | newPEPoolable.gameObject.name = $"PortableExperienceItem ({id})"; |
| 2 | 405 | | newPEPoolable.gameObject.transform.SetParent(rightButtonsContainer.transform); |
| 2 | 406 | | newPEPoolable.gameObject.transform.localScale = Vector3.one; |
| 2 | 407 | | newPEPoolable.gameObject.transform.SetAsFirstSibling(); |
| | 408 | |
|
| 2 | 409 | | PortableExperienceTaskbarItem newPEItem = newPEPoolable.gameObject.GetComponent<PortableExperienceTaskbarItem>() |
| 2 | 410 | | newPEItem.ConfigureItem(id, name, iconUrl, controller); |
| 2 | 411 | | newPEItem.mainButton.OnToggleOn += OnWindowToggleOn; |
| 2 | 412 | | newPEItem.mainButton.OnToggleOff += OnWindowToggleOff; |
| | 413 | |
|
| 2 | 414 | | activePortableExperienceItems.Add(id, newPEItem); |
| 2 | 415 | | activePortableExperiencesPoolables.Add(id, newPEPoolable); |
| | 416 | |
|
| 2 | 417 | | AdjustRightButtonsLayoutWidth(); |
| 2 | 418 | | } |
| | 419 | |
|
| | 420 | | internal void RemovePortableExperienceElement(string id) |
| | 421 | | { |
| 1 | 422 | | if (portableExperiencesPool == null) |
| 0 | 423 | | return; |
| | 424 | |
|
| 1 | 425 | | if (activePortableExperienceItems.ContainsKey(id)) |
| | 426 | | { |
| 1 | 427 | | PortableExperienceTaskbarItem peToRemove = activePortableExperienceItems[id]; |
| | 428 | |
|
| 1 | 429 | | peToRemove.mainButton.OnToggleOn -= OnWindowToggleOn; |
| 1 | 430 | | peToRemove.mainButton.OnToggleOff -= OnWindowToggleOff; |
| | 431 | |
|
| 1 | 432 | | activePortableExperienceItems.Remove(id); |
| 1 | 433 | | portableExperiencesPool.Release(activePortableExperiencesPoolables[id]); |
| 1 | 434 | | activePortableExperiencesPoolables.Remove(id); |
| | 435 | | } |
| | 436 | |
|
| 1 | 437 | | if (activePortableExperienceItems.Count == 0) |
| 1 | 438 | | portableExperiencesDiv.SetActive(false); |
| | 439 | |
|
| 1 | 440 | | AdjustRightButtonsLayoutWidth(); |
| 1 | 441 | | } |
| | 442 | |
|
| | 443 | | [ContextMenu("AdjustRightButtonsLayoutWidth")] |
| | 444 | | private void AdjustRightButtonsLayoutWidth() |
| | 445 | | { |
| 19 | 446 | | float totalWidth = 0f; |
| 19 | 447 | | int numActiveChild = 0; |
| 19 | 448 | | RectTransform rightButtonsContainerRT = (RectTransform)rightButtonsContainer.transform; |
| | 449 | |
|
| 308 | 450 | | for (int i = 0; i < rightButtonsContainerRT.childCount; i++) |
| | 451 | | { |
| 135 | 452 | | RectTransform child = (RectTransform)rightButtonsContainerRT.GetChild(i); |
| | 453 | |
|
| 135 | 454 | | if (!child.gameObject.activeSelf) |
| | 455 | | continue; |
| | 456 | |
|
| 50 | 457 | | totalWidth += child.sizeDelta.x; |
| 50 | 458 | | numActiveChild++; |
| | 459 | | } |
| | 460 | |
|
| 19 | 461 | | totalWidth += |
| | 462 | | ((numActiveChild - 1) * rightButtonsHorizontalLayout.spacing) + |
| | 463 | | rightButtonsHorizontalLayout.padding.left + |
| | 464 | | rightButtonsHorizontalLayout.padding.right; |
| | 465 | |
|
| 19 | 466 | | ((RectTransform)rightButtonsContainer.transform).sizeDelta = new Vector2(totalWidth, ((RectTransform)rightButton |
| 19 | 467 | | } |
| | 468 | | } |