Merge remote-tracking branch 'origin/master' into LouDi_Pig

This commit is contained in:
李浩 2025-01-13 08:54:43 +08:00
commit a318a9c0d7
14 changed files with 274 additions and 69 deletions

View File

@ -468,6 +468,7 @@ MonoBehaviour:
Training: {fileID: 2329671978117574524} Training: {fileID: 2329671978117574524}
Operation: {fileID: 616562839221942952} Operation: {fileID: 616562839221942952}
TrainContent: {fileID: 5869372504899619242} TrainContent: {fileID: 5869372504899619242}
ContentText: {fileID: 2630179459340483145}
OperationContent: {fileID: 3768800539522999701} OperationContent: {fileID: 3768800539522999701}
ConfirmBtn: {fileID: 783019177237190269} ConfirmBtn: {fileID: 783019177237190269}
--- !u!1 &2550146359932684284 --- !u!1 &2550146359932684284
@ -1805,6 +1806,7 @@ GameObject:
- component: {fileID: 1747114938129779637} - component: {fileID: 1747114938129779637}
- component: {fileID: 6155234247361610581} - component: {fileID: 6155234247361610581}
- component: {fileID: 2630179459340483145} - component: {fileID: 2630179459340483145}
- component: {fileID: 956712290457367647}
m_Layer: 5 m_Layer: 5
m_Name: ContentText m_Name: ContentText
m_TagString: Untagged m_TagString: Untagged
@ -1928,6 +1930,22 @@ MonoBehaviour:
m_hasFontAssetChanged: 0 m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0} m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &956712290457367647
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8301949965222141633}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d51f3a7c41ab0346b49ae50d456bece, type: 3}
m_Name:
m_EditorClassIdentifier:
MarkType: 0
CustomComponentName:
CustomComment:
mComponentName: TMPro.TextMeshProUGUI
--- !u!1 &8662634946358023954 --- !u!1 &8662634946358023954
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -522,7 +522,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 7464141640143892343} - {fileID: 7464141640143892343}
- {fileID: 3051202814640239909} - {fileID: 4775158531114985421}
- {fileID: 642645979159612403} - {fileID: 642645979159612403}
m_Father: {fileID: 8969698929162076767} m_Father: {fileID: 8969698929162076767}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1055,7 +1055,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6746250251467292074} m_GameObject: {fileID: 6746250251467292074}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
@ -1063,7 +1063,7 @@ RectTransform:
- {fileID: 1684458048730538019} - {fileID: 1684458048730538019}
- {fileID: 5860908020037853715} - {fileID: 5860908020037853715}
- {fileID: 8568704472119011922} - {fileID: 8568704472119011922}
m_Father: {fileID: 5675325337001315481} m_Father: {fileID: 4775158531114985421}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
@ -1183,3 +1183,79 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &9141652036248099059
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4775158531114985421}
- component: {fileID: 5397078064978493576}
- component: {fileID: 6634696415031054332}
m_Layer: 0
m_Name: IconBg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4775158531114985421
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9141652036248099059}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3051202814640239909}
m_Father: {fileID: 5675325337001315481}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 76, y: 76}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5397078064978493576
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9141652036248099059}
m_CullTransparentMesh: 1
--- !u!114 &6634696415031054332
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9141652036248099059}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.07058824, g: 0.15686275, b: 0.19607843, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1

View File

@ -18,6 +18,8 @@ public class ActionHelper
{ "UIHint", typeof(QFramework.Example.UIHint) }, { "UIHint", typeof(QFramework.Example.UIHint) },
{ "UIPointQuestion", typeof(QFramework.Example.UIPointQuestion) }, { "UIPointQuestion", typeof(QFramework.Example.UIPointQuestion) },
{ "UICameraSwitch", typeof(QFramework.Example.UICameraSwitch) }, { "UICameraSwitch", typeof(QFramework.Example.UICameraSwitch) },
{ "UIInstruction", typeof(QFramework.Example.UIInstruction) },
{ "UIScore", typeof(QFramework.Example.UIScore) },
}; };

View File

@ -4,81 +4,143 @@ using UnityEditor;
using System.Collections; using System.Collections;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System;
using System.IO;
public class FbxAnimListPostprocessor : MonoBehaviour public class FbxAnimListPostprocessor : MonoBehaviour
{ {
[MenuItem("Assets/SplitAnimNew")] [MenuItem("Assets/SplitAnimNew")]
public static void SplitAnim() public static void SplitAnim()
{ {
UnityEngine.Object obj = Selection.activeObject; UnityEngine.Object obj = Selection.activeObject;
if( null != obj ) if (null != obj)
{ {
string assetPath = AssetDatabase.GetAssetPath(obj); string assetPath = AssetDatabase.GetAssetPath(obj);
try SplitAnim(assetPath);
{ }
string fileAnim; }
fileAnim = assetPath;
string ClipText = Path.ChangeExtension(fileAnim, ".txt"); [MenuItem("Assets/SplitAnimFloder")]
StreamReader file = new StreamReader(ClipText); public static void SetAplitAnim()
string sAnimList = file.ReadToEnd(); {
file.Close(); Object[] selectedObjects = Selection.GetFiltered<Object>(SelectionMode.DeepAssets);
// foreach (Object obj in selectedObjects)
if (EditorUtility.DisplayDialog("FBX Animation Import from file", {
fileAnim, "Import", "Cancel")) if (obj != null)
{ {
System.Collections.ArrayList List = new ArrayList(); string path = AssetDatabase.GetAssetPath(obj);
ParseAnimFile(sAnimList, ref List); if (Directory.Exists(path))
{
EnableFBXReadWriteInFolder(path);
}
else if (path.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase))
{
EnableFBXReadWriteForFile(path);
}
}
}
}
public static void EnableFBXReadWriteInFolder(string folderPath)
{
string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories);
foreach (string file in files)
{
EnableFBXReadWriteForFile(file);
}
}
public static void EnableFBXReadWriteForFile(string filePath)
{
string relativePath = filePath;
SplitAnim(filePath, true);
}
public static void SplitAnim(string assetPath, bool autoImport = false)
{
try
{
string fileAnim;
fileAnim = assetPath;
string ClipText = Path.ChangeExtension(fileAnim, ".txt");
StreamReader file = new StreamReader(ClipText);
string sAnimList = file.ReadToEnd();
file.Close();
//
if (autoImport)
{
System.Collections.ArrayList List = new ArrayList();
ParseAnimFile(sAnimList, ref List);
ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;
modelImporter.animationType = ModelImporterAnimationType.Legacy;
//modelImporter.clipAnimations. = true;
modelImporter.clipAnimations = (ModelImporterClipAnimation[])
List.ToArray(typeof(ModelImporterClipAnimation));
AssetDatabase.ImportAsset(assetPath);
}
else
{
if (EditorUtility.DisplayDialog("FBX Animation Import from file",
fileAnim, "Import", "Cancel"))
{
System.Collections.ArrayList List = new ArrayList();
ParseAnimFile(sAnimList, ref List);
ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter; ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter;
modelImporter.animationType = ModelImporterAnimationType.Legacy; modelImporter.animationType = ModelImporterAnimationType.Legacy;
//modelImporter.clipAnimations. = true; //modelImporter.clipAnimations. = true;
modelImporter.clipAnimations = (ModelImporterClipAnimation[]) modelImporter.clipAnimations = (ModelImporterClipAnimation[])
List.ToArray(typeof(ModelImporterClipAnimation)); List.ToArray(typeof(ModelImporterClipAnimation));
AssetDatabase.ImportAsset(assetPath); AssetDatabase.ImportAsset(assetPath);
EditorUtility.DisplayDialog("导入成功", EditorUtility.DisplayDialog("导入成功",
"Number of imported clips: " "Number of imported clips: "
+ modelImporter.clipAnimations.GetLength(0).ToString(), "OK"); + modelImporter.clipAnimations.GetLength(0).ToString(), "OK");
} }
} }
catch { }
// (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); }
}
}
static void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List) }
{ catch { }
Regex regexString = new Regex(" *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| )) *(?<name>[^\r^\n]*[^\r^\n^ ])", // (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); }
RegexOptions.Compiled | RegexOptions.ExplicitCapture); }
Match match = regexString.Match(sAnimList, 0); static void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List)
while (match.Success) {
{ Regex regexString = new Regex(" *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| )) *(?<name>[^\r^\n]*[^\r^\n^ ])",
ModelImporterClipAnimation clip = new ModelImporterClipAnimation(); RegexOptions.Compiled | RegexOptions.ExplicitCapture);
if (match.Groups["firstFrame"].Success) Match match = regexString.Match(sAnimList, 0);
{ while (match.Success)
clip.firstFrame = System.Convert.ToInt32(match.Groups["firstFrame"].Value, 10); {
} ModelImporterClipAnimation clip = new ModelImporterClipAnimation();
if (match.Groups["lastFrame"].Success)
{
clip.lastFrame = System.Convert.ToInt32(match.Groups["lastFrame"].Value, 10);
}
if (match.Groups["loop"].Success)
{
clip.loop = match.Groups["loop"].Value == "loop";
}
if (match.Groups["name"].Success)
{
clip.name = match.Groups["name"].Value;
}
List.Add(clip); if (match.Groups["firstFrame"].Success)
{
clip.firstFrame = System.Convert.ToInt32(match.Groups["firstFrame"].Value, 10);
}
if (match.Groups["lastFrame"].Success)
{
clip.lastFrame = System.Convert.ToInt32(match.Groups["lastFrame"].Value, 10);
}
if (match.Groups["loop"].Success)
{
if (match.Groups["loop"].Value == "loop")
{
clip.loop = true;
clip.wrapMode = WrapMode.Loop;
}
else
{
clip.loop = false;
}
}
if (match.Groups["name"].Success)
{
clip.name = match.Groups["name"].Value;
}
List.Add(clip);
match = regexString.Match(sAnimList, match.Index + match.Length); match = regexString.Match(sAnimList, match.Index + match.Length);
} }
} }
} }

View File

@ -27,6 +27,9 @@ public class SetReadWrite : Editor
} }
} }
public static void EnableFBXReadWriteInFolder(string folderPath) public static void EnableFBXReadWriteInFolder(string folderPath)
{ {
string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories); string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories);

View File

@ -48,7 +48,15 @@ public class DeviceItem : MonoBehaviour
bool.TryParse(obj[0], out isActive); bool.TryParse(obj[0], out isActive);
if (obj.Length == 1 || (obj.Length > 1 && obj[1] == device.Name)) if (obj.Length == 1 || (obj.Length > 1 && obj[1] == device.Name))
{ {
gameObject.GetComponent<HighlightTrigger>().enabled = isActive; var high = gameObject.GetComponent<HighlightTrigger>();
if (high != null)
{
gameObject.GetComponent<HighlightTrigger>().enabled = isActive;
}
else
{
Debug.LogError(device.Name + "身上没有高亮组件");
}
} }
} }
} }

View File

@ -5,7 +5,7 @@ using QFramework;
namespace QFramework.Example namespace QFramework.Example
{ {
// Generate Id:b1c63efb-a7a0-4270-8cd9-08f25e4d69b5 // Generate Id:031f03df-56cd-4f22-b0e4-b4cc8ddb2f1a
public partial class UIInstruction public partial class UIInstruction
{ {
public const string Name = "UIInstruction"; public const string Name = "UIInstruction";
@ -17,6 +17,8 @@ namespace QFramework.Example
[SerializeField] [SerializeField]
public RectTransform TrainContent; public RectTransform TrainContent;
[SerializeField] [SerializeField]
public TMPro.TextMeshProUGUI ContentText;
[SerializeField]
public UnityEngine.UI.Image OperationContent; public UnityEngine.UI.Image OperationContent;
[SerializeField] [SerializeField]
public UnityEngine.UI.Button ConfirmBtn; public UnityEngine.UI.Button ConfirmBtn;
@ -28,6 +30,7 @@ namespace QFramework.Example
Training = null; Training = null;
Operation = null; Operation = null;
TrainContent = null; TrainContent = null;
ContentText = null;
OperationContent = null; OperationContent = null;
ConfirmBtn = null; ConfirmBtn = null;

View File

@ -2,6 +2,7 @@ using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using QFramework; using QFramework;
using TMPro; using TMPro;
using System.Diagnostics.Eventing.Reader;
namespace QFramework.Example namespace QFramework.Example
{ {
@ -47,6 +48,15 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
if (string.IsNullOrEmpty(Global.Instance.curModule.Descript))
{
ContentText.text = "没有Descript相关配置";
}
else
{
ContentText.text = Global.Instance.curModule.Descript;
}
} }
protected override void OnShow() protected override void OnShow()

View File

@ -34,6 +34,8 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
Content.RemoveAllChildren(); Content.RemoveAllChildren();
int moduleCount = 0;
int lastIndex = 0;
for (int i = 0; i < Global.Instance.appData.Modules.Count; i++) for (int i = 0; i < Global.Instance.appData.Modules.Count; i++)
{ {
var item = Global.Instance.appData.Modules[i]; var item = Global.Instance.appData.Modules[i];
@ -42,6 +44,7 @@ namespace QFramework.Example
if (curType == Global.appTpe || curType == Global.AppType.All) if (curType == Global.appTpe || curType == Global.AppType.All)
{ {
moduleCount++;
int index = i; int index = i;
GameObject obj = GameObject.Instantiate(BtnItem.gameObject, Content); GameObject obj = GameObject.Instantiate(BtnItem.gameObject, Content);
obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item.ModuleName; obj.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = item.ModuleName;
@ -54,12 +57,24 @@ namespace QFramework.Example
SceneManager.sceneLoaded += OnLoadFinished; SceneManager.sceneLoaded += OnLoadFinished;
}); });
}); });
lastIndex = index;
} }
}
if (moduleCount == 1)
{
Global.Instance.curModule = Global.Instance.appData.Modules[lastIndex];
UIKit.OpenPanelAsync<UILoading>(canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() =>
{
SceneManager.LoadSceneAsync(Global.Instance.curModule.Scene, LoadSceneMode.Single);
SceneManager.sceneLoaded += OnLoadFinished;
});
} }
} }

View File

@ -35,7 +35,7 @@ namespace QFramework.Example
scoreBtn.onClick.AddListener(() => scoreBtn.onClick.AddListener(() =>
{ {
UIKit.OpenPanelAsync<UIScore>().ToAction().StartGlobal(); UIKit.OpenPanelAsync<UIScore>(canvasLevel: UILevel.PopUI).ToAction().StartGlobal();
}); });
} }
@ -65,10 +65,10 @@ namespace QFramework.Example
case Global.AppType.UnKnow: case Global.AppType.UnKnow:
break; break;
case Global.AppType.Study: case Global.AppType.Study:
Score.gameObject.SetActive(true); Score.gameObject.SetActive(false);
break; break;
case Global.AppType.Exam: case Global.AppType.Exam:
Score.gameObject.SetActive(false); Score.gameObject.SetActive(true);
break; break;
case Global.AppType.All: case Global.AppType.All:
break; break;

View File

@ -61,6 +61,8 @@ namespace QFramework.Example
sum += float.Parse(item.Value.sum); sum += float.Parse(item.Value.sum);
score += item.Value.value; score += item.Value.value;
} }
this.Score.text = score.ToString();
this.Sum.text = sum.ToString();
} }
protected override void OnShow() protected override void OnShow()

View File

@ -60,7 +60,7 @@ namespace QFramework.Example
Debug.Log(item.Name + "????"); Debug.Log(item.Name + "????");
obj.name = item.Name; obj.name = item.Name;
obj.transform.Find("Name").GetComponent<TextMeshProUGUI>().text = item.Name; obj.transform.Find("Name").GetComponent<TextMeshProUGUI>().text = item.Name;
Image icon = obj.transform.Find("Icon").GetComponent<Image>(); Image icon = obj.transform.Find("IconBg/Icon").GetComponent<Image>();
var localImageUrl = Global.deviceIconsPath + item.Icon; var localImageUrl = Global.deviceIconsPath + item.Icon;
GameObject right = icon.transform.Find("Right").gameObject; GameObject right = icon.transform.Find("Right").gameObject;
GameObject wrong = icon.transform.Find("Wrong").gameObject; GameObject wrong = icon.transform.Find("Wrong").gameObject;
@ -125,7 +125,7 @@ namespace QFramework.Example
public void SetSelected(GameObject item, bool isRight) public void SetSelected(GameObject item, bool isRight)
{ {
Transform icon = item.transform.Find("Icon"); Transform icon = item.transform.Find("IconBg/Icon");
GameObject right = icon.Find("Right").gameObject; GameObject right = icon.Find("Right").gameObject;
GameObject wrong = icon.Find("Wrong").gameObject; GameObject wrong = icon.Find("Wrong").gameObject;
GameObject Selected = icon.Find("Selected").gameObject; GameObject Selected = icon.Find("Selected").gameObject;

View File

@ -22,6 +22,7 @@ namespace XMLTool
public string type { get; set; } public string type { get; set; }
public string Scene { get; set; } public string Scene { get; set; }
public string ModuleName { get; set; } public string ModuleName { get; set; }
public string Descript { get; set; }
public List<Operation> Operations { get; set; } public List<Operation> Operations { get; set; }
public List<Device> Devices { get; set; } public List<Device> Devices { get; set; }
@ -186,6 +187,7 @@ namespace XMLTool
// 解析模块名称 // 解析模块名称
module.type = moduleElement.Element("Type")?.Value; module.type = moduleElement.Element("Type")?.Value;
module.ModuleName = moduleElement.Element("Name")?.Value; module.ModuleName = moduleElement.Element("Name")?.Value;
module.Descript = moduleElement.Element("Descript")?.Value;
module.Scene = moduleElement.Element("Scene")?.Value; module.Scene = moduleElement.Element("Scene")?.Value;
// 解析设备 // 解析设备

View File

@ -155,6 +155,10 @@
<!--模块名字--> <!--模块名字-->
<Name>模块1</Name> <Name>模块1</Name>
<Descript>
这里是实训描述内容.....
巴拉巴拉....
</Descript>
<Device> <Device>
<Name>组织钳</Name> <Name>组织钳</Name>
<HighLight color="255,255,255"/> <HighLight color="255,255,255"/>