public void SetPreset(PolyAssetCatalog.AssetDetails asset, int index) { if (asset != m_PacAsset) { m_LoadingOverlay.SetActive(false); } m_PacAsset = asset; SetPreset(asset.Model, index); if (m_PacAsset.ModelRotation != null) { Quaternion publishedRotation = m_PacAsset.ModelRotation.Value; m_PreviewBaseRotation = Quaternion.Euler(0, publishedRotation.eulerAngles.y, 0); } }
protected override void RefreshPage() { m_NoLikesMessage.SetActive(false); m_NoAuthoredModelsMessage.SetActive(false); m_NotLoggedInMessage.SetActive(false); if (VrAssetService.m_Instance.NoConnection) { m_NoPolyConnectionMessage.SetActive(true); RefreshPanelText(); base.RefreshPage(); return; } if (!VrAssetService.m_Instance.Available) { m_OutOfDateMessage.SetActive(true); RefreshPanelText(); base.RefreshPage(); return; } #if UNITY_ANDROID && OCULUS_SUPPORTED if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Quest) { m_NotSupportedMessage.SetActive(true); RefreshPanelText(); base.RefreshPage(); return; } #endif m_NumPages = ((App.PolyAssetCatalog.NumCloudModels(m_CurrentSet) - 1) / Icons.Count) + 1; int numCloudModels = App.PolyAssetCatalog.NumCloudModels(m_CurrentSet); if (m_LastPageIndexForLoad != PageIndex || m_LastSetTypeForLoad != m_CurrentSet) { // Unload the previous page's models. // This function may be called multiple times as icons load, only unload the old models once, // otherwise the current page's models will be thrashed. m_LastPageIndexForLoad = PageIndex; m_LastSetTypeForLoad = m_CurrentSet; // Destroy previews so only the thumbnail is visible. for (int i = 0; i < Icons.Count; i++) { ((ModelButton)Icons[i]).DestroyModelPreview(); } App.PolyAssetCatalog.UnloadUnusedModels(); } for (int i = 0; i < Icons.Count; i++) { PolyModelButton icon = (PolyModelButton)Icons[i]; // Set sketch index relative to page based index int iMapIndex = m_IndexOffset + i; // Init icon according to availability of sketch GameObject go = icon.gameObject; if (iMapIndex < numCloudModels) { PolyAssetCatalog.AssetDetails asset = App.PolyAssetCatalog.GetPolyAsset(m_CurrentSet, iMapIndex); go.SetActive(true); if (icon.Asset != null && asset.AssetId != icon.Asset.AssetId) { icon.DestroyModelPreview(); } icon.SetPreset(asset, iMapIndex); // Note that App.UserConfig.Flags.PolyModelPreload falls through to // App.PlatformConfig.EnablePolyPreload if it isn't set in Tilt Brush.cfg. if (App.UserConfig.Flags.PolyModelPreload) { icon.RequestModelPreload(PageIndex); } } else { go.SetActive(false); } } bool internetError = App.PolyAssetCatalog.NumCloudModels(PolySetType.Featured) == 0; m_InternetError.SetActive(internetError); RefreshPanelText(); switch (m_CurrentSet) { case PolySetType.User: if (!internetError) { if (App.GoogleIdentity.LoggedIn) { if (numCloudModels == 0) { m_NoAuthoredModelsMessage.SetActive(true); } } else { m_NotLoggedInMessage.SetActive(true); } } break; case PolySetType.Liked: if (!internetError) { if (App.GoogleIdentity.LoggedIn) { if (numCloudModels == 0) { m_NoLikesMessage.SetActive(true); } } else { m_NotLoggedInMessage.SetActive(true); } } break; } base.RefreshPage(); }