Compare commits
No commits in common. "bb427c1bd2ea78082994eafda54c8f39e8da03b1" and "18275fb07653975e0f65b89bdf06a3473d97a83b" have entirely different histories.
bb427c1bd2
...
18275fb076
|
@ -1,64 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using Sirenix.OdinInspector;
|
|
||||||
using Sirenix.OdinInspector.Editor;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using ZC;
|
|
||||||
|
|
||||||
namespace ZEditor
|
|
||||||
{
|
|
||||||
public class QuestionEditor : OdinEditorWindow
|
|
||||||
{
|
|
||||||
[MenuItem("ZTools/QuestionEditor")]
|
|
||||||
private static void OpenWindow()
|
|
||||||
{
|
|
||||||
GetWindow<QuestionEditor>().Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
[FolderPath] public string savePath = "Assets/DemoGame/GameRes/Config";
|
|
||||||
public string saveName;
|
|
||||||
private string path => $"{savePath}/{saveName}.asset";
|
|
||||||
|
|
||||||
public List<AnswerData> AnswerDatas = new List<AnswerData>();
|
|
||||||
|
|
||||||
[Button("加载")]
|
|
||||||
void LoadData(string fileName)
|
|
||||||
{
|
|
||||||
string filePath = $"{savePath}/{fileName}.asset";
|
|
||||||
var loadAssetAtPath = AssetDatabase.LoadAssetAtPath<QuestionBankData>(filePath);
|
|
||||||
AnswerDatas = loadAssetAtPath.AnswerDatas;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Button("保存")]
|
|
||||||
void SaveData()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(savePath))
|
|
||||||
{
|
|
||||||
Debug.LogError("请填入正确路径!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(saveName))
|
|
||||||
{
|
|
||||||
Debug.LogError("请填入正确文件名!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(path))
|
|
||||||
{
|
|
||||||
var questionBankData = ScriptableObject.CreateInstance<QuestionBankData>();
|
|
||||||
questionBankData.AnswerDatas = new List<AnswerData>(AnswerDatas);
|
|
||||||
AssetDatabase.CreateAsset(questionBankData, path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var data = AssetDatabase.LoadAssetAtPath<QuestionBankData>(path);
|
|
||||||
data.AnswerDatas = AnswerDatas;
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
saveName = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 290ea4dab1c646dcbb9375d178a85f3f
|
|
||||||
timeCreated: 1730038626
|
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 4bc9670fa7014130a180ddedb93dffb5
|
|
||||||
timeCreated: 1730041828
|
|
|
@ -1,31 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace ZC
|
|
||||||
{
|
|
||||||
[System.Serializable]
|
|
||||||
public class QuestionBankData : ScriptableObject
|
|
||||||
{
|
|
||||||
public string questionName;
|
|
||||||
public List<AnswerData> AnswerDatas = new List<AnswerData>();
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public class AnswerData
|
|
||||||
{
|
|
||||||
public int index;
|
|
||||||
public string title;
|
|
||||||
public List<OptionData> options = new List<OptionData>();
|
|
||||||
public string trueOption;
|
|
||||||
public string analyze;
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public class OptionData
|
|
||||||
{
|
|
||||||
public string content;
|
|
||||||
|
|
||||||
public bool isTrue;
|
|
||||||
// public string analyze;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: d756517b2bde43b68b5ed56251a48a9b
|
|
||||||
timeCreated: 1730041548
|
|
|
@ -1,4 +1,5 @@
|
||||||
using TMPro;
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace ZC
|
namespace ZC
|
||||||
|
@ -119,4 +120,26 @@ namespace ZC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue