70 lines
2.8 KiB
C#
70 lines
2.8 KiB
C#
using CG.Framework;
|
|
using CG.UTility;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function
|
|
*******************************************************************************/
|
|
namespace ZXK.LouDiXvMuNiu
|
|
{
|
|
public class ThreeVideoChoicePrefab : UIBase
|
|
{
|
|
private Text _answerText = null;
|
|
private Transform _videoItemContainer = null;
|
|
private Button _closeBtn = null;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
_answerText = transform.Find("Mask/Connet/AnswerText").GetComponent<Text>();
|
|
_videoItemContainer = transform.Find("Mask/Connet/QuestionsConnet");
|
|
_closeBtn= transform.Find("Mask/Connet/CloseButton").GetComponent<Button>();
|
|
}
|
|
/// <summary>
|
|
/// 弹出选择题界面(奇数个选项)
|
|
/// </summary>
|
|
/// <param name="question"></param>
|
|
/// <param name="answer"></param>
|
|
/// <param name="rightNumber"></param>
|
|
/// <param name="isSelAble">选项是否可选</param>
|
|
/// <param name="configBtnEvent"></param>
|
|
public void InitQuestionPanel(string question, string[] videosPath,string[] tipMsg, int rightNumber, bool selAble, System.Action configBtnEvent)
|
|
{
|
|
question = question.Replace("\u0020", "\u00A0");
|
|
_answerText.text = question;
|
|
|
|
for (int i = 0; i < _videoItemContainer.childCount; i++)
|
|
{
|
|
if (i < videosPath.Length)
|
|
{
|
|
string _videoPath = Application.streamingAssetsPath + ConstCtrl.VIDEO_CSDY_PATH + videosPath[i] + ".mp4";
|
|
_videoItemContainer.GetChild(i).gameObject.SetActive(true);
|
|
VideoPlayer videoPlayCtrl = _videoItemContainer.GetChild(i).Find("Video Player").GetComponent<VideoPlayer>();
|
|
videoPlayCtrl.url = _videoPath;
|
|
_videoItemContainer.GetChild(i).Find("Text").GetComponent<Text>().text = tipMsg[i];
|
|
videoPlayCtrl.Play();
|
|
_videoItemContainer.GetChild(i).GetComponent<Toggle>().interactable = selAble;
|
|
}
|
|
else
|
|
{
|
|
_videoItemContainer.GetChild(i).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
_closeBtn.onClick.AddListener(() =>
|
|
{
|
|
Image rightImg = _videoItemContainer.GetChild(rightNumber).Find("answerItemRight").GetComponent<Image>();
|
|
rightImg.DOFade(1.0f, 0.3f).SetLoops(6, LoopType.Yoyo).OnComplete(() =>
|
|
{
|
|
configBtnEvent?.Invoke();
|
|
});
|
|
});
|
|
transform.SetAsLastSibling();
|
|
}
|
|
}
|
|
} |