Compare commits
2 Commits
91c84e5df8
...
ca8a3ff2a1
Author | SHA1 | Date |
---|---|---|
|
ca8a3ff2a1 | |
|
178d93b78c |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9ed5fdf790e8fd549b3b89325cb36e81
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,145 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace ZC
|
||||||
|
{
|
||||||
|
[UIType(UIType.AnswerUI)]
|
||||||
|
public class AnswerUI : UIBase
|
||||||
|
{
|
||||||
|
private TMP_Text txt_Title;
|
||||||
|
private TMP_Text txt_TrueOption;
|
||||||
|
private TMP_Text txt_JXContent;
|
||||||
|
private TMP_Text txt_Label0;
|
||||||
|
private TMP_Text txt_Label1;
|
||||||
|
private TMP_Text txt_Label2;
|
||||||
|
private TMP_Text txt_Label3;
|
||||||
|
private Toggle tog_Option0;
|
||||||
|
private Toggle tog_Option1;
|
||||||
|
private Toggle tog_Option2;
|
||||||
|
private Toggle tog_Option3;
|
||||||
|
private Button btn_Last;
|
||||||
|
private Button btn_Close;
|
||||||
|
private Button btn_Next;
|
||||||
|
|
||||||
|
private QuestionBankData _bankData;
|
||||||
|
|
||||||
|
private int currentIndex = 0;
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
base.Init();
|
||||||
|
txt_Title = _uiGameObjectBinding.GetValue("txt_Title").GetComponent<TMP_Text>();
|
||||||
|
txt_TrueOption = _uiGameObjectBinding.GetValue("txt_TrueOption").GetComponent<TMP_Text>();
|
||||||
|
txt_JXContent = _uiGameObjectBinding.GetValue("txt_JXContent").GetComponent<TMP_Text>();
|
||||||
|
txt_Label0 = _uiGameObjectBinding.GetValue("txt_Label0").GetComponent<TMP_Text>();
|
||||||
|
txt_Label1 = _uiGameObjectBinding.GetValue("txt_Label1").GetComponent<TMP_Text>();
|
||||||
|
txt_Label2 = _uiGameObjectBinding.GetValue("txt_Label2").GetComponent<TMP_Text>();
|
||||||
|
txt_Label3 = _uiGameObjectBinding.GetValue("txt_Label3").GetComponent<TMP_Text>();
|
||||||
|
tog_Option0 = _uiGameObjectBinding.GetValue("tog_Option0").GetComponent<Toggle>();
|
||||||
|
tog_Option1 = _uiGameObjectBinding.GetValue("tog_Option1").GetComponent<Toggle>();
|
||||||
|
tog_Option2 = _uiGameObjectBinding.GetValue("tog_Option2").GetComponent<Toggle>();
|
||||||
|
tog_Option3 = _uiGameObjectBinding.GetValue("tog_Option3").GetComponent<Toggle>();
|
||||||
|
btn_Last = _uiGameObjectBinding.GetValue("btn_Last").GetComponent<Button>();
|
||||||
|
btn_Close = _uiGameObjectBinding.GetValue("btn_Close").GetComponent<Button>();
|
||||||
|
btn_Next = _uiGameObjectBinding.GetValue("btn_Next").GetComponent<Button>();
|
||||||
|
|
||||||
|
btn_Last.onClick.AddListener(ClickLastButton);
|
||||||
|
btn_Close.onClick.AddListener(ClickCloseButton);
|
||||||
|
btn_Next.onClick.AddListener(ClickNextButton);
|
||||||
|
|
||||||
|
// 读取题库
|
||||||
|
_bankData = new QuestionBankData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
btn_Last.onClick.RemoveListener(ClickLastButton);
|
||||||
|
btn_Close.onClick.RemoveListener(ClickCloseButton);
|
||||||
|
btn_Next.onClick.RemoveListener(ClickNextButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickNextButton()
|
||||||
|
{
|
||||||
|
currentIndex++;
|
||||||
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickCloseButton()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickLastButton()
|
||||||
|
{
|
||||||
|
currentIndex--;
|
||||||
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetQuestionBankData(QuestionBankData bankData)
|
||||||
|
{
|
||||||
|
this._bankData = bankData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitAnswer()
|
||||||
|
{
|
||||||
|
currentIndex = 0;
|
||||||
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetUIContent(AnswerData data)
|
||||||
|
{
|
||||||
|
currentIndex = data.index;
|
||||||
|
txt_Title.text = data.title;
|
||||||
|
txt_Label0.text = data.options[0].content;
|
||||||
|
txt_Label1.text = data.options[1].content;
|
||||||
|
txt_Label2.text = data.options[2].content;
|
||||||
|
txt_Label3.text = data.options[3].content;
|
||||||
|
txt_TrueOption.text = data.trueOption;
|
||||||
|
txt_JXContent.text = data.analyze;
|
||||||
|
|
||||||
|
tog_Option0.isOn = false;
|
||||||
|
tog_Option1.isOn = false;
|
||||||
|
tog_Option2.isOn = false;
|
||||||
|
tog_Option3.isOn = false;
|
||||||
|
|
||||||
|
if (currentIndex >= _bankData.AnswerDatas.Count - 1) // 最后一题
|
||||||
|
{
|
||||||
|
btn_Next.gameObject.SetActive(false);
|
||||||
|
// 提交按钮显示
|
||||||
|
}
|
||||||
|
else if (currentIndex <= 0) // 第一题
|
||||||
|
{
|
||||||
|
btn_Last.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btn_Last.gameObject.SetActive(true);
|
||||||
|
btn_Next.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QuestionBankData
|
||||||
|
{
|
||||||
|
public List<AnswerData> AnswerDatas = new List<AnswerData>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AnswerData
|
||||||
|
{
|
||||||
|
public int index;
|
||||||
|
public string title;
|
||||||
|
public List<OptionData> options = new List<OptionData>();
|
||||||
|
public string trueOption;
|
||||||
|
public string analyze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OptionData
|
||||||
|
{
|
||||||
|
public string content;
|
||||||
|
|
||||||
|
public bool isTrue;
|
||||||
|
// public string analyze;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6671bdd083df41728c3ff3db6378756f
|
||||||
|
timeCreated: 1729952500
|
|
@ -26,10 +26,12 @@ namespace ZC
|
||||||
public bool isActive => _isActive;
|
public bool isActive => _isActive;
|
||||||
|
|
||||||
public GameObject self => _self;
|
public GameObject self => _self;
|
||||||
|
protected GameObjectBinding _uiGameObjectBinding;
|
||||||
|
|
||||||
public void SetGameObject(GameObject gameObject, bool isPause = true, bool isActive = false)
|
public void SetGameObject(GameObject gameObject, bool isPause = true, bool isActive = false)
|
||||||
{
|
{
|
||||||
this._self = gameObject;
|
this._self = gameObject;
|
||||||
|
_uiGameObjectBinding = _self.GetComponent<GameObjectBinding>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace ZC
|
||||||
|
{
|
||||||
|
public class GameObjectBinding : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private List<GameObjectBindingData> Datas = new List<GameObjectBindingData>();
|
||||||
|
|
||||||
|
public GameObject GetValue(string nameStr)
|
||||||
|
{
|
||||||
|
foreach (var data in Datas)
|
||||||
|
{
|
||||||
|
if (data.name == nameStr)
|
||||||
|
{
|
||||||
|
return data.go;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NullReferenceException($"没有找到绑定这个名字的物体,name:{nameStr}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class GameObjectBindingData
|
||||||
|
{
|
||||||
|
[HorizontalGroup("aaa")] [LabelText("k"), LabelWidth(10)]
|
||||||
|
public string name;
|
||||||
|
|
||||||
|
[HorizontalGroup("aaa")] [LabelText("v"), LabelWidth(10)] [OnValueChanged(nameof(OnValueChanged))]
|
||||||
|
public GameObject go;
|
||||||
|
|
||||||
|
private void OnValueChanged()
|
||||||
|
{
|
||||||
|
if (go != null)
|
||||||
|
name = go.name;
|
||||||
|
else
|
||||||
|
name = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 786137fdc2d9480690499e6f4964e8b2
|
||||||
|
timeCreated: 1729953001
|
|
@ -3,7 +3,8 @@
|
||||||
public enum UIType
|
public enum UIType
|
||||||
{
|
{
|
||||||
LoadingUI,
|
LoadingUI,
|
||||||
GameUI
|
GameUI,
|
||||||
|
AnswerUI,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UILayer
|
public enum UILayer
|
||||||
|
|
|
@ -16,7 +16,9 @@ namespace Unity.Loader
|
||||||
ZCGame zcGame;
|
ZCGame zcGame;
|
||||||
|
|
||||||
private float time;
|
private float time;
|
||||||
DateTime startTime;
|
private GlobalData _globalData;
|
||||||
|
|
||||||
|
public GlobalData Data => _globalData;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
@ -26,14 +28,21 @@ namespace Unity.Loader
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback);
|
this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback);
|
||||||
startTime = System.DateTime.Now;
|
|
||||||
|
_globalData = new GlobalData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
time += Time.fixedTime;
|
time += Time.fixedTime;
|
||||||
var timeSpan = System.DateTime.Now - startTime;
|
|
||||||
Debug.Log($"{timeSpan:c}");
|
// Debug.Log($"{_globalData.runTimeStr}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
_globalData.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FinishCallback()
|
private void FinishCallback()
|
||||||
|
|
|
@ -1,20 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Unity.Loader
|
namespace Unity.Loader
|
||||||
{
|
{
|
||||||
public class GlobalData
|
public class GlobalData
|
||||||
{
|
{
|
||||||
private DateTime _startTime;
|
private DateTime _startTime;
|
||||||
private DateTime _endTime;
|
|
||||||
|
|
||||||
private TimeSpan _runTime => System.DateTime.Now - _startTime;
|
private TimeSpan _runTime => System.DateTime.Now - _startTime;
|
||||||
public string runTimeStr => $"{_runTime:c}";
|
public string runTimeStr => $"{_runTime:hh\\:mm\\:ss}";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int _score;
|
private int _score;
|
||||||
public int score => _score;
|
public int score => _score;
|
||||||
|
|
||||||
|
public GlobalData()
|
||||||
|
{
|
||||||
|
_startTime = DateTime.Now;
|
||||||
|
_score = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Debug.Log($"程序运行时长:{runTimeStr}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,6 @@ RenderSettings:
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 0}
|
||||||
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
|
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
|
@ -1032,7 +1031,7 @@ RectTransform:
|
||||||
m_Father: {fileID: 1770513432}
|
m_Father: {fileID: 1770513432}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 114.3303, y: 0}
|
m_SizeDelta: {x: 114.3303, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
@ -1093,7 +1092,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &767437781
|
--- !u!224 &767437781
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2770,7 +2769,7 @@ RectTransform:
|
||||||
m_Father: {fileID: 1923750501}
|
m_Father: {fileID: 1923750501}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 10, y: 0}
|
m_SizeDelta: {x: 10, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
@ -3780,7 +3779,7 @@ MonoBehaviour:
|
||||||
m_UiScaleMode: 1
|
m_UiScaleMode: 1
|
||||||
m_ReferencePixelsPerUnit: 100
|
m_ReferencePixelsPerUnit: 100
|
||||||
m_ScaleFactor: 1
|
m_ScaleFactor: 1
|
||||||
m_ReferenceResolution: {x: 1080, y: 1920}
|
m_ReferenceResolution: {x: 1920, y: 1080}
|
||||||
m_ScreenMatchMode: 0
|
m_ScreenMatchMode: 0
|
||||||
m_MatchWidthOrHeight: 0
|
m_MatchWidthOrHeight: 0
|
||||||
m_PhysicalUnit: 3
|
m_PhysicalUnit: 3
|
||||||
|
|
Loading…
Reference in New Issue