Ejemplo n.º 1
0
        void Update()
        {
            BaseUpdate();
            PageFlipUpdate();

            // Refresh icons while they are in flux
            if (m_SketchSet.IsReadyForAccess &&
                (!m_SketchSet.RequestedIconsAreLoaded ||
                 !m_AllIconTexturesAssigned || !m_AllSketchesAreAvailable))
            {
                UpdateIcons();
            }

            // Set icon uv offsets relative to head position.
            Vector3 head_LS = m_Mesh.transform.InverseTransformPoint(ViewpointScript.Head.position);
            float   angleX  = Vector3.Angle(Vector3.back, new Vector3(head_LS.x, 0.0f, head_LS.z));

            angleX *= (head_LS.x > 0.0f) ? -1.0f : 1.0f;

            float angleY = Vector3.Angle(Vector3.back, new Vector3(0.0f, head_LS.y, head_LS.z));

            angleY *= (head_LS.y > 0.0f) ? -1.0f : 1.0f;

            float   maxAngleXRatio = angleX / 90.0f;
            float   maxAngleYRatio = angleY / 90.0f;
            Vector2 offset         = new Vector2(
                m_HalfInvUvScale.x + (m_HalfInvUvScale.x * maxAngleXRatio),
                m_HalfInvUvScale.y + (m_HalfInvUvScale.y * maxAngleYRatio));

            for (int i = 0; i < Icons.Count; i++)
            {
                LoadSketchButton icon = Icons[i] as LoadSketchButton;
                icon.UpdateUvOffsetAndScale(offset, m_SketchIconUvScale);
            }

            switch (m_CurrentSketchSet)
            {
            case SketchSetType.Curated:
                m_LoadingGallery.SetActive(m_SketchSet.IsActivelyRefreshingSketches);
                m_DriveSyncProgress.SetActive(false);
                m_SyncingDriveIcon.SetActive(false);
                m_DriveEnabledIcon.SetActive(false);
                m_DriveDisabledIcon.SetActive(false);
                m_DriveFullIcon.SetActive(false);
                break;

            case SketchSetType.Liked:
                m_LoadingGallery.SetActive(false);
                m_DriveSyncProgress.SetActive(false);
                m_SyncingDriveIcon.SetActive(false);
                m_DriveEnabledIcon.SetActive(false);
                m_DriveDisabledIcon.SetActive(false);
                m_DriveFullIcon.SetActive(false);
                break;

            case SketchSetType.User:
            case SketchSetType.Drive:
                bool sketchSetRefreshing = m_CurrentSketchSet == SketchSetType.Drive &&
                                           m_SketchSet.IsActivelyRefreshingSketches;
                bool driveSyncing   = App.DriveSync.Syncing;
                bool syncEnabled    = App.DriveSync.SyncEnabled;
                bool googleLoggedIn = App.GoogleIdentity.LoggedIn;
                bool driveFull      = App.DriveSync.DriveIsLowOnSpace;
                m_LoadingGallery.SetActive(sketchSetRefreshing && !driveSyncing);
                m_DriveSyncProgress.SetActive(driveSyncing && !driveFull);
                m_SyncingDriveIcon.SetActive(driveSyncing && !driveFull);
                m_DriveEnabledIcon.SetActive(!driveFull && !driveSyncing && syncEnabled && googleLoggedIn);
                m_DriveDisabledIcon.SetActive(!syncEnabled && googleLoggedIn);
                m_DriveFullIcon.SetActive(driveFull && syncEnabled && googleLoggedIn);
                break;
            }

            // Check to see if whether "drive set has sketches" has changed.
            bool driveSetHasSketches =
                SketchCatalog.m_Instance.GetSet(SketchSetType.Drive).NumSketches != 0;

            if (m_DriveSetHasSketches != driveSetHasSketches)
            {
                m_DriveSetHasSketches = driveSetHasSketches;
                OnDriveSetHasSketchesChanged();
            }
        }
Ejemplo n.º 2
0
        // UpdateIcons() is called repeatedly by Update() until these three conditions are met:
        // 1: The SketchSet has loaded all the requested icons
        // 2: The textures for all the buttons have been set
        // 3: (Cloud only) The SketchSet has downloaded the corresponding .tilt files.
        //    Until the .tilt file is downloaded we set a fade on the button, and need to keep updating
        //    until the file is downloaded.
        private void UpdateIcons()
        {
            m_AllIconTexturesAssigned = true;
            m_AllSketchesAreAvailable = true;

            // Poll sketch catalog until icons have loaded
            foreach (BaseButton baseButton in Icons)
            {
                LoadSketchButton icon = baseButton as LoadSketchButton;
                if (icon == null)
                {
                    continue;
                }
                int iSketchIndex = icon.SketchIndex;
                if (m_SketchSet.IsSketchIndexValid(iSketchIndex))
                {
                    icon.FadeIn = m_SketchSet.GetSketchSceneFileInfo(iSketchIndex).Available ? 1f : 0.5f;

                    if (!icon.ThumbnailLoaded)
                    {
                        Texture2D rTexture = null;
                        string[]  authors;
                        string    description;
                        if (m_SketchSet.GetSketchIcon(iSketchIndex, out rTexture, out authors, out description))
                        {
                            if (rTexture != null)
                            {
                                // Pass through aspect ratio of image so we don't get squished
                                // thumbnails from Poly
                                m_ImageAspect = (float)rTexture.width / rTexture.height;
                                float aspect = m_ImageAspect;
                                icon.SetButtonTexture(rTexture, aspect);
                            }
                            else
                            {
                                icon.SetButtonTexture(m_UnknownImageTexture);
                            }

                            // Mark the texture as assigned regardless of actual bits being valid
                            icon.ThumbnailLoaded = true;
                            ;
                            List <string> lines = new List <string>();
                            lines.Add(icon.Description);

                            SceneFileInfo info = m_SketchSet.GetSketchSceneFileInfo(iSketchIndex);
                            if (info is PolySceneFileInfo polyInfo &&
                                polyInfo.License != VrAssetService.kCreativeCommonsLicense)
                            {
                                lines.Add(String.Format("© {0}", authors[0]));
                                lines.Add("All Rights Reserved");
                            }
                            else
                            {
                                // Include primary author in description if available
                                if (authors != null && authors.Length > 0)
                                {
                                    lines.Add(authors[0]);
                                }
                                // Include an actual description
                                if (description != null)
                                {
                                    lines.Add(App.ShortenForDescriptionText(description));
                                }
                            }
                            icon.SetDescriptionText(lines.ToArray());
                        }
                        else
                        {
                            // While metadata has not finished loading, check if this file is valid
                            bool          bFileValid = false;
                            SceneFileInfo rInfo      = m_SketchSet.GetSketchSceneFileInfo(iSketchIndex);
                            if (rInfo != null)
                            {
                                bFileValid = rInfo.Exists;
                            }

                            // If this file isn't valid, just keep the defaults and move on
                            if (!bFileValid)
                            {
                                icon.SetButtonTexture(m_UnknownImageTexture);
                                icon.ThumbnailLoaded = true;
                            }
                            else
                            {
                                m_AllIconTexturesAssigned = false;
                            }
                            if (!rInfo.Available)
                            {
                                m_AllSketchesAreAvailable = false;
                            }
                        }
                    }
                }
            }
Ejemplo n.º 3
0
        protected override void RefreshPage()
        {
            m_SketchSet.RequestOnlyLoadedMetadata(GetIconLoadIndices());
            m_AllIconTexturesAssigned = false;
            m_AllSketchesAreAvailable = false;

            // Disable all.
            foreach (var i in m_IconsOnFirstPage)
            {
                i.SetActive(false);
            }
            foreach (var i in m_IconsOnNormalPage)
            {
                i.SetActive(false);
            }

            // Base Refresh updates the modal parts of the panel, and we always want those refreshed.
            base.RefreshPage();

            bool polyDown = VrAssetService.m_Instance.NoConnection &&
                            (m_CurrentSketchSet == SketchSetType.Curated ||
                             m_CurrentSketchSet == SketchSetType.Liked);

            m_NoPolyConnectionMessage.SetActive(polyDown);

            bool outOfDate = !polyDown && !VrAssetService.m_Instance.Available &&
                             (m_CurrentSketchSet == SketchSetType.Curated ||
                              m_CurrentSketchSet == SketchSetType.Liked);

            m_OutOfDateMessage.SetActive(outOfDate);

            if (outOfDate || polyDown)
            {
                m_NoSketchesMessage.SetActive(false);
                m_NoDriveSketchesMessage.SetActive(false);
                m_NotLoggedInMessage.SetActive(false);
                m_NoLikesMessage.SetActive(false);
                m_ContactingServerMessage.SetActive(false);
                m_NoShowcaseMessage.SetActive(false);
                return;
            }

            bool refreshIcons = m_SketchSet.NumSketches > 0;

            // Show no sketches if we don't have sketches.
            m_NoSketchesMessage.SetActive(
                (m_CurrentSketchSet == SketchSetType.User) && (m_SketchSet.NumSketches <= 0));
            m_NoDriveSketchesMessage.SetActive(
                (m_CurrentSketchSet == SketchSetType.Drive) && (m_SketchSet.NumSketches <= 0));

            // Show sign in popup if signed out for liked or drive sketchsets
            bool showNotLoggedIn = !App.GoogleIdentity.LoggedIn &&
                                   (m_CurrentSketchSet == SketchSetType.Liked ||
                                    m_CurrentSketchSet == SketchSetType.Drive);

            refreshIcons = refreshIcons && !showNotLoggedIn;
            m_NotLoggedInMessage.SetActive(showNotLoggedIn && m_CurrentSketchSet == SketchSetType.Liked);
            m_NotLoggedInDriveMessage.SetActive(showNotLoggedIn &&
                                                m_CurrentSketchSet == SketchSetType.Drive);

            // Show no likes text & gallery button if we don't have liked sketches.
            m_NoLikesMessage.SetActive(
                (m_CurrentSketchSet == SketchSetType.Liked) &&
                (m_SketchSet.NumSketches <= 0) &&
                !m_SketchSet.IsActivelyRefreshingSketches &&
                App.GoogleIdentity.LoggedIn);

            // Show Contacting Server if we're talking to Poly.
            m_ContactingServerMessage.SetActive(
                (m_CurrentSketchSet == SketchSetType.Curated ||
                 m_CurrentSketchSet == SketchSetType.Liked ||
                 m_CurrentSketchSet == SketchSetType.Drive) &&
                (m_SketchSet.NumSketches <= 0) &&
                (m_SketchSet.IsActivelyRefreshingSketches && App.GoogleIdentity.LoggedIn));

            // Show Showcase error if we're in Showcase and don't have sketches.
            m_NoShowcaseMessage.SetActive(
                (m_CurrentSketchSet == SketchSetType.Curated) &&
                (m_SketchSet.NumSketches <= 0) &&
                !m_SketchSet.IsActivelyRefreshingSketches);

            // Refresh all icons if necessary.
            if (!refreshIcons)
            {
                return;
            }

            for (int i = 0; i < Icons.Count; i++)
            {
                LoadSketchButton icon = Icons[i] as LoadSketchButton;
                // Default to loading image
                icon.SetButtonTexture(m_LoadingImageTexture);
                icon.ThumbnailLoaded = false;

                // Set sketch index relative to page based index
                int iSketchIndex = m_IndexOffset + i;
                if (iSketchIndex >= m_SketchSet.NumSketches)
                {
                    iSketchIndex = -1;
                }
                icon.SketchIndex = iSketchIndex;
                icon.ResetScale();

                // Init icon according to availability of sketch
                GameObject go = icon.gameObject;
                if (m_SketchSet.IsSketchIndexValid(iSketchIndex))
                {
                    string sSketchName = m_SketchSet.GetSketchName(iSketchIndex);
                    icon.SetDescriptionText(App.ShortenForDescriptionText(sSketchName));
                    SceneFileInfo info = m_SketchSet.GetSketchSceneFileInfo(iSketchIndex);
                    if (info.Available)
                    {
                        m_SketchSet.PrecacheSketchModels(iSketchIndex);
                    }

                    if (info.TriangleCount is int triCount)
                    {
                        icon.WarningVisible = triCount >
                                              QualityControls.m_Instance.AppQualityLevels.WarningPolySketchTriangles;
                    }
                    else
                    {
                        icon.WarningVisible = false;
                    }
                    go.SetActive(true);
                }
                else
                {
                    go.SetActive(false);
                }
            }
        }