修改一些问题

This commit is contained in:
YangHua 2024-03-13 16:23:56 +08:00
parent 9b90252c37
commit 1f4d4a7c1a
9 changed files with 1485 additions and 348 deletions

View File

@ -1,5 +1,5 @@
#if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_5 || UNITY_5_4_OR_NEWER #if UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_5 || UNITY_5_4_OR_NEWER
#define UNITY_FEATURE_UGUI #define UNITY_FEATURE_UGUI
#endif #endif
using UnityEngine; using UnityEngine;
@ -14,367 +14,407 @@ using RenderHeads.Media.AVProVideo;
namespace RenderHeads.Media.AVProVideo.Demos namespace RenderHeads.Media.AVProVideo.Demos
{ {
/// <summary> /// <summary>
/// A demo of a simple video player using uGUI for display /// A demo of a simple video player using uGUI for display
/// Uses two MediaPlayer components, with one displaying the current video /// Uses two MediaPlayer components, with one displaying the current video
/// while the other loads the next video. MediaPlayers are then swapped /// while the other loads the next video. MediaPlayers are then swapped
/// once the video is loaded and has a frame available for display. /// once the video is loaded and has a frame available for display.
/// This gives a more seamless display than simply using a single MediaPlayer /// This gives a more seamless display than simply using a single MediaPlayer
/// as its texture will be destroyed when it loads a new video /// as its texture will be destroyed when it loads a new video
/// </summary> /// </summary>
public class VCR : MonoBehaviour public class VCR : MonoBehaviour
{ {
public MediaPlayer _mediaPlayer; public MediaPlayer _mediaPlayer;
public MediaPlayer _mediaPlayerB; public MediaPlayer _mediaPlayerB;
public DisplayUGUI _mediaDisplay; public DisplayUGUI _mediaDisplay;
public RectTransform _bufferedSliderRect; public RectTransform _bufferedSliderRect;
public Slider _videoSeekSlider; public Slider _videoSeekSlider;
private float _setVideoSeekSliderValue; private float _setVideoSeekSliderValue;
private bool _wasPlayingOnScrub; private bool _wasPlayingOnScrub;
public Slider _audioVolumeSlider; public Slider _audioVolumeSlider;
private float _setAudioVolumeSliderValue; private float _setAudioVolumeSliderValue;
public Toggle _AutoStartToggle; public Toggle _AutoStartToggle;
public Toggle _MuteToggle; public Toggle _MuteToggle;
public MediaPlayer.FileLocation _location = MediaPlayer.FileLocation.RelativeToStreamingAssetsFolder; public MediaPlayer.FileLocation _location = MediaPlayer.FileLocation.RelativeToStreamingAssetsFolder;
public string _folder = "AVProVideoDemos/"; public string _folder = "AVProVideoDemos/";
public string[] _videoFiles = { "BigBuckBunny_720p30.mp4", "SampleSphere.mp4" }; public string[] _videoFiles = { "BigBuckBunny_720p30.mp4", "SampleSphere.mp4" };
private int _VideoIndex = 0; private int _VideoIndex = 0;
private Image _bufferedSliderImage; private Image _bufferedSliderImage;
private MediaPlayer _loadingPlayer; private MediaPlayer _loadingPlayer;
public MediaPlayer PlayingPlayer
{
get
{
if (LoadingPlayer == _mediaPlayer)
{
return _mediaPlayerB;
}
return _mediaPlayer;
}
}
public MediaPlayer LoadingPlayer
{
get
{
return _loadingPlayer;
}
}
private void SwapPlayers() public MediaPlayer PlayingPlayer
{ {
// Pause the previously playing video get
PlayingPlayer.Control.Pause(); {
if (LoadingPlayer == _mediaPlayer)
{
return _mediaPlayerB;
}
return _mediaPlayer;
}
}
// Swap the videos public MediaPlayer LoadingPlayer
if (LoadingPlayer == _mediaPlayer) {
{ get
_loadingPlayer = _mediaPlayerB; {
} return _loadingPlayer;
else }
{ }
_loadingPlayer = _mediaPlayer;
}
// Change the displaying video private void SwapPlayers()
_mediaDisplay.CurrentMediaPlayer = PlayingPlayer; {
} // Pause the previously playing video
PlayingPlayer.Control.Pause();
public void OnOpenVideoFile() // Swap the videos
{ if (LoadingPlayer == _mediaPlayer)
LoadingPlayer.m_VideoPath = System.IO.Path.Combine(_folder, _videoFiles[_VideoIndex]); {
_VideoIndex = (_VideoIndex + 1) % (_videoFiles.Length); _loadingPlayer = _mediaPlayerB;
if (string.IsNullOrEmpty(LoadingPlayer.m_VideoPath)) }
{ else
LoadingPlayer.CloseVideo(); {
_VideoIndex = 0; _loadingPlayer = _mediaPlayer;
} }
else
{
LoadingPlayer.OpenVideoFromFile(_location, LoadingPlayer.m_VideoPath, _AutoStartToggle.isOn);
// SetButtonEnabled( "PlayButton", !_mediaPlayer.m_AutoStart );
// SetButtonEnabled( "PauseButton", _mediaPlayer.m_AutoStart );
}
if (_bufferedSliderRect != null) // Change the displaying video
{ _mediaDisplay.CurrentMediaPlayer = PlayingPlayer;
_bufferedSliderImage = _bufferedSliderRect.GetComponent<Image>(); }
}
}
public void OnAutoStartChange() public void OnOpenVideoFile()
{ {
if(PlayingPlayer && Debug.Log(System.IO.Path.Combine(_folder, _videoFiles[_VideoIndex]));
_AutoStartToggle && _AutoStartToggle.enabled && LoadingPlayer.m_VideoPath = System.IO.Path.Combine(_folder, _videoFiles[_VideoIndex]);
PlayingPlayer.m_AutoStart != _AutoStartToggle.isOn ) _VideoIndex = (_VideoIndex + 1) % (_videoFiles.Length);
{ if (string.IsNullOrEmpty(LoadingPlayer.m_VideoPath))
PlayingPlayer.m_AutoStart = _AutoStartToggle.isOn; {
} LoadingPlayer.CloseVideo();
if (LoadingPlayer && _VideoIndex = 0;
_AutoStartToggle && _AutoStartToggle.enabled && }
LoadingPlayer.m_AutoStart != _AutoStartToggle.isOn) else
{ {
LoadingPlayer.m_AutoStart = _AutoStartToggle.isOn; LoadingPlayer.OpenVideoFromFile(_location, LoadingPlayer.m_VideoPath, _AutoStartToggle.isOn);
} // SetButtonEnabled( "PlayButton", !_mediaPlayer.m_AutoStart );
} // SetButtonEnabled( "PauseButton", _mediaPlayer.m_AutoStart );
}
public void OnMuteChange() if (_bufferedSliderRect != null)
{ {
if (PlayingPlayer) _bufferedSliderImage = _bufferedSliderRect.GetComponent<Image>();
{ }
PlayingPlayer.Control.MuteAudio(_MuteToggle.isOn); }
}
if (LoadingPlayer)
{
LoadingPlayer.Control.MuteAudio(_MuteToggle.isOn);
}
}
public void OnPlayButton() public void OnAutoStartChange()
{ {
if(PlayingPlayer) if (PlayingPlayer &&
{ _AutoStartToggle && _AutoStartToggle.enabled &&
PlayingPlayer.Control.Play(); PlayingPlayer.m_AutoStart != _AutoStartToggle.isOn)
// SetButtonEnabled( "PlayButton", false ); {
// SetButtonEnabled( "PauseButton", true ); PlayingPlayer.m_AutoStart = _AutoStartToggle.isOn;
} }
} if (LoadingPlayer &&
public void OnPauseButton() _AutoStartToggle && _AutoStartToggle.enabled &&
{ LoadingPlayer.m_AutoStart != _AutoStartToggle.isOn)
if(PlayingPlayer) {
{ LoadingPlayer.m_AutoStart = _AutoStartToggle.isOn;
PlayingPlayer.Control.Pause(); }
// SetButtonEnabled( "PauseButton", false ); }
// SetButtonEnabled( "PlayButton", true );
}
}
public void OnVideoSeekSlider() public void OnMuteChange()
{ {
if (PlayingPlayer && _videoSeekSlider && _videoSeekSlider.value != _setVideoSeekSliderValue) if (PlayingPlayer)
{ {
PlayingPlayer.Control.Seek(_videoSeekSlider.value * PlayingPlayer.Info.GetDurationMs()); PlayingPlayer.Control.MuteAudio(_MuteToggle.isOn);
} }
} if (LoadingPlayer)
{
LoadingPlayer.Control.MuteAudio(_MuteToggle.isOn);
}
}
public void OnVideoSliderDown() public void OnPlayButton()
{ {
if(PlayingPlayer) if (PlayingPlayer)
{ {
_wasPlayingOnScrub = PlayingPlayer.Control.IsPlaying(); PlayingPlayer.Control.Play();
if( _wasPlayingOnScrub ) // SetButtonEnabled( "PlayButton", false );
{ // SetButtonEnabled( "PauseButton", true );
PlayingPlayer.Control.Pause(); }
// SetButtonEnabled( "PauseButton", false ); }
// SetButtonEnabled( "PlayButton", true ); public void OnPauseButton()
} {
OnVideoSeekSlider(); if (PlayingPlayer)
} {
} PlayingPlayer.Control.Pause();
public void OnVideoSliderUp() // SetButtonEnabled( "PauseButton", false );
{ // SetButtonEnabled( "PlayButton", true );
if(PlayingPlayer && _wasPlayingOnScrub ) }
{ }
PlayingPlayer.Control.Play();
_wasPlayingOnScrub = false;
// SetButtonEnabled( "PlayButton", false ); public void OnVideoSeekSlider()
// SetButtonEnabled( "PauseButton", true ); {
} if (PlayingPlayer && _videoSeekSlider && _videoSeekSlider.value != _setVideoSeekSliderValue)
} {
PlayingPlayer.Control.Seek(_videoSeekSlider.value * PlayingPlayer.Info.GetDurationMs());
}
}
public void OnAudioVolumeSlider() public void OnVideoSliderDown()
{ {
if (PlayingPlayer && _audioVolumeSlider && _audioVolumeSlider.value != _setAudioVolumeSliderValue) if (PlayingPlayer)
{ {
PlayingPlayer.Control.SetVolume(_audioVolumeSlider.value); _wasPlayingOnScrub = PlayingPlayer.Control.IsPlaying();
} if (_wasPlayingOnScrub)
if (LoadingPlayer && _audioVolumeSlider && _audioVolumeSlider.value != _setAudioVolumeSliderValue) {
{ PlayingPlayer.Control.Pause();
LoadingPlayer.Control.SetVolume(_audioVolumeSlider.value); // SetButtonEnabled( "PauseButton", false );
} // SetButtonEnabled( "PlayButton", true );
} }
// public void OnMuteAudioButton() OnVideoSeekSlider();
// { }
// if( _mediaPlayer ) }
// { public void OnVideoSliderUp()
// _mediaPlayer.Control.MuteAudio( true ); {
// SetButtonEnabled( "MuteButton", false ); if (PlayingPlayer && _wasPlayingOnScrub)
// SetButtonEnabled( "UnmuteButton", true ); {
// } PlayingPlayer.Control.Play();
// } _wasPlayingOnScrub = false;
// public void OnUnmuteAudioButton()
// {
// if( _mediaPlayer )
// {
// _mediaPlayer.Control.MuteAudio( false );
// SetButtonEnabled( "UnmuteButton", false );
// SetButtonEnabled( "MuteButton", true );
// }
// }
public void OnRewindButton() // SetButtonEnabled( "PlayButton", false );
{ // SetButtonEnabled( "PauseButton", true );
if(PlayingPlayer) }
{ }
PlayingPlayer.Control.Rewind();
}
}
private void Awake() public void OnAudioVolumeSlider()
{ {
_loadingPlayer = _mediaPlayerB; if (PlayingPlayer && _audioVolumeSlider && _audioVolumeSlider.value != _setAudioVolumeSliderValue)
} {
PlayingPlayer.Control.SetVolume(_audioVolumeSlider.value);
}
if (LoadingPlayer && _audioVolumeSlider && _audioVolumeSlider.value != _setAudioVolumeSliderValue)
{
LoadingPlayer.Control.SetVolume(_audioVolumeSlider.value);
}
}
// public void OnMuteAudioButton()
// {
// if( _mediaPlayer )
// {
// _mediaPlayer.Control.MuteAudio( true );
// SetButtonEnabled( "MuteButton", false );
// SetButtonEnabled( "UnmuteButton", true );
// }
// }
// public void OnUnmuteAudioButton()
// {
// if( _mediaPlayer )
// {
// _mediaPlayer.Control.MuteAudio( false );
// SetButtonEnabled( "UnmuteButton", false );
// SetButtonEnabled( "MuteButton", true );
// }
// }
void Start() public void OnRewindButton()
{ {
if(PlayingPlayer) if (PlayingPlayer)
{ {
PlayingPlayer.Events.AddListener(OnVideoEvent); PlayingPlayer.Control.Rewind();
}
}
if (LoadingPlayer)
{
LoadingPlayer.Events.AddListener(OnVideoEvent);
}
if ( _audioVolumeSlider ) public Button multiplyPlaybackBtn;
{ public Button[] multiplyButtons;
// Volume public GameObject multiplyTogglesParents;
if (PlayingPlayer.Control != null) public bool isMultiplyOn = false;
{
float volume = PlayingPlayer.Control.GetVolume();
_setAudioVolumeSliderValue = volume;
_audioVolumeSlider.value = volume;
}
}
// Auto start toggle public void ResetPlayState()
_AutoStartToggle.isOn = PlayingPlayer.m_AutoStart; {
isMultiplyOn = false;
multiplyTogglesParents.SetActive(false);
multiplyPlaybackBtn.transform.GetChild(0).GetComponent<Text>().text = "×1";
}
/// <summary>
/// 倍数播放
/// </summary>
if(PlayingPlayer.m_AutoOpen ) private void Awake()
{ {
// RemoveOpenVideoButton(); _loadingPlayer = _mediaPlayerB;
}
// SetButtonEnabled( "PlayButton", !_mediaPlayer.m_AutoStart ); void Start()
// SetButtonEnabled( "PauseButton", _mediaPlayer.m_AutoStart ); {
} multiplyPlaybackBtn.onClick.AddListener(() =>
else {
{ isMultiplyOn = !isMultiplyOn;
// SetButtonEnabled( "PlayButton", false ); multiplyTogglesParents.SetActive(isMultiplyOn);
// SetButtonEnabled( "PauseButton", false ); });
}
// SetButtonEnabled( "MuteButton", !_mediaPlayer.m_Muted ); for (int i = 0; i < multiplyButtons.Length; i++)
// SetButtonEnabled( "UnmuteButton", _mediaPlayer.m_Muted ); {
int index = i;
multiplyButtons[index].onClick.AddListener(() =>
{
multiplyPlaybackBtn.transform.GetChild(0).GetComponent<Text>().text = "×" + multiplyButtons[index].name;
float temp = float.Parse(multiplyButtons[index].name);
if (PlayingPlayer)
PlayingPlayer.Control.SetPlaybackRate(temp);
isMultiplyOn = false;
multiplyTogglesParents.SetActive(false);
});
OnOpenVideoFile(); }
} ResetPlayState();
} if (PlayingPlayer)
{
PlayingPlayer.Events.AddListener(OnVideoEvent);
void Update() if (LoadingPlayer)
{ {
if (PlayingPlayer && PlayingPlayer.Info != null && PlayingPlayer.Info.GetDurationMs() > 0f) LoadingPlayer.Events.AddListener(OnVideoEvent);
{ }
float time = PlayingPlayer.Control.GetCurrentTimeMs();
float duration = PlayingPlayer.Info.GetDurationMs();
float d = Mathf.Clamp(time / duration, 0.0f, 1.0f);
// Debug.Log(string.Format("time: {0}, duration: {1}, d: {2}", time, duration, d)); if (_audioVolumeSlider)
{
// Volume
if (PlayingPlayer.Control != null)
{
float volume = PlayingPlayer.Control.GetVolume();
_setAudioVolumeSliderValue = volume;
_audioVolumeSlider.value = volume;
}
}
_setVideoSeekSliderValue = d; // Auto start toggle
_videoSeekSlider.value = d; _AutoStartToggle.isOn = PlayingPlayer.m_AutoStart;
if (_bufferedSliderRect != null) if (PlayingPlayer.m_AutoOpen)
{ {
float t1 = 0f; // RemoveOpenVideoButton();
float t2 = PlayingPlayer.Control.GetBufferingProgress();
if (t2 <= 0f)
{
if (PlayingPlayer.Control.GetBufferedTimeRangeCount() > 0)
{
PlayingPlayer.Control.GetBufferedTimeRange(0, ref t1, ref t2);
t1 /= PlayingPlayer.Info.GetDurationMs();
t2 /= PlayingPlayer.Info.GetDurationMs();
}
}
Vector2 anchorMin = Vector2.zero; // SetButtonEnabled( "PlayButton", !_mediaPlayer.m_AutoStart );
Vector2 anchorMax = Vector2.one; // SetButtonEnabled( "PauseButton", _mediaPlayer.m_AutoStart );
}
if (_bufferedSliderImage != null && else
_bufferedSliderImage.type == Image.Type.Filled) {
{ // SetButtonEnabled( "PlayButton", false );
_bufferedSliderImage.fillAmount = d; // SetButtonEnabled( "PauseButton", false );
} }
else
{
anchorMin[0] = t1;
anchorMax[0] = t2;
}
_bufferedSliderRect.anchorMin = anchorMin;
_bufferedSliderRect.anchorMax = anchorMax;
}
}
}
// Callback function to handle events // SetButtonEnabled( "MuteButton", !_mediaPlayer.m_Muted );
public void OnVideoEvent(MediaPlayer mp, MediaPlayerEvent.EventType et, ErrorCode errorCode) // SetButtonEnabled( "UnmuteButton", _mediaPlayer.m_Muted );
{
switch (et)
{
case MediaPlayerEvent.EventType.ReadyToPlay:
break;
case MediaPlayerEvent.EventType.Started:
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
SwapPlayers();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
break;
}
Debug.Log("Event: " + et.ToString()); OnOpenVideoFile();
} }
}
// private void SetButtonEnabled( string objectName, bool bEnabled ) void Update()
// { {
// Button button = GameObject.Find( objectName ).GetComponent<Button>(); if (PlayingPlayer && PlayingPlayer.Info != null && PlayingPlayer.Info.GetDurationMs() > 0f)
// if( button ) {
// { float time = PlayingPlayer.Control.GetCurrentTimeMs();
// button.enabled = bEnabled; float duration = PlayingPlayer.Info.GetDurationMs();
// button.GetComponentInChildren<CanvasRenderer>().SetAlpha( bEnabled ? 1.0f : 0.4f ); float d = Mathf.Clamp(time / duration, 0.0f, 1.0f);
// button.GetComponentInChildren<Text>().color = Color.clear;
// }
// }
// private void RemoveOpenVideoButton() // Debug.Log(string.Format("time: {0}, duration: {1}, d: {2}", time, duration, d));
// {
// Button openVideoButton = GameObject.Find( "OpenVideoButton" ).GetComponent<Button>(); _setVideoSeekSliderValue = d;
// if( openVideoButton ) _videoSeekSlider.value = d;
// {
// openVideoButton.enabled = false; if (_bufferedSliderRect != null)
// openVideoButton.GetComponentInChildren<CanvasRenderer>().SetAlpha( 0.0f ); {
// openVideoButton.GetComponentInChildren<Text>().color = Color.clear; float t1 = 0f;
// } float t2 = PlayingPlayer.Control.GetBufferingProgress();
// if (t2 <= 0f)
// if( _AutoStartToggle ) {
// { if (PlayingPlayer.Control.GetBufferedTimeRangeCount() > 0)
// _AutoStartToggle.enabled = false; {
// _AutoStartToggle.isOn = false; PlayingPlayer.Control.GetBufferedTimeRange(0, ref t1, ref t2);
// _AutoStartToggle.GetComponentInChildren<CanvasRenderer>().SetAlpha( 0.0f ); t1 /= PlayingPlayer.Info.GetDurationMs();
// _AutoStartToggle.GetComponentInChildren<Text>().color = Color.clear; t2 /= PlayingPlayer.Info.GetDurationMs();
// _AutoStartToggle.GetComponentInChildren<Image>().enabled = false; }
// _AutoStartToggle.GetComponentInChildren<Image>().color = Color.clear; }
// }
// } Vector2 anchorMin = Vector2.zero;
} Vector2 anchorMax = Vector2.one;
if (_bufferedSliderImage != null &&
_bufferedSliderImage.type == Image.Type.Filled)
{
_bufferedSliderImage.fillAmount = d;
}
else
{
anchorMin[0] = t1;
anchorMax[0] = t2;
}
_bufferedSliderRect.anchorMin = anchorMin;
_bufferedSliderRect.anchorMax = anchorMax;
}
}
}
// Callback function to handle events
public void OnVideoEvent(MediaPlayer mp, MediaPlayerEvent.EventType et, ErrorCode errorCode)
{
switch (et)
{
case MediaPlayerEvent.EventType.ReadyToPlay:
break;
case MediaPlayerEvent.EventType.Started:
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
SwapPlayers();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
break;
}
Debug.Log("Event: " + et.ToString());
}
// private void SetButtonEnabled( string objectName, bool bEnabled )
// {
// Button button = GameObject.Find( objectName ).GetComponent<Button>();
// if( button )
// {
// button.enabled = bEnabled;
// button.GetComponentInChildren<CanvasRenderer>().SetAlpha( bEnabled ? 1.0f : 0.4f );
// button.GetComponentInChildren<Text>().color = Color.clear;
// }
// }
// private void RemoveOpenVideoButton()
// {
// Button openVideoButton = GameObject.Find( "OpenVideoButton" ).GetComponent<Button>();
// if( openVideoButton )
// {
// openVideoButton.enabled = false;
// openVideoButton.GetComponentInChildren<CanvasRenderer>().SetAlpha( 0.0f );
// openVideoButton.GetComponentInChildren<Text>().color = Color.clear;
// }
//
// if( _AutoStartToggle )
// {
// _AutoStartToggle.enabled = false;
// _AutoStartToggle.isOn = false;
// _AutoStartToggle.GetComponentInChildren<CanvasRenderer>().SetAlpha( 0.0f );
// _AutoStartToggle.GetComponentInChildren<Text>().color = Color.clear;
// _AutoStartToggle.GetComponentInChildren<Image>().enabled = false;
// _AutoStartToggle.GetComponentInChildren<Image>().color = Color.clear;
// }
// }
}
} }
#endif #endif

View File

@ -79,7 +79,7 @@ TextMesh:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 114525537} m_GameObject: {fileID: 114525537}
m_Text: m_Text: "\u7535\u5B50\u4FA6\u5BDF\u65E0\u4EBA\u673A"
m_OffsetZ: 0 m_OffsetZ: 0
m_CharacterSize: 1 m_CharacterSize: 1
m_LineSpacing: 1 m_LineSpacing: 1
@ -142,7 +142,7 @@ MonoBehaviour:
isEnableVertical: 1 isEnableVertical: 1
isEnableLerp: 0 isEnableLerp: 0
lerpTime: 1 lerpTime: 1
_distance: 10 _distance: 6
--- !u!1 &1868832759 --- !u!1 &1868832759
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -768,6 +768,11 @@ MonoBehaviour:
SurveillanceFrequencyBand: {fileID: 6513129680526216908} SurveillanceFrequencyBand: {fileID: 6513129680526216908}
gamePos: {fileID: 392167392884716949} gamePos: {fileID: 392167392884716949}
gamemap: {fileID: 6311100753636855780} gamemap: {fileID: 6311100753636855780}
reveal: 0
Ground:
serializedVersion: 2
m_Bits: 0
boisp: 1
attackColliders1: [] attackColliders1: []
currentCollider: {fileID: 0} currentCollider: {fileID: 0}
layerMask: layerMask:

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ public class Main_interface_Panel : XUIPanel
public Button train; public Button train;
public Button replay; public Button replay;
public Button appQuet; public Button appQuet;
public Text accountName;
public Main_interface_Panel() : base(UIType.Fixed, UIMode.None, UICollider.None) public Main_interface_Panel() : base(UIType.Fixed, UIMode.None, UICollider.None)
{ {
uiPath = "UIPanel/Main_interface_Panel"; uiPath = "UIPanel/Main_interface_Panel";
@ -34,6 +35,8 @@ public class Main_interface_Panel : XUIPanel
appQuet.onClick.AddListener(() => { Application.Quit(); appQuet.onClick.AddListener(() => { Application.Quit();
//Debug.Log("退出"); //Debug.Log("退出");
}); });
accountName = this.transform.Find("UPBG/avatar_btn/Text").GetComponent<Text>();
accountName.text = GlobalFlag.currentUser.login_name;
} }
/// <summary> /// <summary>

View File

@ -369,10 +369,10 @@ public class Scenariopage : MonoBehaviour
caodi = GameObject.Find("Background"); caodi = GameObject.Find("Background");
//调用接口 //调用接口
Debug.Log("Url_Action..:" + Url_Action); //Debug.Log("Url_Action..:" + Url_Action);
StartCoroutine(Post1(Url_Action, (bol, str) => StartCoroutine(Post1(Url_Action, (bol, str) =>
{ {
Debug.Log(str); //Debug.Log(str);
Scenario(bol, str); Scenario(bol, str);
})); }));
Scenario();//想定文件 Scenario();//想定文件
@ -382,7 +382,8 @@ public class Scenariopage : MonoBehaviour
send_back_btn.onClick.AddListener(() => send_back_btn.onClick.AddListener(() =>
{ {
GameMain.tiao = false; GameMain.tiao = false;
SceneManager.LoadScene("SampleScene"); SceneLoad.Instance.SceneChange("SampleScene");
//SceneManager.LoadScene("SampleScene");
}); });
//SetLightValue(1f); //SetLightValue(1f);
queding.onClick.AddListener(() => queding.onClick.AddListener(() =>
@ -1558,7 +1559,7 @@ public class Scenariopage : MonoBehaviour
{ {
if (bol) if (bol)
{ {
Debug.LogError(str); //Debug.LogError(str);
scen = JsonMapper.ToObject<Editinformation>(str);//解析最外层的想定名称json文件 scen = JsonMapper.ToObject<Editinformation>(str);//解析最外层的想定名称json文件
for (int i = 0; i < scen.data.Count; i++) for (int i = 0; i < scen.data.Count; i++)
{ {

View File

@ -38,9 +38,10 @@ public class Taskpanel : MonoBehaviour
public Button fanhuiBtn; public Button fanhuiBtn;
public Button fanhui; public Button fanhui;
private bool isp = true; private bool isp = true;
void Start() void Start()
{ {
this.transform.Find("UPBG/avatar_botn/Text").GetComponent<Text>().text = GlobalFlag.currentUser.login_name;
fanhui.onClick.AddListener(() => fanhui.onClick.AddListener(() =>
{ {
GameMain.tiao = false; GameMain.tiao = false;

View File

@ -49,7 +49,6 @@ public class View_Panel2 : XUIPanel
public List<string> rootlist = new List<string>();//存入房间的名字 public List<string> rootlist = new List<string>();//存入房间的名字
public List<Button> buttonlist = new List<Button>();//克隆出来房间按钮 public List<Button> buttonlist = new List<Button>();//克隆出来房间按钮
//public string roomUrl = Url_RoomList; //public string roomUrl = Url_RoomList;
//public string userUrl = Url_StudentList; //public string userUrl = Url_StudentList;
public RoomData roomdata = new RoomData(); public RoomData roomdata = new RoomData();
@ -212,7 +211,7 @@ public class View_Panel2 : XUIPanel
{ {
Debug.Log("onEndEdit" + info); Debug.Log("onEndEdit" + info);
}); });
Forkoffbtn(); Forkoffbtn();
Verify(); Verify();
Submit(); Submit();
@ -365,11 +364,11 @@ public class View_Panel2 : XUIPanel
/// <summary> /// <summary>
/// 取消分配 /// 取消分配
/// </summary> /// </summary>
public void DeleteAssignedAccount(string subjectID,string seatID) public void DeleteAssignedAccount(string subjectID, string seatID)
{ {
for (int i = 0; i < currentEditorAccounts.Count; i++) for (int i = 0; i < currentEditorAccounts.Count; i++)
{ {
if(currentEditorAccounts[i].subjectID.Equals(subjectID)&& currentEditorAccounts[i].SeatID.Equals(seatID)) if (currentEditorAccounts[i].subjectID.Equals(subjectID) && currentEditorAccounts[i].SeatID.Equals(seatID))
{ {
currentEditorAccounts.Remove(currentEditorAccounts[i]); currentEditorAccounts.Remove(currentEditorAccounts[i]);
} }
@ -555,7 +554,8 @@ public class View_Panel2 : XUIPanel
///想定编辑 ///想定编辑
scenario_btn.onClick.AddListener(() => scenario_btn.onClick.AddListener(() =>
{ {
SceneManager.LoadScene("Contingenc_yediting_panl"); SceneLoad.Instance.SceneChange("Contingenc_yediting_panl");
//SceneManager.LoadScene("Contingenc_yediting_panl");
}); });
} }
@ -846,7 +846,7 @@ public class View_Panel2 : XUIPanel
append_room_panl.gameObject.SetActive(false); append_room_panl.gameObject.SetActive(false);
distribution_panl.gameObject.SetActive(false); distribution_panl.gameObject.SetActive(false);
selector_panl.gameObject.SetActive(false); selector_panl.gameObject.SetActive(false);
string accountInfo = AccountsInfo(); string accountInfo = AccountsInfo();
ReturnRoomID returnRoomId = await AsyncWebReq.Post<ReturnRoomID>(Url_GetRoomID + currentRoomName + "&MissionModel=" + currentMissionModel + "&ThinkingId=" + currentThinkingId + "&AccountsInfo=" + accountInfo, null); ReturnRoomID returnRoomId = await AsyncWebReq.Post<ReturnRoomID>(Url_GetRoomID + currentRoomName + "&MissionModel=" + currentMissionModel + "&ThinkingId=" + currentThinkingId + "&AccountsInfo=" + accountInfo, null);
if (returnRoomId.state) if (returnRoomId.state)
@ -860,6 +860,7 @@ public class View_Panel2 : XUIPanel
CreateRoomBase(returnRoomId.data, currentRoomName); CreateRoomBase(returnRoomId.data, currentRoomName);
refresh_btn.onClick?.Invoke(); refresh_btn.onClick?.Invoke();
} }
currentEditorAccounts.Clear();
string RoomName = "createroom " + returnRoomId.data; string RoomName = "createroom " + returnRoomId.data;
_ = AdamSync.SyncCreateRoom.SendMessageAsync(RoomName); _ = AdamSync.SyncCreateRoom.SendMessageAsync(RoomName);
} }

View File

@ -46,8 +46,8 @@ public class Face2Camera : MonoBehaviour
float distance = Vector3.Distance(Camera.main.transform.position, transform.position);//不断变化的距离 float distance = Vector3.Distance(Camera.main.transform.position, transform.position);//不断变化的距离
float scale = distance / _distance; float scale = distance / _distance;
if (scale > 10f) if (scale > 3f)
scale = 10f; scale = 3f;
transform.localScale = initScale * scale; transform.localScale = initScale * scale;
} }