Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Video;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace AC
- {
- [System.Serializable]
- public class ActionVideoPlayerSetClip : Action
- {
- public VideoPlayer videoPlayer;
- public VideoClip videoClip;
- public bool playClip;
- public int constantID;
- public ActionVideoPlayerSetClip()
- {
- this.isDisplayed = true;
- category = ActionCategory.Custom;
- title = "VideoPlayer SetClip";
- description = "This will set the clip on a Video Player component and optionally play it immediately.";
- }
- override public float Run ()
- {
- videoPlayer.clip = videoClip;
- if (playClip) {
- videoPlayer.Play();
- }
- return 0f;
- }
- #if UNITY_EDITOR
- override public void ShowGUI ()
- {
- videoPlayer = (VideoPlayer)EditorGUILayout.ObjectField("VideoPlayer Component:", videoPlayer, typeof(VideoPlayer), true);
- if (videoPlayer) {
- constantID = FieldToID(videoPlayer, constantID);
- videoPlayer = IDToField(videoPlayer, constantID, true);
- }
- videoClip = (VideoClip)EditorGUILayout.ObjectField("Video Clip:", videoClip, typeof(VideoClip), true);
- playClip = EditorGUILayout.Toggle("Play Clip Automatically:", playClip);
- AfterRunningOption ();
- }
- public override string SetLabel ()
- {
- string labelAdd = " to " + videoClip.name;
- if (playClip) {
- labelAdd += " and Play";
- }
- return labelAdd;
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement