Compare commits

..

No commits in common. "ec4d72adcc0f45b7f1c5ca85b74b29e24913132b" and "2006bf10ff391bb784e81c59dfc4e5c14ccdba66" have entirely different histories.

16 changed files with 17 additions and 4361 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 3e4645aaac3d48d4896ad6e7b2a1f1cc
PrefabImporter:
externalObjects: {}
userData:
assetBundleName: uiknowledge_prefab
assetBundleVariant:

View File

@ -132,11 +132,11 @@ namespace QFramework
}
public virtual void Update()
{
#if VR
private void Update()
{
transform.localEulerAngles = Vector3.zero;
#endif
}
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 13457db631332b149901c3d79f802d84
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -27,8 +27,7 @@ public class ActionHelper
{ "UI3DObjSelect", typeof(QFramework.Example.UI3DObjSelect) },
{ "UITextTip", typeof(QFramework.Example.UITextTip) },
{ "UITextWindow", typeof(QFramework.Example.UITextWindow) },
{ "UIKnowledge", typeof(QFramework.Example.UIKnowledge) },
};

View File

@ -35,6 +35,7 @@ namespace QFramework.Example
{
Point.anchoredPosition = Utility.GetScreenPosByObj(transform as RectTransform);
}
}
#endif

View File

@ -45,9 +45,8 @@ namespace QFramework.Example
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
}
public override void Update()
private void Update()
{
base.Update();
if (isRun)
{
object[] objects = new object[mData.values.Count];

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 762d12b9d2c220c46afe6eb3eda2e85c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,67 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using QFramework;
namespace QFramework.Example
{
// Generate Id:d21887cc-bea5-4c87-8eae-a1d693d6555a
public partial class UIKnowledge
{
public const string Name = "UIKnowledge";
[SerializeField]
public UnityEngine.UI.Button CloseBtn;
[SerializeField]
public RectTransform LeftContent;
[SerializeField]
public UnityEngine.UI.ScrollRect Right;
[SerializeField]
public UnityEngine.UI.Image RightContent;
[SerializeField]
public RectTransform GlobalComs;
[SerializeField]
public RectTransform ItemComs;
[SerializeField]
public RectTransform LeftItem;
[SerializeField]
public UnityEngine.UI.Button BtnPrefab;
private UIKnowledgeData mPrivateData = null;
protected override void ClearUIComponents()
{
CloseBtn = null;
LeftContent = null;
Right = null;
RightContent = null;
GlobalComs = null;
ItemComs = null;
LeftItem = null;
BtnPrefab = null;
mData = null;
}
public UIKnowledgeData Data
{
get
{
return mData;
}
}
UIKnowledgeData mData
{
get
{
return mPrivateData ?? (mPrivateData = new UIKnowledgeData());
}
set
{
mUIData = value;
mPrivateData = value;
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 9a5d5c0eba3097b48b9c67e7e229ccee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,198 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using TMPro;
using System.Collections.Generic;
using System;
namespace QFramework.Example
{
public class UIKnowledgeData : UIPanelData
{
public XMLTool.Knowledge knowledge;
}
public partial class UIKnowledge : UIPanel
{
ResLoader loader;
Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();
IAction curAction;
protected override void OnInit(IUIData uiData = null)
{
mData = uiData as UIKnowledgeData ?? new UIKnowledgeData();
// please add init code here
loader = ResLoader.Allocate();
CloseBtn.onClick.AddListener(() =>
{
Hide();
});
}
protected override void OnOpen(IUIData uiData = null)
{
if (Global.Instance.curModule.knowledge != null && Global.Instance.curModule.knowledge.items != null)
{
LeftContent.RemoveAllChildren();
string bg = Global.Instance.curModule.knowledge.bgImage;
LoadBgImage(bg, () =>
{
SetRightContentPos("");
RefreshComponents(Global.Instance.curModule.knowledge.components, GlobalComs);
});
foreach (var item in Global.Instance.curModule.knowledge.items)
{
ItemFactory(item);
}
}
}
public void ItemFactory(XMLTool.Knowledge.Item itemData, Transform parent = null)
{
Transform content = parent == null ? LeftContent : parent;
GameObject leftObj = GameObject.Instantiate(LeftItem.gameObject, content);
Transform subContent = leftObj.transform.Find("SubContent");
Toggle toggle = leftObj.transform.Find("Toggle").GetComponent<Toggle>();
TextMeshProUGUI label = toggle.transform.Find("Name").GetComponent<TextMeshProUGUI>();
label.text = itemData.title;
toggle.onValueChanged.AddListener(isOn =>
{
if (isOn)
{
LoadBgImage(itemData.bgImage, () =>
{
SetRightContentPos(itemData.setPos);
});
ItemComs.RemoveAllChildren();
RefreshComponents(itemData.components, ItemComs);
}
if (subContent.childCount > 0)
{
subContent.gameObject.SetActive(isOn);
if (isOn)
{
subContent.GetChild(0).GetComponentInChildren<Toggle>().isOn = true;
}
}
else
{
label.color = isOn == true ? Color.black : Color.white;
}
});
if (itemData.subs != null && itemData.subs.Count > 0)
{
foreach (var sub in itemData.subs)
{
ItemFactory(sub, subContent);
}
}
else
{
toggle.group = LeftContent.GetComponent<ToggleGroup>();
}
}
/// <summary>
/// ˢе±Ç°Ò³ÃæµÄ¹Ò¼þ
/// </summary>
public void RefreshComponents(List<XMLTool.Knowledge.Item.Component> coms, Transform content)
{
if (coms != null && coms.Count > 0)
{
foreach (var ComData in coms)
{
switch (ComData.type)
{
case "Button":
GameObject btn = GameObject.Instantiate(BtnPrefab.gameObject, content);
btn.GetComponent<RectTransform>().sizeDelta = Utility.GetVector2FromStrArray(ComData.size);
btn.transform.localPosition = Utility.GetVector2FromStrArray(ComData.pos);
btn.GetComponent<Button>().onClick.AddListener(() =>
{
if (curAction != null)
{
curAction.Deinit();
curAction = null;
}
curAction = ActionHelper.GetActionAndSub(ComData.action);
curAction.StartGlobal(() =>
{
curAction = null;
});
});
break;
}
}
}
}
public void LoadBgImage(string bg, Action callback = null)
{
if (string.IsNullOrEmpty(bg) == false)
{
if (sprites.ContainsKey(bg))
{
RightContent.sprite = sprites[bg];
RightContent.SetNativeSize();
callback?.Invoke();
}
else
{
var localImageUrl = Global.imagePath + bg;
loader.Add2Load(localImageUrl.ToNetImageResName(), (success, res) =>
{
if (success)
{
Sprite sprite = Utility.GetSprite(res.Asset.As<Texture2D>());
if (sprites.ContainsKey(bg) == false)
{
sprites.Add(bg, sprite);
}
}
});
TypeEventSystem.Global.Send<OnLoadingShow>();
loader.LoadAsync(() =>
{
callback?.Invoke();
RightContent.sprite = sprites[bg];
RightContent.SetNativeSize();
TypeEventSystem.Global.Send<OnLoadingHide>();
});
}
}
else
{
callback?.Invoke();
}
}
public void SetRightContentPos(string setPos)
{
Vector2 pos = default;
if (string.IsNullOrEmpty(setPos) == false)
{
pos = Utility.GetVector2FromStrArray(setPos);
}
RightContent.rectTransform.anchoredPosition = pos;
}
protected override void OnShow()
{
}
protected override void OnHide()
{
}
protected override void OnClose()
{
sprites.Clear();
loader.ReleaseAllRes();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fd25ee86b2071da4aa68360bc13232e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,11 +1,7 @@
using QFramework;
using QFramework.Example;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using UnityEngine;
using static XMLTool.Body3D;
namespace XMLTool
@ -46,8 +42,6 @@ namespace XMLTool
public Score score;
public Body3D body3d;
public Knowledge knowledge;
}
public class Device
@ -221,32 +215,6 @@ namespace XMLTool
public string isOff;
}
public class Knowledge
{
public class Item
{
public class Component
{
public string type;
public string size;
public string pos;
public Action action;
}
public string title;
public string bgImage;
public string setPos;
public List<Item> subs;
public List<Component> components;
}
public string bgImage;
public List<Item> items;
public List<Item.Component> components;
}
public class XmlParser
{
public static AppData ParseXml(string xmlString)
@ -422,7 +390,6 @@ namespace XMLTool
module.body3d.parts.Add(part.Name, part);
}
}
// 解析评分
XElement scoreNode = moduleElement.Element("Score");
if (scoreNode != null)
{
@ -442,66 +409,8 @@ namespace XMLTool
});
}
}
// 解析知识点
var knowledge = moduleElement.Element("Knowledge");
if (knowledge != null)
{
module.knowledge = new Knowledge();
module.knowledge.bgImage = knowledge.Attribute("bgImage")?.Value;
foreach (var itemXml in knowledge.Elements("Item"))
{
Knowledge.Item item = ParserKnowledgeItem(itemXml);
if (module.knowledge.items == null)
{
module.knowledge.items = new List<Knowledge.Item>();
}
module.knowledge.items.Add(item);
}
module.knowledge.components = ParserKnowledgeComponet(knowledge);
}
}
}
private static Knowledge.Item ParserKnowledgeItem(XElement itemXml)
{
Knowledge.Item item = new Knowledge.Item();
item.title = itemXml.Attribute("title")?.Value;
item.bgImage = itemXml.Attribute("bgImage")?.Value;
item.setPos = itemXml.Attribute("setPos")?.Value;
item.components = ParserKnowledgeComponet(itemXml);
foreach (var subXml in itemXml.Elements("Item"))
{
if (item.subs == null)
{
item.subs = new List<Knowledge.Item>();
}
// 增加子物体
item.subs.Add(ParserKnowledgeItem(subXml));
}
return item;
}
private static List<Knowledge.Item.Component> ParserKnowledgeComponet(XElement xmlData)
{
List<Knowledge.Item.Component> list = null;
foreach (var componentXml in xmlData.Elements("Component"))
{
if (list == null)
{
list = new List<Knowledge.Item.Component>();
}
Knowledge.Item.Component component = new Knowledge.Item.Component();
component.type = componentXml.Attribute("type")?.Value;
component.pos = componentXml.Attribute("pos")?.Value;
component.size = componentXml.Attribute("size")?.Value;
component.action = ParseAction(componentXml.Element("Action"));
list.Add(component);
}
return list;
}
private static Body3D.Body ParseBody(XElement bodyElement, Body parent = null)
{
Body3D.Body body = new Body3D.Body
@ -513,7 +422,7 @@ namespace XMLTool
Audio = bodyElement.Attribute("audio")?.Value,
FocusDistance = bodyElement.Attribute("FocusDistance")?.Value
};
var isShow = bodyElement.Attribute("isShow");
if (isShow != null)
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 MiB

View File

@ -20,7 +20,7 @@
<!--显示得分UI界面 onlyCurModule 是否仅显示当前模块成绩 默认为false-->
<Action type="ShowScore" onlyCurModule="true"></Action>
<!--切换operation模块 使用此功能 operation的配置中必须有name属性
name为operation配置中的name
执行此行后 不需要在执行NextOperationAction 框架底层执行了
@ -338,45 +338,6 @@
</Step>
</Operation>
<!--知识点
title对应左侧树状图的名字
bgImage是右侧的长图
Component是长图上挂在的组件 目前仅支持Type=Button的按钮类型
Action是动作组 点击按钮后的动作
Component标签与bgImage属性 可以在根节点Knowledge上也可以在子节点Item上
位于根节点时 是全局的 位于Item节点时是切换Item后展示的针对与Item的
-->
<Knowledge bgImage="Knowledge/ChangTu.png">
<Item title="第一步" setPos="0,0">
<Item title="第一步_第一个子步骤" bgImage="" setPos="0,100">
<Component type="Button" size="200,200" pos="200,-200">
<Action type="Log" value="第二步_第二个子步骤"></Action>
</Component>
<Component type="Button" size="200,200" pos="400,-200">
<Action type="Log" value="第二步_第二个子步骤"></Action>
</Component>
</Item>
</Item>
<Item title="第二步" setPos="0,400">
<Item title="第二步_第一个子步骤" bgImage="" setPos="0,500">
<Component type="Button" size="200,200" pos="200,-400">
<Action type="Log" value="第二步_第二个子步骤"></Action>
</Component>
<Component type="Button" size="200,200" pos="400,-400">
<Action type="Log" value="第二步_第二个子步骤"></Action>
</Component>
</Item>
<Item title="第二步_第二个子步骤" bgImage="" setPos="0,600"></Item>
</Item>
<Component type="Button" size="932,526" pos="20,-9653">
<Action type="Sequence">
<Action type="Log" value="第一步_第一个子步骤"></Action>
<Action type="Video" value="test.mp4" size="500,500" offset="10,10" finishedEvent="finished" closeEvent="close"></Action>
</Action>
</Component>
</Knowledge>
<!--动作组-->
<Action name="初始化" type="Sequence">
@ -425,9 +386,9 @@
<Action type="Log" value="ddd"></Action>
</Action>
</Exit>
</State>
</State>-->
<Transision from="any" to="状态1">
<Condition type="UIClick" value="Cube"></Condition>
<Condition type="ObjClick" value="Cube"></Condition>
</Transision>
<Transision from="初始状态" to="状态2">
<Condition type="ObjClick" value="Cube (1)"></Condition>
@ -447,7 +408,7 @@
<Body name="左一" path="Ren_NEW/SM_GuGe/upper_limb_bone/Left_upper_limb_bones/Left_free_upper_limb_bones" tip="左一肋骨描述">
<ObjectToggle>
<Color isOn="0,255,255" isOff="255,255,255"></Color>
</ObjectToggle>
</ObjectToggle>
</Body>
<Body name="左二" path="Ren/Tou/GuGe/LeiGu/ZuoLei/2" tip="左二肋骨描述">
<ObjectToggle>
@ -455,9 +416,9 @@
</ObjectToggle>
</Body>
</Body>
<Body name="右肋" path="Ren/Tou/GuGe/LeiGu/YouLei">
<Body name="右一" path="Ren/Tou/GuGe/LeiGu/YouLei/1" tip="7右一肋骨描述">
<ObjectToggle>
@ -501,8 +462,8 @@
</ObjectToggle>
</Body>
</Body>
<Body name="神经" isBodyList="true">
<Body name="神经" isBodyList="true">
<Body name="aaa" path="Ren/Tou/ShenJing/1">
<ObjectToggle>
<Color></Color>
@ -519,7 +480,7 @@
</ObjectToggle>
</Body>
</Body>
</Body>
</Body3D>