Пример #1
0
        public float Evaluate(float value, TweenType type)
        {
            if (type == TweenType.Custom || direction == TweenDirection.Button)
            {
                return(customEase.Evaluate(((value - startPoint)) / (endPoint - startPoint)));
            }
            float duration = item.GetItemDuration();

            return(TSSTweenBase.Evaluate(((Mathf.Clamp(value, startPoint, endPoint) - startPoint)) * duration, duration == 0 ? 1 : (endPoint - startPoint) * duration, type));
        }
Пример #2
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                previewRenderUtility.BeginPreview(r, background);

                Material material = profile.isUI ? previewUIMaterial : previewMaterial;

                Vector3    position = profile.values.positions[0];
                Quaternion rotation = Quaternion.identity;
                Vector3    scale    = Vector3.one;

                Color closedColorAlpha = profile.values.colors[0];
                closedColorAlpha.a = profile.values.alphas[0];

                Color openedColorAlpha = profile.values.colors[1];
                closedColorAlpha.a = profile.values.alphas[1];

                if (material != null)
                {
                    material.SetColor("_Color", Color.white);
                }

                for (int i = 0; i < profile.tweens.Count; i++)
                {
                    if (!profile.tweens[i].enabled)
                    {
                        continue;
                    }

                    float tweenValue = TSSTweenBase.Evaluate(evulate, 1, profile.tweens[i].type);

                    switch (profile.tweens[i].effect)
                    {
                    case ItemEffect.transform:
                        position = Vector3.LerpUnclamped(profile.values.positions[0], profile.values.positions[1], tweenValue);
                        rotation = Quaternion.LerpUnclamped(profile.values.rotations[0], profile.values.rotations[1], tweenValue);
                        scale    = Vector3.LerpUnclamped(profile.values.scales[0], profile.values.scales[1], tweenValue);
                        break;

                    case ItemEffect.position:
                        position = Vector3.LerpUnclamped(profile.values.positions[0], profile.values.positions[1], tweenValue);
                        break;

                    case ItemEffect.rotation:
                        rotation = Quaternion.LerpUnclamped(profile.values.rotations[0], profile.values.rotations[1], tweenValue);
                        break;

                    case ItemEffect.scale:
                        scale = Vector3.LerpUnclamped(profile.values.scales[0], profile.values.scales[1], tweenValue);
                        break;

                    case ItemEffect.color:
                        material.SetColor("_Color", Color.LerpUnclamped(profile.values.colors[0], profile.values.colors[1], tweenValue));
                        break;

                    case ItemEffect.alpha:

                        material.SetColor("_Color", Color.Lerp(closedColorAlpha, openedColorAlpha, tweenValue));
                        break;
                    }
                }

                position -= profile.values.positions[0];
                if (profile.isUI)
                {
                    position *= 0.01f;
                }
                if (profile.isUI)
                {
                    previewRenderUtility.camera.orthographic = true;
                }

                Matrix4x4 matrix4X4 = Matrix4x4.TRS(position, rotation, scale);

                previewRenderUtility.DrawMesh(previewMesh, matrix4X4, material, 0);
                previewRenderUtility.camera.Render();

                Texture resultRender = previewRenderUtility.EndPreview();
                GUI.DrawTexture(r, resultRender, ScaleMode.StretchToFill, false);
            }
        }