实验用品编辑器说明文档

实验用品编辑器说明文档


组件接口-说明文档

<table> <thead> <tr> <th>最后更新日期</th> <th>2024-01-18</th> </tr> </thead> <tbody> <tr> <td>作者</td> <td>QFord、LJX、ZYY</td> </tr> <tr> <td>V1.0.0</td> <td>创建文档</td> </tr> <tr> <td>V2.0.0</td> <td>1.设置器材模型对象创建的根节点 2.从器材LuaTable中获取属性3.设置器材LuaTable中的属性</td> </tr> <tr> <td>V2.0.1</td> <td>新增器材多语言切换接口</td> </tr> </tbody> </table> <p>&gt; 文档版本和组件版本对应</p> <p>[TOC]</p> <h1>组件概述</h1> <p>物件(器材)播放器组件提供器材的创建、删除、修改和查询基础能力。 此外,还提供观察器材、加速器材和显示器材电场线等扩展能力。 &gt; 注:扩展能力将计划在2.0.0版本中开发(2024-1~2024-2)。</p> <hr /> <h1>组件接口汇总</h1> <p>- <a href="#CreateEquipment">CreateEquipment</a>: 创建单个器材 - <a href="#CreateEquipments">CreateEquipments</a>: 创建多个器材 - <a href="#CreateEquipmentByCoroutine">CreateEquipmentByCoroutine</a>: 使用协程创建单个器材 - <a href="#CreateEquipmentsByCoroutine">CreateEquipmentsByCoroutine</a>: 使用协程创建多个器材 - <a href="#DeleteEquipmentByGuid">DeleteEquipmentByGuid</a>: 根据guid删除器材 - <a href="#DeleteEquipmentByObject">DeleteEquipmentByObject</a>: 根据Gameobject删除器材 - <a href="#DeleteAllEquipments">DeleteAllEquipments</a>: 清空场景中所有器材 - <a href="#SetEquipRoot">SetEquipRoot</a>: 设置器材模型对象创建的根节点 - <a href="#GetEquipPropertyFromLuaTable">GetEquipPropertyFromLuaTable</a>: 从场景中已创建的器材LuaTable中获取属性 - <a href="#SetEquipPropertyToLuaTable">SetEquipPropertyToLuaTable</a>: 设置场景中已创建的器材LuaTable中的属性 - <a href="#SwitchLanguage">SwitchLanguage</a>: 器材多语言切换</p> <h1>组件基础接口</h1> <p> &lt;a id=&quot;CreateEquipment&quot;&gt;&lt;/a&gt;</p> <h3>创建单个器材</h3> <p>GameObject CreateEquipment(EquipementPreset presets)</p> <p><strong>简要说明:</strong></p> <ul> <li>创建单个器材</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">presets</td> <td style="text-align: left;">EquipementPreset</td> <td>器材信息</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>GameObject</p> <p><strong>示例</strong> ```C# var code = new EquipementPreset() { Code = &quot;JiuJingDengElement&quot;, Position = BornTrans.position}; var goList = EquipmentManager.CreateEquipment(code);</p> <pre><code>  &amp;lt;a id=&amp;quot;CreateEquipments&amp;quot;&amp;gt;&amp;lt;/a&amp;gt; ###一次创建多个器材 GameObject[] CreateEquipments(EquipementPreset[] presets) **简要说明:** - 一次创建多个器材 **参数:** |参数名|类型|说明| |:---- |:----- |----- | |presets |EquipementPreset[] |器材信息列表| **返回值说明** GameObject[] **示例** ```C# var codes = new string[] { &amp;quot;JiuJingDengElement&amp;quot;,&amp;quot;ZhongHaoShiGuanElement&amp;quot; }; var goList = EquipmentManager.CreateEquipments( codes.Select((e, i) =&amp;gt; new EquipementPreset() { Code = e, Position = BornTrans.position }).ToArray() );</code></pre> <p> &lt;a id=&quot;CreateEquipmentByCoroutine&quot;&gt;&lt;/a&gt;</p> <h3>使用协程创建单个器材</h3> <p>bool CreateEquipmentByCoroutine(EquipementPreset preset, UnityAction&lt;GameObject&gt; OnCreateCompleted)</p> <p><strong>简要说明:</strong></p> <ul> <li>使用协程创建单个器材</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">preset</td> <td style="text-align: left;">EquipementPreset</td> <td>器材信息</td> </tr> <tr> <td style="text-align: left;">OnCreateCompleted</td> <td style="text-align: left;">UnityAction&lt;GameObject&gt;</td> <td>创建完成回调,返回器材对象</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>bool:true表示立即开始创建,false表示上一个创建流程还未结束,加入任务队列中等待</p> <p><strong>示例</strong></p> <pre><code class="language-csharp">var preset = new EquipementPreset() { Code = &amp;quot;JiuJingDengElement&amp;quot; }; GameObject go; bool bSuccess = EquipmentManager.CreateEquipmentByCoroutine(preset, (GameObject obj) =&amp;gt; { go = obj; });</code></pre> <p> &lt;a id=&quot;CreateEquipmentsByCoroutine&quot;&gt;&lt;/a&gt;</p> <h3>使用协程创建多个器材</h3> <p>bool CreateEquipmentsByCoroutine(EquipementPreset[] presets, UnityAction&lt;string, GameObject&gt; OnSingleCreated, UnityAction&lt;List&lt;GameObject&gt;&gt; OnCreateCompleted)</p> <p><strong>简要说明:</strong></p> <ul> <li>使用协程创建多个器材</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">presets</td> <td style="text-align: left;">EquipementPreset[]</td> <td>器材信息列表</td> </tr> <tr> <td style="text-align: left;">OnSingleCreated</td> <td style="text-align: left;">UnityAction&lt;string, GameObject&gt;</td> <td>单个器材创建完成回调,返回器材Code和器材对象,若创建失败,则器材对象为空</td> </tr> <tr> <td style="text-align: left;">OnCreateCompleted</td> <td style="text-align: left;">UnityAction&lt;List&lt;GameObject&gt;&gt;</td> <td>创建完成回调,返回器材对象列表</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>bool:true表示立即开始创建,false表示上一个创建流程还未结束,加入任务队列中等待</p> <p><strong>示例</strong> ```C# EquipementPreset[] presets = new EquipementPreset[2]; presets[0] = new EquipementPreset() { Code = &quot;JiuJingDengElement&quot; }; presets[1] = new EquipementPreset() { Code = &quot;ZhongHaoShiGuanElement&quot; }; List&lt;GameObject&gt; goList; bool bSuccess = EquipmentManager.CreateEquipmentsByCoroutine(presets, null, (List&lt;GameObject&gt; objs) =&gt; { goList = objs; });</p> <pre><code>  &amp;lt;a id=&amp;quot;DeleteEquipmentByGuid&amp;quot;&amp;gt;&amp;lt;/a&amp;gt; ###根据guid删除单个器材 void DeleteEquipmentByGuid(string objectId, bool deleteGroupObjects) **简要说明:** - 根据guid删除单个器材 **参数:** |参数名|类型|说明| |:---- |:----- |----- | |objectId |string |器材guid| |deleteGroupObjects |bool |true :有组合器材会一起删除,false:只删除指定器材| **返回值说明** void **示例** ```C# string guid = LabObjectIdManager.Instance.GetGuid(currentEntityId); EquipmentManager.DeleteEquipmentByGuid(guid, false);</code></pre> <p> &lt;a id=&quot;DeleteEquipmentByObject&quot;&gt;&lt;/a&gt;</p> <h3>根据GameObject删除单个器材</h3> <p>void DeleteEquipmentByObject(GameObject objectTarget, bool deleteGroupObjects)</p> <p><strong>简要说明:</strong></p> <ul> <li>根据GameObject删除单个器材</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">objectTarget</td> <td style="text-align: left;">GameObject</td> <td>器材对象</td> </tr> <tr> <td style="text-align: left;">deleteGroupObjects</td> <td style="text-align: left;">bool</td> <td>true :有组合器材会一起删除,false:只删除指定器材</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>void</p> <p><strong>示例</strong> ```C# string guid = LabObjectIdManager.Instance.GetGuid(currentEntityId); var obj = LabObjectManager.Instance.GetLabObjGoByID(guid); EquipmentManager.DeleteEquipmentByObject(obj, false);</p> <pre><code>  &amp;lt;a id=&amp;quot;DeleteAllEquipments&amp;quot;&amp;gt;&amp;lt;/a&amp;gt; ###清空场景所有器材 void DeleteAllEquipments() **简要说明:** - 清空场景所有器材 **参数:** |参数名|类型|说明| |:---- |:----- |----- | |无 |无 |无| **返回值说明** void **示例** ```C# EquipmentManager.DeleteAllEquipments();</code></pre> <p> &lt;a id=&quot;SetEquipRoot&quot;&gt;&lt;/a&gt;</p> <h3>动态设置器材模型对象创建的根节点</h3> <p>void SetEquipRoot(Transform rootTrans)</p> <p><strong>简要说明:</strong></p> <ul> <li>动态设置器材模型对象创建的根节点</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">rootTrans</td> <td style="text-align: left;">Transform</td> <td>根节点</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>void</p> <p><strong>示例</strong> ```C# GameObject equipRoot = new GameObject(&quot;EquipRoot&quot;); EquipmentManager.SetEquipRoot(equipRoot.transform);</p> <pre><code>  &amp;lt;a id=&amp;quot;GetEquipPropertyFromLuaTable&amp;quot;&amp;gt;&amp;lt;/a&amp;gt; ###从场景中已创建的器材LuaTable中获取属性 object GetEquipPropertyFromLuaTable(string code, string propertyName) **简要说明:** - 从器材LuaTable中获取属性 **参数:** |参数名|类型|说明| |:---- |:----- |----- | | code | string | 器材编码 | | propertyName | string | 属性名 | **返回值说明** object 属性对象 **示例** ```C# object obj = EquipmentManager.GetEquipPropertyFromLuaTable(&amp;quot;AmpereMeterElement&amp;quot;, &amp;quot;numberName&amp;quot;);</code></pre> <p> &lt;a id=&quot;SetEquipPropertyToLuaTable&quot;&gt;&lt;/a&gt;</p> <h3>设置场景中已创建的器材LuaTable中的属性</h3> <p>void SetEquipPropertyToLuaTable(string code, string propertyName, object value)</p> <p><strong>简要说明:</strong></p> <ul> <li>设置器材LuaTable中的属性</li> </ul> <p><strong>参数:</strong></p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">code</td> <td style="text-align: left;">string</td> <td>器材编码</td> </tr> <tr> <td style="text-align: left;">propertyName</td> <td style="text-align: left;">string</td> <td>属性名</td> </tr> <tr> <td style="text-align: left;">value</td> <td style="text-align: left;">object</td> <td>属性值</td> </tr> </tbody> </table> <p><strong>返回值说明</strong></p> <p>void</p> <p><strong>示例</strong> ```C# EquipmentManager.SetEquipPropertyToLuaTable(&quot;AmpereMeterElement&quot;, &quot;formatteststringlong&quot;, &quot;11111111111111&quot;);</p> <pre><code>  &amp;lt;a id=&amp;quot;SwitchLanguage&amp;quot;&amp;gt;&amp;lt;/a&amp;gt; ###器材多语言切换 void SwitchLanguage(string languageCode) **简要说明:** - 器材多语言切换,需要本地下载的器材包含有对应的语言文件 ![](https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=3a387e558621199c25cf6156f408544c&amp;amp;file=file.png) **参数:** |参数名|类型|说明| |:---- |:----- |----- | |languageCode |string |语言编码 中文:zh_CN zh-CN 英文:en_US 阿拉伯:ar_SA ar_EG 繁体中文:zh_HK zh-HK zh-TW| **返回值说明** void **示例** ```C# var code = &amp;quot;en_US&amp;quot;; EquipmentManager.SwitchLanguage(code);</code></pre> <h1>组件扩展接口(除器材的CRUD外,如观察器材、显示器材电场线等)</h1> <p><strong> 待更新 </strong> &gt; 注:扩展能力将计划在1.5.0版本中开发(2024-1~2024-2)。</p> <p>Test.cs类中包含所有接口的测试用例。</p> <p>播放器参数(原学科设置)设置项及测试用例:</p> <pre><code class="language-csharp"> /// &amp;lt;summary&amp;gt; /// 通用设置项 /// &amp;lt;/summary&amp;gt; public void TestCommonSetting() { //显示器材读数 //【器材读数】:如显示在电压表上方的电压大小读数UI PlayerEntrySettingSimulator.Instance.Common.XianShiDuShu = true; //显示器材序号 //【器材序号】:如显示在电流表上方的“A1”序号标签UI PlayerEntrySettingSimulator.Instance.Common.XianShiXuHao = true; //显示器材损坏状态 //【损坏状态】:如电流表短路损坏时,显示在电流表上方的“!”标签UI PlayerEntrySettingSimulator.Instance.Common.XianShiXuHao = true; //显示器材读数观察窗口 //【观察窗口】:如点击电流表时,显示在屏幕正上方的电流表指针读数的放大窗口 PlayerEntrySettingSimulator.Instance.Common.XuanZhongGuanChaChuangKou = true; } /// &amp;lt;summary&amp;gt; /// 时间控制设置项 /// &amp;lt;/summary&amp;gt; public void TestTimeControlSetting() { //开启时间加速功能 PlayerEntrySettingSimulator.Instance.Time.ActiveGenericTimeControl = true; //时间加速方式 //0:固定变速倍率; 1:区间变速倍率 PlayerEntrySettingSimulator.Instance.Time.AdjustSpeedMode = 0; //区间变速倍率范围 [MinTimesSpeed , MaxTimesSpeed] PlayerEntrySettingSimulator.Instance.Time.MinTimesSpeed = 1; PlayerEntrySettingSimulator.Instance.Time.MaxTimesSpeed = 10; // 当前时间控制状态: // 0:暂停; 1:正常; 2:变速 PlayerEntrySettingSimulator.Instance.Time.TimeState = 1; //当前时间变速倍率 PlayerEntrySettingSimulator.Instance.Time.TimesSpeed = 1; //开启时间暂停功能 PlayerEntrySettingSimulator.Instance.Time.ActiveTimePauseInPlayer = true; } /// &amp;lt;summary&amp;gt; /// 化学学科设置项 /// &amp;lt;/summary&amp;gt; public void TestChemistrySetting() { //以下设置项用于点击器材时,显示在器材上方的化学数据界面数据项的设置 //显示容器温度 PlayerEntrySettingSimulator.Instance.Chemistry.XianShiWenDu = true; //显示容器所拥有的各物质的质量 PlayerEntrySettingSimulator.Instance.Chemistry.XianShiZhiLiang = true; //显示容器所拥有的各物质的摩尔质量 PlayerEntrySettingSimulator.Instance.Chemistry.XianShiMoEr = true; //显示容器所拥有的各物质的体积 PlayerEntrySettingSimulator.Instance.Chemistry.XianShiTiJi = true; //显示容器所拥有的各物质的浓度 PlayerEntrySettingSimulator.Instance.Chemistry.XianShiNongDu = true; //显示当前容器发生的化学反应的化学方程式(部分化学反应才有,如CaCO3+HCl) PlayerEntrySettingSimulator.Instance.Chemistry.XianShiHuaXueFangChengShi = true; //开启科学计数法显示数值(当数值极大或极小时,使用科学计数法显示) PlayerEntrySettingSimulator.Instance.Chemistry.ScientifiCounting = true; //科学计数法显示的小数位数 PlayerEntrySettingSimulator.Instance.Chemistry.ScientifiCountingDecimal = 2; //设置完成后需调用该接口以应用设置 PlayerSettingAdapter.ApplySettingsToPlayerCore(); } /// &amp;lt;summary&amp;gt; /// 化学学科设置项 /// &amp;lt;/summary&amp;gt; public void TestPhysicsSetting() { ///显示导线电流特效 PlayerEntrySettingSimulator.Instance.Circuit.XianShiDaoXianDianLiu = true; //显示电场线 PlayerEntrySettingSimulator.Instance.Magnetism.XianShiDianChangXian = true; //显示磁感线 PlayerEntrySettingSimulator.Instance.Magnetism.XianShiCiGanXian = true; //显示光学角度 //如使用激光笔照射半圆形玻璃砖时,可开启各光线之间的角度数值显示 PlayerEntrySettingSimulator.Instance.Optics.XianShiJiaoDu = true; //显示反射光线 PlayerEntrySettingSimulator.Instance.Optics.XianShiFanSheGuangXian = true; //设置完成后需调用该接口以应用设置 PlayerSettingAdapter.ApplySettingsToPlayerCore(); }</code></pre>

页面列表

ITEM_HTML