Beispiel #1
0
        public void UpdateTransforms(float scale)
        {
            if (Time.time - m_SetupTime > k_InitializeDelay)
            {
                m_SetupTime = float.MaxValue;

                // If this AssetData hasn't started fetching its asset yet, do so now
                if (!data.initialized)
                {
                    data.Initialize();
                }

#if INCLUDE_POLY_TOOLKIT
                data.modelImportCompleted     += OnModelImportCompleted;
                data.thumbnailImportCompleted += OnThumbnailImportCompleted;
#endif
            }

            // Don't scale the item while changing visibility because this would conflict with AnimateVisibility
            if (m_VisibilityCoroutine != null)
            {
                return;
            }

            var time = Time.time;

            TransitionUtils.AnimateProperty(time, m_Hovered, ref m_WasHovered, ref m_HoverTime, ref m_HoverLerp,
                                            ref m_HoverLerpStart, 0f, 1f, k_PreviewDuration, Mathf.Approximately, TransitionUtils.GetPercentage,
                                            Mathf.Lerp, m_SetThumbnailScale, true, m_CompleteHoverTransition);

            TransitionUtils.AnimateProperty(time, m_Importing, ref m_WasImporting, ref m_ImportingTime,
                                            ref m_ImportingScale, ref m_ImportingStartScale, m_IconScale.y, k_ImportingScaleBump, k_PreviewDuration,
                                            Mathf.Approximately, TransitionUtils.GetPercentage, Mathf.Lerp, m_SetImportingScale, false);

            TransitionUtils.AnimateProperty(time, m_Importing, ref m_WasImporting, ref m_ImportingTime,
                                            ref m_ImportingColor, ref m_ImportingStartColor, m_ImportingDefaultColor, m_ImportingTargetColor,
                                            k_PreviewDuration, TransitionUtils.Approximately, TransitionUtils.GetPercentage, Color.Lerp,
                                            m_SetImportingColor);

            scaleFactor = scale;

            transform.localScale = Vector3.one * scale;

            m_TextPanel.transform.localRotation = CameraUtils.LocalRotateTowardCamera(transform.parent);
        }
Beispiel #2
0
                public void Update(Renderer renderer, Material material, float time, float fadeInDuration, float fadeOutDuration,
                                   ProxyNode proxyNode, AffordanceVisibilityDefinition visibilityOverride)
                {
                    VisibilityState visibilityState = null;
                    var             definition      = visibilityOverride;
                    var             hideTime        = 0f;

                    if (definition == null)
                    {
                        foreach (var kvp in m_AffordanceVisibilityStates)
                        {
                            var state = kvp.Value;
                            if (state.visible)
                            {
                                if (state.hideTime > hideTime)
                                {
                                    definition      = state.definition;
                                    hideTime        = state.visibleDuration > 0 ? state.hideTime : 0;
                                    visibilityState = state;
                                }
                            }
                        }
                    }

                    var visible = definition != null;

                    if (!visible)
                    {
                        foreach (var kvp in m_AffordanceVisibilityStates)
                        {
                            visibilityState = kvp.Value;
                            definition      = visibilityState.definition;
                            break;
                        }
                    }

                    var fadeDuration = visible ? fadeInDuration : fadeOutDuration;

                    switch (definition.visibilityType)
                    {
                    case VisibilityControlType.AlphaProperty:
                        if (visibilityState == null)
                        {
                            var kvp = new KeyValuePair <Material, string>(material, definition.alphaProperty);
                            if (!m_VisibilityStates.TryGetValue(kvp, out visibilityState))
                            {
                                visibilityState         = new VisibilityState(renderer, null, definition, material);
                                m_VisibilityStates[kvp] = visibilityState;
                            }
                        }

                        TransitionUtils.AnimateProperty(time, visible, ref m_WasVisible, ref m_VisibleChangeTime,
                                                        ref m_CurrentColor.a, ref m_StartColor.a, definition.hiddenColor.a, m_OriginalColor.a,
                                                        fadeDuration, Mathf.Approximately, TransitionUtils.GetPercentage, Mathf.Lerp,
                                                        visibilityState.setFloat, false);
                        break;

                    case VisibilityControlType.ColorProperty:
                        if (visibilityState == null)
                        {
                            var kvp = new KeyValuePair <Material, string>(material, definition.alphaProperty);
                            if (!m_VisibilityStates.TryGetValue(kvp, out visibilityState))
                            {
                                visibilityState         = new VisibilityState(renderer, null, definition, material);
                                m_VisibilityStates[kvp] = visibilityState;
                            }
                        }

                        TransitionUtils.AnimateProperty(time, visible, ref m_WasVisible, ref m_VisibleChangeTime,
                                                        ref m_CurrentColor, ref m_StartColor, definition.hiddenColor, m_OriginalColor,
                                                        fadeDuration, TransitionUtils.Approximately, TransitionUtils.GetPercentage, Color.Lerp,
                                                        visibilityState.setColor, false);
                        break;
                    }

                    if (visible != m_WasVisible)
                    {
                        foreach (var kvp in m_AffordanceVisibilityStates)
                        {
                            visibilityState = kvp.Value;
                            if (visibilityState.definition.visibilityType == VisibilityControlType.MaterialSwap)
                            {
                                renderer.sharedMaterials[visibilityState.materialIndex] =
                                    visible ? material : visibilityState.definition.hiddenMaterial;
                            }
                        }
                    }

                    m_WasVisible = visible;

                    if (visible && hideTime > 0 && Time.time > hideTime)
                    {
                        foreach (var kvp in m_AffordanceVisibilityStates)
                        {
                            visibilityState = kvp.Value;
                            var tooltips = visibilityState.tooltips;
                            if (tooltips != null)
                            {
                                foreach (var tooltip in tooltips)
                                {
                                    if (tooltip)
                                    {
                                        proxyNode.HideTooltip(tooltip, true);
                                    }
                                }
                            }

                            proxyNode.SetHighlight(renderer.gameObject, false);

                            visibilityState.visible = false;
                        }
                    }
                }