예제 #1
0
        /// <summary>
        /// Update the current state of the mesh preview.
        /// As AssetPreview API is asynchronous, we need to keep requesting the asset preview
        /// until we have it. Once texture is loaded, current state of the instance moves
        /// to Status.Loaded.
        /// </summary>
        internal void UpdatePreview()
        {
            switch (m_previewState)
            {
            case State.Loading:
                if (ProBuilderBridge.ProBuilderExists() && ProBuilderInterface.IsProBuilderObject(m_Asset as GameObject))
                {
                    m_PreviewTexture = GenerateProBuilderPreview();
                }
                else if (PolyEditorUtility.IsPolybrushObject(m_Asset as GameObject))
                {
                    m_PreviewTexture = GeneratePreview();
                }
                else
                {
                    m_PreviewTexture = AssetPreview.GetAssetPreview(m_Asset);
                }

                if (previewTexture != null)
                {
                    SetState(State.Loaded);
                }

                break;

            case State.Loaded:
                // Failsafe as AssetPreview can return white textures while loading
                // and erase that texture from memory once the right texture is available.
                if (m_PreviewTexture == null)
                {
                    SetState(State.Loading);
                }
                break;
            }
        }