/// <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); }
/// <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); } }
public VideoClipEvents GetClipEvents() { clipEvents = new VideoClipEvents(Count); foreach (EditorVideoClipEvent editorClipEvent in editorClipEvents) { clipEvents.Add(editorClipEvent.clipEvent); } return(clipEvents); }
public string Assign() { clipEvents = new VideoClipEvents(Count); foreach (EditorVideoClipEvent editorClip in editorClipEvents) { clipEvents.Add(editorClip.clipEvent); } UserData = VideoClipEvents.ObjectToJSON(clipEvents); return(UserData); }
public EditorVideoClipEvents(VideoClipEvents events) { clipEvents = events; editorClipEvents = new List <EditorVideoClipEvent>(); foreach (VideoClipEvent clipEvent in clipEvents) { EditorVideoClipEvent editorClipEvent = new EditorVideoClipEvent(clipEvent); editorClipEvents.Add(editorClipEvent); } LoadTexture(); }
/// <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; }
/// <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); }
public EditorVideoClipEvents() { clipEvents = new VideoClipEvents(); editorClipEvents = new List <EditorVideoClipEvent>(); LoadTexture(); }
public void GetVideoClipEvents() { clipEvents = GetVideoClipEvents(clipEventData); }
/// <summary> /// Initialisate the lists when the window is created /// </summary> protected virtual void OnEnable() { videoClipEvents = new VideoClipEvents(); editorVideoClipEvents = new EditorVideoClipEvents(); }