界面
工程组件
脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
using Valve.VR;
public class UI_systerm : MonoBehaviour
{
[Space(30)]
[Header("PIC")]
public Image PIC;
public Sprite[] PICS;
public Sprite play, pause,max,min;
[Space(30)]
[Header("VID")]
public VideoPlayer VID;
public RawImage rawimage_max;
public RenderTexture vplayer;
public VideoClip[] VIDS;
public Button VID_PLAY;
public Button VID_SPEED_UP;
public Button VID_SPEED_DOWN;
public Button VID_AUDIO;
public Button VID_MAX;
public Scrollbar BAR;
public Scrollbar AUDIO_BAR;
[Space(30)]
public Button BTN_L;
public Button BTN_M;
public Button BTN_R;
public Button BTN_PIC;
public Button BTN_CLIP;
[Space(30)]
public Text TT;
public Text BEGIN_TT;
public Text END_TT;
[Space(30)]
public Toggle TG;
int i = 0;
int speed = 1;
bool isvidmax = false,ispicmax=false;
bool isplay=false;
bool isaudio = false;
double time=0f;
int total = 8;
int h, m, s,hh,mm,ss;
void Start()
{
}
void Update()
{
if (TG.isOn)
{
VID.clip = VIDS[i];
PIC.sprite = PICS[i];
timetotext();
TT.text = (VIDS[i].name.ToString());
bar_time();
Debug.Log( VID.GetDirectAudioVolume(0));
}
else
{
TT.text = ("请勾选下方内容。");
VID.Pause();
}
}
public void scroller_volume()
{
VID.SetDirectAudioVolume(0, AUDIO_BAR.value);
}
public void audioset()
{
if (isaudio == false)
{
GameObject audio_bar = GameObject.Find("Scrollbar_audio");
audio_bar.transform.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(118f,-85,0);
isaudio = true;
}
else
{
GameObject audio_bar = GameObject.Find("Scrollbar_audio");
audio_bar.transform.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(314f, -85, 0);
isaudio =false;
}
}
public void max_pic()
{
if (ispicmax == false && BTN_PIC.image.sprite == max)
{
rawimage_max.transform.position = new Vector3(0, 0, 0);
rawimage_max.texture = PIC.sprite.texture;
ispicmax = true;
BTN_PIC.image.sprite = min;
isvidmax = false;
BTN_CLIP.image.sprite = max;
}
else if (ispicmax == true && BTN_PIC.image.sprite == min)
{
rawimage_max.transform.position = new Vector3(800, 0, 0);
rawimage_max.texture = null;
ispicmax = false;
BTN_PIC.image.sprite = max;
}
}
public void max_vid()
{
if (isvidmax == false&& BTN_CLIP.image.sprite == max)
{
rawimage_max.transform.position=new Vector3(0, 0, 0);
rawimage_max.texture = vplayer;
isvidmax = true;
BTN_CLIP.image.sprite = min;
ispicmax = false;
BTN_PIC.image.sprite = max;
}
else if(isvidmax == true && BTN_CLIP.image.sprite == min)
{
rawimage_max.transform.position = new Vector3(800, 0, 0);
rawimage_max.texture = null;
isvidmax = false;
BTN_CLIP.image.sprite = max;
}
}
public void video_speedup()
{
VID.time += 5;
}
public void video_speeddown()
{
VID.time -= 5;
}
void timetotext()
{
hh= (int)VID.clip.length / 3600;
mm= (int)(VID.clip.length -hh * 3600)/ 60;
ss = (int)(VID.clip.length - hh * 3600 - mm * 60);
h =(int) VID.time / 3600;
m = (int)(VID.time - h * 3600) / 60;
s = (int)(VID.time - h *3600 - m * 60);
BEGIN_TT.text = string.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
END_TT.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hh, mm, ss);
}
void bar_time()
{
BAR.value = (float)(VID.time / VIDS[i].length);
}
public void button_play()
{
if (isplay == false)
{
isplay = true;
VID.Play();
VID_PLAY.image.sprite = play;
}
else
{
isplay = false;
VID.Pause();
VID_PLAY.image.sprite = pause;
}
}
public void ToMaxWindow(Button btn)
{
}
public void speed_up()
{
}
public void button_right()
{
if (i < total-1)
{
i += 1;
Debug.Log(i);
}
}
public void button_left()
{
if (i > 0)
{
i -= 1;
Debug.Log(i);
}
}
public void button_mid()
{
}
}