Esempio n. 1
0
    private static void ShowMediaInternal(string mediaPath, Type mediaType)
    {
        var window = (MediaPreviewWindow)ScriptableObject.CreateInstance <MediaPreviewWindow>();

        Vector2 size = Vector2.zero;

        if (mediaType == typeof(VideoClip))
        {
            window.playingClip = AssetDatabase.LoadAssetAtPath <VideoClip>(mediaPath);
            window.previewID   = MediaPreviewUtil.PlayPreview(window.playingClip);
            size = new Vector2(window.playingClip.width * videoClipSizeScale,
                               window.playingClip.height * videoClipSizeScale);
        }

        if (mediaType == typeof(Texture2D))
        {
            window.playingPic = AssetDatabase.LoadAssetAtPath <Texture2D>(mediaPath);
            size = new Vector2(window.playingPic.width * videoClipSizeScale,
                               window.playingPic.height * videoClipSizeScale);
        }

        window.maxSize      = window.minSize = size;
        window.position     = MediaPreviewUtil.GetMainWindowCenteredPosition(size);
        window.titleContent = new GUIContent("VideoWindow");
        window.ShowPopup();
        window.Focus();
        instance = window;
    }