Пример #1
0
        /// <summary>
        /// Parses the JSON of the userData into VideoClipEvents
        /// </summary>
        protected static VideoClipEvents GetVideoClipEvents(string data)
        {
            VideoClipEvents clipEvents = new VideoClipEvents();

            JsonUtility.FromJsonOverwrite(data, clipEvents);
            return(clipEvents);
        }
Пример #2
0
        /// <summary>
        /// Draws the video clip in the window
        /// And draws the Play/Pause buttons, the Apply button for saving the data to the video clip metadata
        /// </summary>
        private void DrawVideoClip()
        {
            videoTexture = importer.GetPreviewTexture();
            if (videoTexture == null)
            {
                return;
            }
            Vector2 size          = new Vector2(videoTexture.width, videoTexture.height) * VIDEO_SIZE_MULTIPLIER;
            Vector2 videoPosition = new Vector2(100, 10);

            videoRect = new Rect(videoPosition, size);
            bool mustPlay = GUI.Button(playButtonRect, mustPlayPreview ? "Pause" : "Play");

            if (mustPlay)
            {
                ChangePlayState();
            }
            if (mustPlayPreview)
            {
                PlayPreview();
            }
            EditorGUI.DrawPreviewTexture(videoRect, videoTexture);

            if (GUI.Button(applyButtonRect, "Apply"))
            {
                importer.userData = VideoClipEvents.ObjectToJSON(videoClipEvents);
                videoClipImporter.ApplyModifiedPropertiesWithoutUndo();
                ReImportAssets(AssetPath);
            }
        }
Пример #3
0
 public VideoClipEvents GetClipEvents()
 {
     clipEvents = new VideoClipEvents(Count);
     foreach (EditorVideoClipEvent editorClipEvent in editorClipEvents)
     {
         clipEvents.Add(editorClipEvent.clipEvent);
     }
     return(clipEvents);
 }
Пример #4
0
 public string Assign()
 {
     clipEvents = new VideoClipEvents(Count);
     foreach (EditorVideoClipEvent editorClip in editorClipEvents)
     {
         clipEvents.Add(editorClip.clipEvent);
     }
     UserData = VideoClipEvents.ObjectToJSON(clipEvents);
     return(UserData);
 }
Пример #5
0
 public EditorVideoClipEvents(VideoClipEvents events)
 {
     clipEvents       = events;
     editorClipEvents = new List <EditorVideoClipEvent>();
     foreach (VideoClipEvent clipEvent in clipEvents)
     {
         EditorVideoClipEvent editorClipEvent = new EditorVideoClipEvent(clipEvent);
         editorClipEvents.Add(editorClipEvent);
     }
     LoadTexture();
 }
Пример #6
0
 /// <summary>
 /// Determines whether the add event UI should be drawn
 /// </summary>
 private void ChangeAddingEventState()
 {
     if (isAddingEvent)
     {
         // save the event
         if (editorVideoClipEvents == null)
         {
             editorVideoClipEvents = new EditorVideoClipEvents();
         }
         editorVideoClipEvents.Add(currentEvent);
         videoClipEvents = editorVideoClipEvents.GetClipEvents();
     }
     else
     {
         currentEvent = new EditorVideoClipEvent();
     }
     isAddingEvent = !isAddingEvent;
 }
Пример #7
0
        /// <summary>
        /// Sets the video clip to edit,
        /// Sets the importer,
        /// Caches the video clip length
        /// Caches the user data in a serialized property
        /// Initializes the editor video clip events
        /// </summary>
        private static void Initialize()
        {
            Current.wantsMouseMove = true;
            Current.editingClip    = (Selection.activeObject as VideoClip);
            if (Current.editingClip == null)
            {
                var videoPlayer = FindObjectOfType <VideoPlayer>();
                Current.editingClip = videoPlayer.clip;
                if (Current.editingClip == null)
                {
                    Debug.LogError("No clip selected");
                    return;
                }
            }
            Current.importer          = (VideoClipImporter)AssetImporter.GetAtPath(Current.editingClip.originalPath);
            Current.videoClipImporter = new SerializedObject(Current.importer);
            Current.TotalVideoTime    = Current.importer.frameCount / Current.importer.frameRate;

            string userData = Current.importer.userData;

            Current.videoClipEvents       = VideoClipEvents.JSONToObject(userData);
            Current.editorVideoClipEvents = new EditorVideoClipEvents(Current.videoClipEvents);
        }
Пример #8
0
 public EditorVideoClipEvents()
 {
     clipEvents       = new VideoClipEvents();
     editorClipEvents = new List <EditorVideoClipEvent>();
     LoadTexture();
 }
Пример #9
0
 public void GetVideoClipEvents()
 {
     clipEvents = GetVideoClipEvents(clipEventData);
 }
Пример #10
0
 /// <summary>
 /// Initialisate the lists when the window is created
 /// </summary>
 protected virtual void OnEnable()
 {
     videoClipEvents       = new VideoClipEvents();
     editorVideoClipEvents = new EditorVideoClipEvents();
 }