Slot.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. /**
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2012-2017 DragonBones team and other contributors
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  7. * this software and associated documentation files (the "Software"), to deal in
  8. * the Software without restriction, including without limitation the rights to
  9. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10. * the Software, and to permit persons to whom the Software is furnished to do so,
  11. * subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. using System;
  24. using System.Collections.Generic;
  25. namespace DragonBones
  26. {
  27. /// <summary>
  28. /// - The slot attached to the armature, controls the display status and properties of the display object.
  29. /// A bone can contain multiple slots.
  30. /// A slot can contain multiple display objects, displaying only one of the display objects at a time,
  31. /// but you can toggle the display object into frame animation while the animation is playing.
  32. /// The display object can be a normal texture, or it can be a display of a child armature, a grid display object,
  33. /// and a custom other display object.
  34. /// </summary>
  35. /// <see cref="DragonBones.Armature"/>
  36. /// <see cref="DragonBones.Bone"/>
  37. /// <see cref="DragonBones.SlotData"/>
  38. /// <version>DragonBones 3.0</version>
  39. /// <language>en_US</language>
  40. /// <summary>
  41. /// - 插槽附着在骨骼上,控制显示对象的显示状态和属性。
  42. /// 一个骨骼上可以包含多个插槽。
  43. /// 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。
  44. /// 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
  45. /// </summary>
  46. /// <see cref="DragonBones.Armature"/>
  47. /// <see cref="DragonBones.Bone"/>
  48. /// <see cref="DragonBones.SlotData"/>
  49. /// <version>DragonBones 3.0</version>
  50. /// <language>zh_CN</language>
  51. public abstract class Slot : TransformObject
  52. {
  53. /// <summary>
  54. /// - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states.
  55. /// </summary>
  56. /// <default>null</default>
  57. /// <see cref="DragonBones.AnimationState.displayControl"/>
  58. /// <see cref="DragonBones.AnimationState.name"/>
  59. /// <see cref="DragonBones.AnimationState.group"/>
  60. /// <version>DragonBones 4.5</version>
  61. /// <language>en_US</language>
  62. /// <summary>
  63. /// - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。
  64. /// </summary>
  65. /// <default>null</default>
  66. /// <see cref="DragonBones.AnimationState.displayControl"/>
  67. /// <see cref="DragonBones.AnimationState.name"/>
  68. /// <see cref="DragonBones.AnimationState.group"/>
  69. /// <version>DragonBones 4.5</version>
  70. /// <language>zh_CN</language>
  71. public string displayController;
  72. /// <private/>
  73. protected bool _displayDirty;
  74. /// <private/>
  75. protected bool _zOrderDirty;
  76. /// <private/>
  77. protected bool _visibleDirty;
  78. /// <private/>
  79. protected bool _blendModeDirty;
  80. /// <internal/>
  81. /// <private/>
  82. internal bool _colorDirty;
  83. /// <private/>
  84. internal bool _transformDirty;
  85. /// <private/>
  86. protected bool _visible;
  87. /// <private/>
  88. internal BlendMode _blendMode;
  89. /// <private/>
  90. protected int _displayIndex;
  91. /// <private/>
  92. protected int _animationDisplayIndex;
  93. /// <internal/>
  94. /// <private/>
  95. internal int _zOrder;
  96. /// <private/>
  97. protected int _cachedFrameIndex;
  98. /// <internal/>
  99. /// <private/>
  100. internal float _pivotX;
  101. /// <internal/>
  102. /// <private/>
  103. internal float _pivotY;
  104. /// <private/>
  105. protected readonly Matrix _localMatrix = new Matrix();
  106. /// <internal/>
  107. /// <private/>
  108. internal readonly ColorTransform _colorTransform = new ColorTransform();
  109. /// <private/>
  110. internal readonly List<DisplayData> _displayDatas = new List<DisplayData>();
  111. /// <private/>
  112. protected readonly List<object> _displayList = new List<object>();
  113. /// <internal/>
  114. /// <private/>
  115. internal SlotData _slotData;
  116. /// <private/>
  117. protected List<DisplayData> _rawDisplayDatas;
  118. /// <internal/>
  119. /// <private/>
  120. protected DisplayData _displayData;
  121. /// <private/>
  122. protected BoundingBoxData _boundingBoxData;
  123. /// <private/>
  124. protected TextureData _textureData;
  125. /// <internal/>
  126. public DeformVertices _deformVertices;
  127. /// <private/>
  128. protected object _rawDisplay;
  129. /// <private/>
  130. protected object _meshDisplay;
  131. /// <private/>
  132. protected object _display;
  133. /// <private/>
  134. protected Armature _childArmature;
  135. /// <private/>
  136. protected Bone _parent;
  137. /// <internal/>
  138. /// <private/>
  139. internal List<int> _cachedFrameIndices = new List<int>();
  140. public Slot()
  141. {
  142. }
  143. /// <inheritDoc/>
  144. protected override void _OnClear()
  145. {
  146. base._OnClear();
  147. var disposeDisplayList = new List<object>();
  148. for (int i = 0, l = _displayList.Count; i < l; ++i)
  149. {
  150. var eachDisplay = _displayList[i];
  151. if (eachDisplay != _rawDisplay && eachDisplay != _meshDisplay && !disposeDisplayList.Contains(eachDisplay))
  152. {
  153. disposeDisplayList.Add(eachDisplay);
  154. }
  155. }
  156. for (int i = 0, l = disposeDisplayList.Count; i < l; ++i)
  157. {
  158. var eachDisplay = disposeDisplayList[i];
  159. if (eachDisplay is Armature)
  160. {
  161. (eachDisplay as Armature).Dispose();
  162. }
  163. else
  164. {
  165. this._DisposeDisplay(eachDisplay, true);
  166. }
  167. }
  168. if (this._deformVertices != null)
  169. {
  170. this._deformVertices.ReturnToPool();
  171. }
  172. if (this._meshDisplay != null && this._meshDisplay != this._rawDisplay)
  173. {
  174. // May be _meshDisplay and _rawDisplay is the same one.
  175. this._DisposeDisplay(this._meshDisplay, false);
  176. }
  177. if (this._rawDisplay != null)
  178. {
  179. this._DisposeDisplay(this._rawDisplay, false);
  180. }
  181. this.displayController = null;
  182. this._displayDirty = false;
  183. this._zOrderDirty = false;
  184. this._blendModeDirty = false;
  185. this._colorDirty = false;
  186. this._transformDirty = false;
  187. this._visible = true;
  188. this._blendMode = BlendMode.Normal;
  189. this._displayIndex = -1;
  190. this._animationDisplayIndex = -1;
  191. this._zOrder = 0;
  192. this._cachedFrameIndex = -1;
  193. this._pivotX = 0.0f;
  194. this._pivotY = 0.0f;
  195. this._localMatrix.Identity();
  196. this._colorTransform.Identity();
  197. this._displayList.Clear();
  198. this._displayDatas.Clear();
  199. this._slotData = null; //
  200. this._rawDisplayDatas = null; //
  201. this._displayData = null;
  202. this._boundingBoxData = null;
  203. this._textureData = null;
  204. this._deformVertices = null;
  205. this._rawDisplay = null;
  206. this._meshDisplay = null;
  207. this._display = null;
  208. this._childArmature = null;
  209. this._parent = null;
  210. this._cachedFrameIndices = null;
  211. }
  212. /// <private/>
  213. protected abstract void _InitDisplay(object value, bool isRetain);
  214. /// <private/>
  215. protected abstract void _DisposeDisplay(object value, bool isRelease);
  216. /// <private/>
  217. protected abstract void _OnUpdateDisplay();
  218. /// <private/>
  219. protected abstract void _AddDisplay();
  220. /// <private/>
  221. protected abstract void _ReplaceDisplay(object value);
  222. /// <private/>
  223. protected abstract void _RemoveDisplay();
  224. /// <private/>
  225. protected abstract void _UpdateZOrder();
  226. /// <private/>
  227. internal abstract void _UpdateVisible();
  228. /// <private/>
  229. internal abstract void _UpdateBlendMode();
  230. /// <private/>
  231. protected abstract void _UpdateColor();
  232. /// <private/>
  233. protected abstract void _UpdateFrame();
  234. /// <private/>
  235. protected abstract void _UpdateMesh();
  236. /// <private/>
  237. protected abstract void _UpdateTransform();
  238. /// <private/>
  239. protected abstract void _IdentityTransform();
  240. /// <summary>
  241. /// - Support default skin data.
  242. /// </summary>
  243. /// <private/>
  244. protected DisplayData _GetDefaultRawDisplayData(int displayIndex)
  245. {
  246. var defaultSkin = this._armature._armatureData.defaultSkin;
  247. if (defaultSkin != null)
  248. {
  249. var defaultRawDisplayDatas = defaultSkin.GetDisplays(this._slotData.name);
  250. if (defaultRawDisplayDatas != null)
  251. {
  252. return displayIndex < defaultRawDisplayDatas.Count ? defaultRawDisplayDatas[displayIndex] : null;
  253. }
  254. }
  255. return null;
  256. }
  257. /// <private/>
  258. protected void _UpdateDisplayData()
  259. {
  260. var prevDisplayData = this._displayData;
  261. var prevVerticesData = this._deformVertices != null ? this._deformVertices.verticesData : null;
  262. var prevTextureData = this._textureData;
  263. DisplayData rawDisplayData = null;
  264. VerticesData currentVerticesData = null;
  265. this._displayData = null;
  266. this._boundingBoxData = null;
  267. this._textureData = null;
  268. if (this._displayIndex >= 0)
  269. {
  270. if (this._rawDisplayDatas != null)
  271. {
  272. rawDisplayData = this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;
  273. }
  274. if (rawDisplayData == null)
  275. {
  276. rawDisplayData = this._GetDefaultRawDisplayData(this._displayIndex);
  277. }
  278. if (this._displayIndex < this._displayDatas.Count)
  279. {
  280. this._displayData = this._displayDatas[this._displayIndex];
  281. }
  282. }
  283. // Update texture and mesh data.
  284. if (this._displayData != null)
  285. {
  286. if (this._displayData.type == DisplayType.Mesh)
  287. {
  288. currentVerticesData = (this._displayData as MeshDisplayData).vertices;
  289. }
  290. else if (this._displayData.type == DisplayType.Path)
  291. {
  292. currentVerticesData = (this._displayData as PathDisplayData).vertices;
  293. }
  294. else if (rawDisplayData != null)
  295. {
  296. if (rawDisplayData.type == DisplayType.Mesh)
  297. {
  298. currentVerticesData = (rawDisplayData as MeshDisplayData).vertices;
  299. }
  300. else if (rawDisplayData.type == DisplayType.Path)
  301. {
  302. currentVerticesData = (rawDisplayData as PathDisplayData).vertices;
  303. }
  304. }
  305. if (this._displayData.type == DisplayType.BoundingBox)
  306. {
  307. this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox;
  308. }
  309. else if (rawDisplayData != null)
  310. {
  311. if (rawDisplayData.type == DisplayType.BoundingBox)
  312. {
  313. this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox;
  314. }
  315. }
  316. if (this._displayData.type == DisplayType.Image)
  317. {
  318. this._textureData = (this._displayData as ImageDisplayData).texture;
  319. }
  320. else if (this._displayData.type == DisplayType.Mesh)
  321. {
  322. this._textureData = (this._displayData as MeshDisplayData).texture;
  323. }
  324. }
  325. if (this._displayData != prevDisplayData || currentVerticesData != prevVerticesData || this._textureData != prevTextureData)
  326. {
  327. // Update pivot offset.
  328. if (currentVerticesData == null && this._textureData != null)
  329. {
  330. var imageDisplayData = this._displayData as ImageDisplayData;
  331. var scale = this._textureData.parent.scale * this._armature._armatureData.scale;
  332. var frame = this._textureData.frame;
  333. this._pivotX = imageDisplayData.pivot.x;
  334. this._pivotY = imageDisplayData.pivot.y;
  335. var rect = frame != null ? frame : this._textureData.region;
  336. var width = rect.width;
  337. var height = rect.height;
  338. if (this._textureData.rotated && frame == null)
  339. {
  340. width = rect.height;
  341. height = rect.width;
  342. }
  343. this._pivotX *= width * scale;
  344. this._pivotY *= height * scale;
  345. if (frame != null)
  346. {
  347. this._pivotX += frame.x * scale;
  348. this._pivotY += frame.y * scale;
  349. }
  350. // Update replace pivot. TODO
  351. if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData)
  352. {
  353. rawDisplayData.transform.ToMatrix(Slot._helpMatrix);
  354. Slot._helpMatrix.Invert();
  355. Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
  356. this._pivotX -= Slot._helpPoint.x;
  357. this._pivotY -= Slot._helpPoint.y;
  358. this._displayData.transform.ToMatrix(Slot._helpMatrix);
  359. Slot._helpMatrix.Invert();
  360. Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
  361. this._pivotX += Slot._helpPoint.x;
  362. this._pivotY += Slot._helpPoint.y;
  363. }
  364. if (!DragonBones.yDown)
  365. {
  366. this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY;
  367. }
  368. }
  369. else
  370. {
  371. this._pivotX = 0.0f;
  372. this._pivotY = 0.0f;
  373. }
  374. // Update original transform.
  375. if (rawDisplayData != null)
  376. {
  377. // Compatible.
  378. this.origin = rawDisplayData.transform;
  379. }
  380. else if (this._displayData != null)
  381. {
  382. // Compatible.
  383. this.origin = this._displayData.transform;
  384. }
  385. else
  386. {
  387. this.origin = null;
  388. }
  389. // Update vertices.
  390. if (currentVerticesData != prevVerticesData)
  391. {
  392. if (this._deformVertices == null)
  393. {
  394. this._deformVertices = BaseObject.BorrowObject<DeformVertices>();
  395. }
  396. this._deformVertices.init(currentVerticesData, this._armature);
  397. }
  398. else if (this._deformVertices != null && this._textureData != prevTextureData)
  399. {
  400. // Update mesh after update frame.
  401. this._deformVertices.verticesDirty = true;
  402. }
  403. this._displayDirty = true;
  404. this._transformDirty = true;
  405. }
  406. }
  407. /// <private/>
  408. protected void _UpdateDisplay()
  409. {
  410. var prevDisplay = this._display != null ? this._display : this._rawDisplay;
  411. var prevChildArmature = this._childArmature;
  412. // Update display and child armature.
  413. if (this._displayIndex >= 0 && this._displayIndex < this._displayList.Count)
  414. {
  415. this._display = this._displayList[this._displayIndex];
  416. if (this._display != null && this._display is Armature)
  417. {
  418. this._childArmature = this._display as Armature;
  419. this._display = this._childArmature.display;
  420. }
  421. else
  422. {
  423. this._childArmature = null;
  424. }
  425. }
  426. else
  427. {
  428. this._display = null;
  429. this._childArmature = null;
  430. }
  431. // Update display.
  432. var currentDisplay = this._display != null ? this._display : this._rawDisplay;
  433. if (currentDisplay != prevDisplay)
  434. {
  435. this._OnUpdateDisplay();
  436. this._ReplaceDisplay(prevDisplay);
  437. this._transformDirty = true;
  438. this._visibleDirty = true;
  439. this._blendModeDirty = true;
  440. this._colorDirty = true;
  441. }
  442. // Update frame.
  443. if (currentDisplay == this._rawDisplay || currentDisplay == this._meshDisplay)
  444. {
  445. this._UpdateFrame();
  446. }
  447. // Update child armature.
  448. if (this._childArmature != prevChildArmature)
  449. {
  450. if (prevChildArmature != null)
  451. {
  452. // Update child armature parent.
  453. prevChildArmature._parent = null;
  454. prevChildArmature.clock = null;
  455. if (prevChildArmature.inheritAnimation)
  456. {
  457. prevChildArmature.animation.Reset();
  458. }
  459. }
  460. if (this._childArmature != null)
  461. {
  462. // Update child armature parent.
  463. this._childArmature._parent = this;
  464. this._childArmature.clock = this._armature.clock;
  465. if (this._childArmature.inheritAnimation)
  466. {
  467. // Set child armature cache frameRate.
  468. if (this._childArmature.cacheFrameRate == 0)
  469. {
  470. var cacheFrameRate = this._armature.cacheFrameRate;
  471. if (cacheFrameRate != 0)
  472. {
  473. this._childArmature.cacheFrameRate = cacheFrameRate;
  474. }
  475. }
  476. // Child armature action.
  477. List<ActionData> actions = null;
  478. if (this._displayData != null && this._displayData.type == DisplayType.Armature)
  479. {
  480. actions = (this._displayData as ArmatureDisplayData).actions;
  481. }
  482. else if (this._displayIndex >= 0 && this._rawDisplayDatas != null)
  483. {
  484. var rawDisplayData = this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;
  485. if (rawDisplayData == null)
  486. {
  487. rawDisplayData = this._GetDefaultRawDisplayData(this._displayIndex);
  488. }
  489. if (rawDisplayData != null && rawDisplayData.type == DisplayType.Armature)
  490. {
  491. actions = (rawDisplayData as ArmatureDisplayData).actions;
  492. }
  493. }
  494. if (actions != null && actions.Count > 0)
  495. {
  496. foreach (var action in actions)
  497. {
  498. var eventObject = BaseObject.BorrowObject<EventObject>();
  499. EventObject.ActionDataToInstance(action, eventObject, this._armature);
  500. eventObject.slot = this;
  501. this._armature._BufferAction(eventObject, false);
  502. }
  503. }
  504. else
  505. {
  506. this._childArmature.animation.Play();
  507. }
  508. }
  509. }
  510. }
  511. }
  512. /// <private/>
  513. protected void _UpdateGlobalTransformMatrix(bool isCache)
  514. {
  515. this.globalTransformMatrix.CopyFrom(this._localMatrix);
  516. this.globalTransformMatrix.Concat(this._parent.globalTransformMatrix);
  517. if (isCache)
  518. {
  519. this.global.FromMatrix(this.globalTransformMatrix);
  520. }
  521. else
  522. {
  523. this._globalDirty = true;
  524. }
  525. }
  526. /// <internal/>
  527. /// <private/>
  528. internal bool _SetDisplayIndex(int value, bool isAnimation = false)
  529. {
  530. if (isAnimation)
  531. {
  532. if (this._animationDisplayIndex == value)
  533. {
  534. return false;
  535. }
  536. this._animationDisplayIndex = value;
  537. }
  538. if (this._displayIndex == value)
  539. {
  540. return false;
  541. }
  542. this._displayIndex = value;
  543. this._displayDirty = true;
  544. this._UpdateDisplayData();
  545. return this._displayDirty;
  546. }
  547. /// <internal/>
  548. /// <private/>
  549. internal bool _SetZorder(int value)
  550. {
  551. if (this._zOrder == value)
  552. {
  553. //return false;
  554. }
  555. this._zOrder = value;
  556. this._zOrderDirty = true;
  557. return this._zOrderDirty;
  558. }
  559. /// <internal/>
  560. /// <private/>
  561. internal bool _SetColor(ColorTransform value)
  562. {
  563. this._colorTransform.CopyFrom(value);
  564. this._colorDirty = true;
  565. return this._colorDirty;
  566. }
  567. /// <internal/>
  568. /// <private/>
  569. internal bool _SetDisplayList(List<object> value)
  570. {
  571. if (value != null && value.Count > 0)
  572. {
  573. if (this._displayList.Count != value.Count)
  574. {
  575. this._displayList.ResizeList(value.Count);
  576. }
  577. for (int i = 0, l = value.Count; i < l; ++i)
  578. {
  579. // Retain input render displays.
  580. var eachDisplay = value[i];
  581. if (eachDisplay != null &&
  582. eachDisplay != this._rawDisplay &&
  583. eachDisplay != this._meshDisplay &&
  584. !(eachDisplay is Armature) && this._displayList.IndexOf(eachDisplay) < 0)
  585. {
  586. this._InitDisplay(eachDisplay, true);
  587. }
  588. this._displayList[i] = eachDisplay;
  589. }
  590. }
  591. else if (this._displayList.Count > 0)
  592. {
  593. this._displayList.Clear();
  594. }
  595. if (this._displayIndex >= 0 && this._displayIndex < this._displayList.Count)
  596. {
  597. this._displayDirty = this._display != this._displayList[this._displayIndex];
  598. }
  599. else
  600. {
  601. this._displayDirty = this._display != null;
  602. }
  603. this._UpdateDisplayData();
  604. return this._displayDirty;
  605. }
  606. /// <internal/>
  607. /// <private/>
  608. internal virtual void Init(SlotData slotData, Armature armatureValue, object rawDisplay, object meshDisplay)
  609. {
  610. if (this._slotData != null)
  611. {
  612. return;
  613. }
  614. this._slotData = slotData;
  615. //
  616. this._visibleDirty = true;
  617. this._blendModeDirty = true;
  618. this._colorDirty = true;
  619. this._blendMode = this._slotData.blendMode;
  620. this._zOrder = this._slotData.zOrder;
  621. this._colorTransform.CopyFrom(this._slotData.color);
  622. this._rawDisplay = rawDisplay;
  623. this._meshDisplay = meshDisplay;
  624. this._armature = armatureValue;
  625. var slotParent = this._armature.GetBone(this._slotData.parent.name);
  626. if (slotParent != null)
  627. {
  628. this._parent = slotParent;
  629. }
  630. else
  631. {
  632. // Never;
  633. }
  634. this._armature._AddSlot(this);
  635. //
  636. this._InitDisplay(this._rawDisplay, false);
  637. if (this._rawDisplay != this._meshDisplay)
  638. {
  639. this._InitDisplay(this._meshDisplay, false);
  640. }
  641. this._OnUpdateDisplay();
  642. this._AddDisplay();
  643. //
  644. // this.rawDisplayDatas = displayDatas; // TODO
  645. }
  646. /// <internal/>
  647. /// <private/>
  648. internal void Update(int cacheFrameIndex)
  649. {
  650. if (this._displayDirty)
  651. {
  652. this._displayDirty = false;
  653. this._UpdateDisplay();
  654. // TODO remove slot
  655. if (this._transformDirty)
  656. {
  657. // Update local matrix. (Only updated when both display and transform are dirty.)
  658. if (this.origin != null)
  659. {
  660. this.global.CopyFrom(this.origin).Add(this.offset).ToMatrix(this._localMatrix);
  661. }
  662. else
  663. {
  664. this.global.CopyFrom(this.offset).ToMatrix(this._localMatrix);
  665. }
  666. }
  667. }
  668. if (this._zOrderDirty)
  669. {
  670. this._zOrderDirty = false;
  671. this._UpdateZOrder();
  672. }
  673. if (cacheFrameIndex >= 0 && this._cachedFrameIndices != null)
  674. {
  675. var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex];
  676. if (cachedFrameIndex >= 0 && this._cachedFrameIndex == cachedFrameIndex)
  677. {
  678. // Same cache.
  679. this._transformDirty = false;
  680. }
  681. else if (cachedFrameIndex >= 0)
  682. {
  683. // Has been Cached.
  684. this._transformDirty = true;
  685. this._cachedFrameIndex = cachedFrameIndex;
  686. }
  687. else if (this._transformDirty || this._parent._childrenTransformDirty)
  688. {
  689. // Dirty.
  690. this._transformDirty = true;
  691. this._cachedFrameIndex = -1;
  692. }
  693. else if (this._cachedFrameIndex >= 0)
  694. {
  695. // Same cache, but not set index yet.
  696. this._transformDirty = false;
  697. this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex;
  698. }
  699. else
  700. {
  701. // Dirty.
  702. this._transformDirty = true;
  703. this._cachedFrameIndex = -1;
  704. }
  705. }
  706. else if (this._transformDirty || this._parent._childrenTransformDirty)
  707. {
  708. // Dirty.
  709. cacheFrameIndex = -1;
  710. this._transformDirty = true;
  711. this._cachedFrameIndex = -1;
  712. }
  713. if (this._display == null)
  714. {
  715. return;
  716. }
  717. if (this._visibleDirty)
  718. {
  719. this._visibleDirty = false;
  720. this._UpdateVisible();
  721. }
  722. if (this._blendModeDirty)
  723. {
  724. this._blendModeDirty = false;
  725. this._UpdateBlendMode();
  726. }
  727. if (this._colorDirty)
  728. {
  729. this._colorDirty = false;
  730. this._UpdateColor();
  731. }
  732. if (this._deformVertices != null && this._deformVertices.verticesData != null && this._display == this._meshDisplay)
  733. {
  734. var isSkinned = this._deformVertices.verticesData.weight != null;
  735. if (this._deformVertices.verticesDirty ||
  736. (isSkinned && this._deformVertices.isBonesUpdate()))
  737. {
  738. this._deformVertices.verticesDirty = false;
  739. this._UpdateMesh();
  740. }
  741. if (isSkinned)
  742. {
  743. // Compatible.
  744. return;
  745. }
  746. }
  747. if (this._transformDirty)
  748. {
  749. this._transformDirty = false;
  750. if (this._cachedFrameIndex < 0)
  751. {
  752. var isCache = cacheFrameIndex >= 0;
  753. this._UpdateGlobalTransformMatrix(isCache);
  754. if (isCache && this._cachedFrameIndices != null)
  755. {
  756. this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.SetCacheFrame(this.globalTransformMatrix, this.global);
  757. }
  758. }
  759. else
  760. {
  761. this._armature._armatureData.GetCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex);
  762. }
  763. this._UpdateTransform();
  764. }
  765. }
  766. /// <private/>
  767. public void UpdateTransformAndMatrix()
  768. {
  769. if (this._transformDirty)
  770. {
  771. this._transformDirty = false;
  772. this._UpdateGlobalTransformMatrix(false);
  773. }
  774. }
  775. /// <private/>
  776. internal void ReplaceDisplayData(DisplayData value, int displayIndex = -1)
  777. {
  778. if (displayIndex < 0)
  779. {
  780. if (this._displayIndex < 0)
  781. {
  782. displayIndex = 0;
  783. }
  784. else
  785. {
  786. displayIndex = this._displayIndex;
  787. }
  788. }
  789. if (this._displayDatas.Count <= displayIndex)
  790. {
  791. this._displayDatas.ResizeList(displayIndex + 1);
  792. for (int i = 0, l = this._displayDatas.Count; i < l; ++i)
  793. {
  794. // Clean undefined.
  795. this._displayDatas[i] = null;
  796. }
  797. }
  798. this._displayDatas[displayIndex] = value;
  799. }
  800. /// <summary>
  801. /// - Check whether a specific point is inside a custom bounding box in the slot.
  802. /// The coordinate system of the point is the inner coordinate system of the armature.
  803. /// Custom bounding boxes need to be customized in Dragonbones Pro.
  804. /// </summary>
  805. /// <param name="x">- The horizontal coordinate of the point.</param>
  806. /// <param name="y">- The vertical coordinate of the point.</param>
  807. /// <version>DragonBones 5.0</version>
  808. /// <language>en_US</language>
  809. /// <summary>
  810. /// - 检查特定点是否在插槽的自定义边界框内。
  811. /// 点的坐标系为骨架内坐标系。
  812. /// 自定义边界框需要在 DragonBones Pro 中自定义。
  813. /// </summary>
  814. /// <param name="x">- 点的水平坐标。</param>
  815. /// <param name="y">- 点的垂直坐标。</param>
  816. /// <version>DragonBones 5.0</version>
  817. /// <language>zh_CN</language>
  818. public bool ContainsPoint(float x, float y)
  819. {
  820. if (this._boundingBoxData == null)
  821. {
  822. return false;
  823. }
  824. this.UpdateTransformAndMatrix();
  825. Slot._helpMatrix.CopyFrom(this.globalTransformMatrix);
  826. Slot._helpMatrix.Invert();
  827. Slot._helpMatrix.TransformPoint(x, y, Slot._helpPoint);
  828. return this._boundingBoxData.ContainsPoint(Slot._helpPoint.x, Slot._helpPoint.y);
  829. }
  830. /// <summary>
  831. /// - Check whether a specific segment intersects a custom bounding box for the slot.
  832. /// The coordinate system of the segment and intersection is the inner coordinate system of the armature.
  833. /// Custom bounding boxes need to be customized in Dragonbones Pro.
  834. /// </summary>
  835. /// <param name="xA">- The horizontal coordinate of the beginning of the segment.</param>
  836. /// <param name="yA">- The vertical coordinate of the beginning of the segment.</param>
  837. /// <param name="xB">- The horizontal coordinate of the end point of the segment.</param>
  838. /// <param name="yB">- The vertical coordinate of the end point of the segment.</param>
  839. /// <param name="intersectionPointA">- The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)</param>
  840. /// <param name="intersectionPointB">- The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)</param>
  841. /// <param name="normalRadians">- The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)</param>
  842. /// <returns>Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections]</returns>
  843. /// <version>DragonBones 5.0</version>
  844. /// <language>en_US</language>
  845. /// <summary>
  846. /// - 检查特定线段是否与插槽的自定义边界框相交。
  847. /// 线段和交点的坐标系均为骨架内坐标系。
  848. /// 自定义边界框需要在 DragonBones Pro 中自定义。
  849. /// </summary>
  850. /// <param name="xA">- 线段起点的水平坐标。</param>
  851. /// <param name="yA">- 线段起点的垂直坐标。</param>
  852. /// <param name="xB">- 线段终点的水平坐标。</param>
  853. /// <param name="yB">- 线段终点的垂直坐标。</param>
  854. /// <param name="intersectionPointA">- 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点)</param>
  855. /// <param name="intersectionPointB">- 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点)</param>
  856. /// <param name="normalRadians">- 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线)</param>
  857. /// <returns>相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点]</returns>
  858. /// <version>DragonBones 5.0</version>
  859. /// <language>zh_CN</language>
  860. public int IntersectsSegment(float xA, float yA, float xB, float yB,
  861. Point intersectionPointA = null,
  862. Point intersectionPointB = null,
  863. Point normalRadians = null)
  864. {
  865. if (this._boundingBoxData == null)
  866. {
  867. return 0;
  868. }
  869. this.UpdateTransformAndMatrix();
  870. Slot._helpMatrix.CopyFrom(this.globalTransformMatrix);
  871. Slot._helpMatrix.Invert();
  872. Slot._helpMatrix.TransformPoint(xA, yA, Slot._helpPoint);
  873. xA = Slot._helpPoint.x;
  874. yA = Slot._helpPoint.y;
  875. Slot._helpMatrix.TransformPoint(xB, yB, Slot._helpPoint);
  876. xB = Slot._helpPoint.x;
  877. yB = Slot._helpPoint.y;
  878. var intersectionCount = this._boundingBoxData.IntersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians);
  879. if (intersectionCount > 0)
  880. {
  881. if (intersectionCount == 1 || intersectionCount == 2)
  882. {
  883. if (intersectionPointA != null)
  884. {
  885. this.globalTransformMatrix.TransformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA);
  886. if (intersectionPointB != null)
  887. {
  888. intersectionPointB.x = intersectionPointA.x;
  889. intersectionPointB.y = intersectionPointA.y;
  890. }
  891. }
  892. else if (intersectionPointB != null)
  893. {
  894. this.globalTransformMatrix.TransformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB);
  895. }
  896. }
  897. else
  898. {
  899. if (intersectionPointA != null)
  900. {
  901. this.globalTransformMatrix.TransformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA);
  902. }
  903. if (intersectionPointB != null)
  904. {
  905. this.globalTransformMatrix.TransformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB);
  906. }
  907. }
  908. if (normalRadians != null)
  909. {
  910. this.globalTransformMatrix.TransformPoint((float)Math.Cos(normalRadians.x), (float)Math.Sin(normalRadians.x), Slot._helpPoint, true);
  911. normalRadians.x = (float)Math.Atan2(Slot._helpPoint.y, Slot._helpPoint.x);
  912. this.globalTransformMatrix.TransformPoint((float)Math.Cos(normalRadians.y), (float)Math.Sin(normalRadians.y), Slot._helpPoint, true);
  913. normalRadians.y = (float)Math.Atan2(Slot._helpPoint.y, Slot._helpPoint.x);
  914. }
  915. }
  916. return intersectionCount;
  917. }
  918. /// <summary>
  919. /// - Forces the slot to update the state of the display object in the next frame.
  920. /// </summary>
  921. /// <version>DragonBones 4.5</version>
  922. /// <language>en_US</language>
  923. /// <summary>
  924. /// - 强制插槽在下一帧更新显示对象的状态。
  925. /// </summary>
  926. /// <version>DragonBones 4.5</version>
  927. /// <language>zh_CN</language>
  928. public void InvalidUpdate()
  929. {
  930. this._displayDirty = true;
  931. this._transformDirty = true;
  932. }
  933. /// <summary>
  934. /// - The visible of slot's display object.
  935. /// </summary>
  936. /// <default>true</default>
  937. /// <version>DragonBones 5.6</version>
  938. /// <language>en_US</language>
  939. /// <summary>
  940. /// - 插槽的显示对象的可见。
  941. /// </summary>
  942. /// <default>true</default>
  943. /// <version>DragonBones 5.6</version>
  944. /// <language>zh_CN</language>
  945. public bool visible
  946. {
  947. get { return this._visible; }
  948. set
  949. {
  950. if (this._visible == value)
  951. {
  952. return;
  953. }
  954. this._visible = value;
  955. this._UpdateVisible();
  956. }
  957. }
  958. /// <summary>
  959. /// - The index of the display object displayed in the display list.
  960. /// </summary>
  961. /// <example>
  962. /// TypeScript style, for reference only.
  963. /// <pre>
  964. /// let slot = armature.getSlot("weapon");
  965. /// slot.displayIndex = 3;
  966. /// slot.displayController = "none";
  967. /// </pre>
  968. /// </example>
  969. /// <version>DragonBones 4.5</version>
  970. /// <language>en_US</language>
  971. /// <summary>
  972. /// - 此时显示的显示对象在显示列表中的索引。
  973. /// </summary>
  974. /// <example>
  975. /// TypeScript 风格,仅供参考。
  976. /// <pre>
  977. /// let slot = armature.getSlot("weapon");
  978. /// slot.displayIndex = 3;
  979. /// slot.displayController = "none";
  980. /// </pre>
  981. /// </example>
  982. /// <version>DragonBones 4.5</version>
  983. /// <language>zh_CN</language>
  984. public int displayIndex
  985. {
  986. get { return this._displayIndex; }
  987. set
  988. {
  989. if (this._SetDisplayIndex(value))
  990. {
  991. this.Update(-1);
  992. }
  993. }
  994. }
  995. /// <summary>
  996. /// - The slot name.
  997. /// </summary>
  998. /// <see cref="DragonBones.SlotData.name"/>
  999. /// <version>DragonBones 3.0</version>
  1000. /// <language>en_US</language>
  1001. /// <summary>
  1002. /// - 插槽名称。
  1003. /// </summary>
  1004. /// <see cref="DragonBones.SlotData.name"/>
  1005. /// <version>DragonBones 3.0</version>
  1006. /// <language>zh_CN</language>
  1007. public string name
  1008. {
  1009. get { return this._slotData.name; }
  1010. }
  1011. /// <summary>
  1012. /// - Contains a display list of display objects or child armatures.
  1013. /// </summary>
  1014. /// <version>DragonBones 3.0</version>
  1015. /// <language>en_US</language>
  1016. /// <summary>
  1017. /// - 包含显示对象或子骨架的显示列表。
  1018. /// </summary>
  1019. /// <version>DragonBones 3.0</version>
  1020. /// <language>zh_CN</language>
  1021. public List<object> displayList
  1022. {
  1023. get { return new List<object>(_displayList.ToArray()); }
  1024. set
  1025. {
  1026. var backupDisplayList = _displayList.ToArray(); // Copy.
  1027. var disposeDisplayList = new List<object>();
  1028. if (this._SetDisplayList(value))
  1029. {
  1030. this.Update(-1);
  1031. }
  1032. // Release replaced displays.
  1033. foreach (var eachDisplay in backupDisplayList)
  1034. {
  1035. if (eachDisplay != null &&
  1036. eachDisplay != this._rawDisplay &&
  1037. eachDisplay != this._meshDisplay &&
  1038. this._displayList.IndexOf(eachDisplay) < 0 &&
  1039. disposeDisplayList.IndexOf(eachDisplay) < 0)
  1040. {
  1041. disposeDisplayList.Add(eachDisplay);
  1042. }
  1043. }
  1044. foreach (var eachDisplay in disposeDisplayList)
  1045. {
  1046. if (eachDisplay is Armature)
  1047. {
  1048. // (eachDisplay as Armature).Dispose();
  1049. }
  1050. else
  1051. {
  1052. this._DisposeDisplay(eachDisplay, true);
  1053. }
  1054. }
  1055. }
  1056. }
  1057. /// <summary>
  1058. /// - The slot data.
  1059. /// </summary>
  1060. /// <see cref="DragonBones.SlotData"/>
  1061. /// <version>DragonBones 4.5</version>
  1062. /// <language>en_US</language>
  1063. /// <summary>
  1064. /// - 插槽数据。
  1065. /// </summary>
  1066. /// <see cref="DragonBones.SlotData"/>
  1067. /// <version>DragonBones 4.5</version>
  1068. /// <language>zh_CN</language>
  1069. public SlotData slotData
  1070. {
  1071. get { return this._slotData; }
  1072. }
  1073. /// <private/>
  1074. public List<DisplayData> rawDisplayDatas
  1075. {
  1076. get { return this._rawDisplayDatas; }
  1077. set
  1078. {
  1079. if (this._rawDisplayDatas == value)
  1080. {
  1081. return;
  1082. }
  1083. this._displayDirty = true;
  1084. this._rawDisplayDatas = value;
  1085. if (this._rawDisplayDatas != null)
  1086. {
  1087. this._displayDatas.ResizeList(this._rawDisplayDatas.Count);
  1088. for (int i = 0, l = this._displayDatas.Count; i < l; ++i)
  1089. {
  1090. var rawDisplayData = this._rawDisplayDatas[i];
  1091. if (rawDisplayData == null)
  1092. {
  1093. rawDisplayData = this._GetDefaultRawDisplayData(i);
  1094. }
  1095. this._displayDatas[i] = rawDisplayData;
  1096. }
  1097. }
  1098. else
  1099. {
  1100. this._displayDatas.Clear();
  1101. }
  1102. }
  1103. }
  1104. /// <summary>
  1105. /// - The custom bounding box data for the slot at current time.
  1106. /// </summary>
  1107. /// <version>DragonBones 5.0</version>
  1108. /// <language>en_US</language>
  1109. /// <summary>
  1110. /// - 插槽此时的自定义包围盒数据。
  1111. /// </summary>
  1112. /// <version>DragonBones 5.0</version>
  1113. /// <language>zh_CN</language>
  1114. public BoundingBoxData boundingBoxData
  1115. {
  1116. get { return this._boundingBoxData; }
  1117. }
  1118. /// <private/>
  1119. public object rawDisplay
  1120. {
  1121. get { return this._rawDisplay; }
  1122. }
  1123. /// <private/>
  1124. public object meshDisplay
  1125. {
  1126. get { return this._meshDisplay; }
  1127. }
  1128. /// <summary>
  1129. /// - The display object that the slot displays at this time.
  1130. /// </summary>
  1131. /// <example>
  1132. /// TypeScript style, for reference only.
  1133. /// <pre>
  1134. /// let slot = armature.getSlot("text");
  1135. /// slot.display = new yourEngine.TextField();
  1136. /// </pre>
  1137. /// </example>
  1138. /// <version>DragonBones 3.0</version>
  1139. /// <language>en_US</language>
  1140. /// <summary>
  1141. /// - 插槽此时显示的显示对象。
  1142. /// </summary>
  1143. /// <example>
  1144. /// TypeScript 风格,仅供参考。
  1145. /// <pre>
  1146. /// let slot = armature.getSlot("text");
  1147. /// slot.display = new yourEngine.TextField();
  1148. /// </pre>
  1149. /// </example>
  1150. /// <version>DragonBones 3.0</version>
  1151. /// <language>zh_CN</language>
  1152. public object display
  1153. {
  1154. get { return this._display; }
  1155. set
  1156. {
  1157. if (this._display == value)
  1158. {
  1159. return;
  1160. }
  1161. var displayListLength = this._displayList.Count;
  1162. if (this._displayIndex < 0 && displayListLength == 0)
  1163. {
  1164. // Emprty.
  1165. this._displayIndex = 0;
  1166. }
  1167. if (this._displayIndex < 0)
  1168. {
  1169. return;
  1170. }
  1171. else
  1172. {
  1173. var replaceDisplayList = this.displayList; // Copy.
  1174. if (displayListLength <= this._displayIndex)
  1175. {
  1176. replaceDisplayList.ResizeList(this._displayIndex + 1);
  1177. }
  1178. replaceDisplayList[this._displayIndex] = value;
  1179. this.displayList = replaceDisplayList;
  1180. }
  1181. }
  1182. }
  1183. /// <summary>
  1184. /// - The child armature that the slot displayed at current time.
  1185. /// </summary>
  1186. /// <example>
  1187. /// TypeScript style, for reference only.
  1188. /// <pre>
  1189. /// let slot = armature.getSlot("weapon");
  1190. /// let prevChildArmature = slot.childArmature;
  1191. /// if (prevChildArmature) {
  1192. /// prevChildArmature.dispose();
  1193. /// }
  1194. /// slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
  1195. /// </pre>
  1196. /// </example>
  1197. /// <version>DragonBones 3.0</version>
  1198. /// <language>en_US</language>
  1199. /// <summary>
  1200. /// - 插槽此时显示的子骨架。
  1201. /// 注意,被替换的对象并不会被回收,根据语言和引擎的不同,需要额外处理。
  1202. /// </summary>
  1203. /// <example>
  1204. /// TypeScript 风格,仅供参考。
  1205. /// <pre>
  1206. /// let slot = armature.getSlot("weapon");
  1207. /// let prevChildArmature = slot.childArmature;
  1208. /// if (prevChildArmature) {
  1209. /// prevChildArmature.dispose();
  1210. /// }
  1211. /// slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
  1212. /// </pre>
  1213. /// </example>
  1214. /// <version>DragonBones 3.0</version>
  1215. /// <language>zh_CN</language>
  1216. public Armature childArmature
  1217. {
  1218. get { return this._childArmature; }
  1219. set
  1220. {
  1221. if (this._childArmature == value)
  1222. {
  1223. return;
  1224. }
  1225. this.display = value;
  1226. }
  1227. }
  1228. /// <summary>
  1229. /// - The parent bone to which it belongs.
  1230. /// </summary>
  1231. /// <version>DragonBones 3.0</version>
  1232. /// <language>en_US</language>
  1233. /// <summary>
  1234. /// - 所属的父骨骼。
  1235. /// </summary>
  1236. /// <version>DragonBones 3.0</version>
  1237. /// <language>zh_CN</language>
  1238. public Bone parent
  1239. {
  1240. get { return this._parent; }
  1241. }
  1242. }
  1243. }