Gets the original video clip file path as it was imported into Unity. (Read Only).
Use this property to find the original ___location of the file when you imported it into Unity. If you move the video clip file, this property’s value remains as the original ___location. The value only updates if you reimport the file.
Note: When you import your video file, if you enable Transcode in the VideoClip Import Settings, originalPath
returns the new video format instead of the original format. For example, if you do the following:
Unity imports the video file in the WebM format, and originalPath
returns .webm
instead of .mp4
. To get your original format instead, use AssetDatabase.GetAssetPath.
Additional resources: VideoClip Importer.
// The script outputs the clip’s original path to the console. // Assign this script and a VideoPlayer component to a GameObject in your Scene. // In the VideoPlayer component, assign a video clip.
using UnityEngine; using UnityEngine.Video; using UnityEditor;
public class OriginalPathExample : MonoBehaviour { void Start() { VideoPlayer videoPlayer = GetComponent<VideoPlayer>(); VideoClip videoClip = videoPlayer.clip; // Get the original video file path as it was imported into Unity. string originalPath = videoClip.originalPath; Debug.Log("Original Path: " + originalPath);
// Verify if the original file exists. if (System.IO.File.Exists(originalPath)) { Debug.Log("Original video file found at: " + originalPath); } else { Debug.Log("Original video file not found at: " + originalPath + ". Checking AssetDatabase instead."); // Check Asset database instead for the video clip. string assetPath = AssetDatabase.GetAssetPath(videoClip); if (System.IO.File.Exists(assetPath)) { Debug.Log("Original video file found at " + assetPath); } else Debug.LogWarning("Original video file not found!"); } } }