dragonbones / dragonbonescsharp Goto Github PK
View Code? Open in Web Editor NEWDragonBones C# Runtime
License: MIT License
DragonBones C# Runtime
License: MIT License
This is a suggestion rather than a major issue, however I spent the last few hours scratching my head over why Unity was showing my DragonBones animations incorrectly but was fine in the DragonBones application.
By default Unity imports textures at 2048x2048 (for desktop), however DragonBones has options to export to 4096x4096 and 8192x8192.
If I wanted to create a build for multiple platforms which might have texture restraints, or simply to improve performance on lower end machines, I might want to use a smaller texture and let Unity handle that when building for specific platforms.
As such I propose that when exporting the JSON files from DragonBones, texture UVs are used instead of absolute texture coordinates (e.g. x: 512, y:512 becomes x: 0.25, y: 0.25 on a 2048x2048 size image). This way even if the texture is scaled down, the texture coordinates still map correctly to the mesh.
最新的Unity代码ReplaceSlotDisplay一个非网格的Slot之后会看不见,网格的才可以看见。demo里的Ubbie就可以复现
在实际项目中,创建了多个龙骨实例,通过SetActive去控制显示隐藏,发现即便隐藏的UnityArmatureComponent挂载的物件,对应的animations依然在worldClock中进行更新,建议进行相关调整,谢谢!
Hello!
I am wondering what is the proper way to change DisplayIndex of a slot via API. For instance, I have several hairstyles or hats for my character and would like to swap them on the fly via code. Intuitively I use
_hairstyleSlot.displayIndex = INDEX;
But this value will be overriden back to default when next frame of animation will be played because of
var displayIndex = _currentFrame.displayIndex;
if (_playState >= 0 && slot.displayIndex != displayIndex)
{
slot._setDisplayIndex(displayIndex);
}
in timeline slot _onArriveAtFrame();
As far as I've understood from sources, every slot's frame now has its display index set, even if it isn't specified in the DragonBones editor:
protected SlotFrameData _parseSlotFrame(Dictionary<string, object> rawData, uint frameStart, uint frameCount)
{
var frame = BaseObject.BorrowObject<SlotFrameData>();
frame.displayIndex = _getNumber(rawData, DISPLAY_INDEX, 0);
And even if slot is not animated, the default timeline will be created nevertheless, with one frame effectively setting displayIndex to default one.
So, the question is - am I missing something? What is the proper way to set DisplayIndex from my code so it wont be changed back to default value on next playback of animation
Kind regards,
Serj
P.S. if you interested, so far to resolve this in a quick and dirty manner I just patched source code by adding new slot bool property displayIndexIsControlledByApi so if it is raised, the animation code wont change displayIndex at all
Image sorting in animation does not appear to be preserved in game, especially if any billboarding is happening. Manually configuring the depth sorting layers in my armature appears not to work because changing the sort order on the top level parent will reset all child objects instead of appending an offset.
proposed Solution expose
DEPTH index offset (default 0)
DEPTH z offset (default 0.0F)
Which provides in between spacing for your animation parts. Unless there's a workaround I don't know about.
Hi! Can I play an animation from code if I created it from the editor and saved as prefab?
Why if I use code like that I got and NullRefrenceException?
dgb.GetComponent<UnityArmatureComponent>().animation.Play("Calm");
Or I must define data from code to make unit animated?
Does anybody know how to create animation timestamp events (like in unity animations) and/or how to access animation %progress variable? I know how to subscribe to an event that happens at the end of the animation but no idea how to get one in the middle (or at specific frame)
编译时有个小错误 UnityTextureData
Object.DestroyImmediate(material);
Object.Destroy(metrial);//此处变量名错误
然后编辑器条件下各个demo运行成功,编译导出Webplayer后,运行所有动画都不能正常运行。
是否有支持4.7的老版本呢
我使用ulua,将DragonBones的c#类导出,在cs中可以正常播放的代码,在lua中实现就不会正常播放。
UnityFactory.factory.LoadDragonBonesData("410/Animations/NewProject/NewProject_ske");
UnityFactory.factory.LoadTextureAtlasData("410/Animations/NewProject/NewProject_tex");
armatureComponent = UnityFactory.factory.BuildArmatureComponent(isFemale ? "Armaturenv" : "Armature", "NewProject");
armatureComponent.transform.SetParent(this.transform);
armatureComponent.sortingLayerName = "Anim";
armatureComponent.transform.localPosition = new Vector3(0, 0, 0);
armatureComponent.transform.localScale = new Vector3(100, 100, 100);
armatureComponent.AddEventListener(EventObject.FRAME_EVENT, _frameEventHandler);
armatureComponent.AddEventListener(EventObject.COMPLETE, _animationEventHandler);
armatureComponent.animation.Play(null, 1);
lua代码
UnityFactory.factory:LoadDragonBonesData("410/Animations/NewProject/NewProject_ske","NewProject",1)
UnityFactory.factory:LoadTextureAtlasData("410/Animations/NewProject/NewProject_tex","NewProject",1)
this.armatureComponent_Hu = UnityFactory.factory:BuildArmatureComponent(isFemale and "Armaturenv" or "Armature","NewProject","NewProject_ske","NewProject_tex",nil)
this.armatureComponent_Hu.transform:SetParent(this.Armature_Hu.transform)
this.armatureComponent_Hu.sortingLayerName = "Anim"
this.armatureComponent_Hu.transform.localPosition = Vector3.zero
this.armatureComponent_Hu.transform.localScale = Vector3.New(100,100,100)
this.armatureComponent_Hu.animation:Play("newAnimation",1)
在Unity编辑器中,UnityArmatureComponent组件的Animation显示Stop(即认为是播放状态了),但是画面是不动的,感觉想是卡在那里,而且不能正常结束。 这时(playing状态)在编辑器中切换其他Armature 再切换回来,就可以正常播放了。怎么回事呢?
播放的原理不是很清楚,可能是那边设置有问题吗
NullReferenceException: Object reference not set to an instance of an object
DragonBones.UnityTextureData._GetUIMaterial (BlendMode blendMode) (at Assets/DragonBones/Scripts/unity/UnityTextureAtlasData.cs:171)
设置的混合模式为叠加的时候。在unity里运行就会出现这个错。
Hello, on DragonBones features page, it mentions animation mixing using layers (normal weighting) and groups (additive weighting).
Can someone shed a light on how to use these features ?
I do know there are parameters for them in DragonBone.Animation.FadeIn
method, but I'm not exactly sure how to use them.
Also, I see no option for animation layers or groups in DragonBonesPro Editor.
I'd really appreciate any help, since I'm getting pretty desperate because of lack of documentations.
Thanks in advance !
之前和reload相关的函数调用后悔出现动画错乱。现在按inspector面板里的reload直接就报错了。不知是不是我操作的问题。
导入的UGUI层的bones动画不会动,Create->Armature(UGUI),但如果非UGUI的是会动的。
1.layer也设置好了,相机没有问题,在Scene场景能看到
2.是在canvas下面并且层级正确
Hi i was wondering if there was a way to create ragdolls with DB armature in unity
Thanks!
I can't work out how to move the position of an ik target (e.g. to follow the mouse)
public UnityArmatureComponent character;
void Update () {
Bone ik = character.armature.GetBone("Head").ik;
// How to transform position of ik???
}
2017/12/01的版本,匯入Unity後骨頭不會轉動,導至綁定在手腳的Clidder無法正確運作,在舊版的是沒問題的。
I use Dragon bones 4.9.5 and Unity 5.5.0p3. I import armature demo from application's welcome page. I export it with default settings. I create an empty unity projects. i import demo files to this project. demo scenes work. i create an empty scene in this project. i create Dragonbones/armature object. i set DragonBones Data of this armature as Resources/BirdAndCentaur/skeleton. it works. i set DragonBones Data as Dragon_ske (from Armature Demo). it creates all parts as disabled. there is no material on those parts. it looks runtime works for skeleton files with version 2.3 (demo files)
在不确定的时候 播放时候时出现如下错误
` if (this.displayControl)
{
for (int i = 0, l = this._slotTimelines.Count; i < l; ++i)
{
var timeline = this._slotTimelines[i];
var displayController = timeline.slot.displayController; //此处timeline.slot == null
if (
displayController == null ||
displayController == this.name ||
displayController == this.group
)
{
if (timeline.playState <= 0)
{
timeline.Update(time);
}
}
}
}`
正在寻找必现的方法 如果找到了 跟帖上传
in this function:
public UnityArmatureComponent BuildArmatureComponent(string armatureName, string dragonBonesName = null, string skinName = null, string textureAtlasName = null, GameObject gameObject = null,bool isUGUI=false);
How to make more than one skin in DragonBonesPro Editor?
(I can only change the export json file to make it work.)
while, I also can not find the way to change a suit of pictures for one skeleton
I want change the color of the armature like this
UnityDragonBonesData dragonBoneData = (UnityDragonBonesData)Instantiate(Resources.Load("xxx_Data"));
UnityFactory.factory.LoadData(dragonBoneData);
body = UnityFactory.factory.BuildArmatureComponent("armatureName");
for (int i = 0; i < body.sortedSlots.Count; i++)
{
body.sortedSlots[i].skinSlotData.slot.color.alphaMultiplier = 0.1f;
}
But it does not work immediately, just have effect on the next time creating the Armature in the Unity Editor.
I guess it calls the wrong api some where for Editor or I used in a wrong way :(
Hi there,
I have created a simple animation using Dragonbone pro, now when I want to use that animation in unity it stuck on last frame in another word no animation is played but stack on one frame.
Here is the code I use:
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DragonBones;
public class Player : MonoBehaviour {
private UnityArmatureComponent player;
// Use this for initialization
void Start () {
player = this.gameObject.GetComponent<UnityArmatureComponent>();
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.LeftArrow)) {
player.animation.Play ("walk", -1);
} else if(Input.GetKey(KeyCode.LeftArrow)){
player.animation.Play ("walk", -1);
} else {
player.animation.Play ("stand", -1);
}
}
}
`
Any help is much appreciated.
UnityFactory.factory.LoadDragonBonesData("Ubbie/Ubbie"); // DragonBones file path (without suffix)
UnityFactory.factory.LoadTextureAtlasData("Ubbie/texture"); //Texture atlas file path (without suffix)
你们的demo里倒是有最新的API引用,好歹在帮助文档里改一下啊。
最新的da9229e版本
将骨骼对象放在舞台中, 运行游戏, 停止运行, 所有骨骼会丢失坐标重叠在一起, 同时console会报很多错误
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.EditorGUIUtility.TempContent (System.String[] texts) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIUtilityBindings.gen.cs:313)
UnityEditor.EditorGUI.Popup (Rect position, System.String label, Int32 selectedIndex, System.String[] displayedOptions, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorGUIBindings.gen.cs:570)
UnityEditor.EditorGUILayout.Popup (System.String label, Int32 selectedIndex, System.String[] displayedOptions, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:6194)
UnityEditor.EditorGUILayout.Popup (System.String label, Int32 selectedIndex, System.String[] displayedOptions, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:6187)
DragonBones.UnityArmatureEditor.OnInspectorGUI () (at Assets/DragonBones/unity/Editor/UnityEditor.cs:215)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1235)
UnityEditor.DockArea:OnGUI()
错误信息如下
IndexOutOfRangeException: Array index is out of range.
DragonBones.SlotColorTimelineState._OnArriveAtFrame () (at Assets/Scripts/DragonBones/animation/TimelineState.cs:682)
DragonBones.TimelineState.Update (Single passedTime) (at Assets/Scripts/DragonBones/animation/BaseTimelineState.cs:220)
DragonBones.SlotColorTimelineState.Update (Single passedTime) (at Assets/Scripts/DragonBones/animation/TimelineState.cs:755)
DragonBones.AnimationState.AdvanceTime (Single passedTime, Single cacheFrameRate) (at Assets/Scripts/DragonBones/animation/AnimationState.cs:833)
DragonBones.Animation.AdvanceTime (Single passedTime) (at Assets/Scripts/DragonBones/animation/Animation.cs:185)
DragonBones.Armature.AdvanceTime (Single passedTime) (at Assets/Scripts/DragonBones/armature/Armature.cs:365)
DragonBones.WorldClock.AdvanceTime (Single passedTime) (at Assets/Scripts/DragonBones/animation/WorldClock.cs:96)
DragonBones.DragonBones.AdvanceTime (Single passedTime) (at Assets/Scripts/DragonBones/core/DragonBones.cs:284)
DragonBones.ClockHandler.Update () (at Assets/Scripts/DragonBones/unity/UnityFactory.cs:16)
以前是没问题的,更新后部分动画无法正常播放
是在龙骨中制作动画时要注意什么吗
AnimationState.cs中,_OnClear的时候,_poseTimelines这个列表没有clear。如果这时候,有新的AnimationState从池中获取timeline时,刚好这个timeline存在与这个_poseTimelines列表中,而旧的AnimationState被复用后,就会导致两个AnimationState都持有这个timeline,复用的AnimationState如果对timeline调用了ReturnToPool,新的AnimationState中的timeline就会出错了。
float layer should be int layer.
the float is compared to an int with "==" later.
Though called from FadeIn from Line 426, layer is still an int.
As title says, this problem occurs only after I switch rooms, after getting some debug info I got this messages. I tried with demos, but the same error occurs. I tried both methods to build the UnityArmatureComponent, by runtime or by getting it an already created UnityArmatureComponent,
it actually works on the editor but if you export it in the first case nothing is shown in the second case the base body is loaded but no animation are played.
有的动画IK支持没问题,大多数动画有IK支持出现错位的情况。Unity5.6.0f3有问题,我用5.4.4也一样。还有去掉IK就正常
Hello!
First of all, I'd like to thank you for making such an amazing project available free of charge -- it has every single feature gamedev needs. The only thing that prevents it from taking deserved attention is a small amount of English documentation.
I picked it to use for my game and I'd like to contribute my experience to help other people using DragonBones with Unity. Wiki is an excellent choice for collaborative documentation writing.
Could you please consider enabling wiki section on this repo?
Hi there,
I have character with three animation states (idle [when it’s on the ground], onAir[when it jumps], landing[when it first touch the ground]) I want to make the character play the “landing” animation just once before going back to idle Animation; the problem is I can’t find any method for that, there is one isCompleted but I don’t know how does it work.
so, basically how do i play landing animation just and then keep playing idle animation.
Here is there code I use:
`//RaycastHit2D hit;
float distance = 0.2f;
Vector2 dir = new Vector2(0, -1);
Debug.DrawRay (transform.position, dir * distance, Color.cyan);
RaycastHit2D hit = Physics2D.Raycast(transform.position,dir,distance,rayMask);
if ( hit.collider != null )
{
Debug.Log( "player is on the Ground!");
if (player.animation.isPlaying && player.animation.lastAnimationName != "idle") {
player.animation.Play ("idle", -1);
}
}else{
Debug.Log( "player is in the Air!");
if (player.animation.isPlaying && player.animation.lastAnimationName != "onAir") {
player.animation.Play ("onAir", -1);
}
}
`
Many thanks in advance.
请教一下,我看到 UnityDragonBonesData 中有一个方法叫做 RemoveFromFactory,这个方法需要用户手动调用吗?
如果有多份 UnityDragonBonesData 共享了相同的纹理,其中一份释放后,纹理也就释放了。那么 factory 中剩余的 UnityDragonBonesData 该如何处理?
armature.eventDispatcher.AddEventListener(EventObject.START, onEvent);
armature.eventDispatcher.AddEventListener(EventObject.FRAME_EVENT, onEvent);
EventObject.START works, but EventObject.FRAME_EVENT never works with or without event keyframe set in animation
mac unity 5.6.1
i see dragon bone is free and open source , im looking up source in github, where is it? i cant find DragonBone Pro source code
在动画帧事件中,使用ReplaceSlotDisplay替换图片资源,替换后的位置偏移Bug,有什么办法可以规避呢?被替换的插槽资源是在运动的,想要整体往上偏移一点点。
或者说 怎么调整 Slot的位置,往上偏移,并且作用于整个Slot的动画中。
http://developer.egret.com/cn/github/egret-docs/DB/dbLibs/replaceTexture/index.html
这个链接中描述的是整个换资源包,我想要局部替换资源,所有资源都打在一个png里。
I export armature data from DB pro 4.9.5. Older armature data seems to work fine.
When I create an DB object onto the unity stage and then switch to an armature, I get Unity editor error
NullReferenceException: Object reference not set to an instance of an object
DragonBones.Slot._update (Int32 cacheFrameIndex) (at Assets/Scripts/DragonBones/armature/Slot.cs:708)
DragonBones.Armature.AdvanceTime (Single passedTime) (at Assets/Scripts/DragonBones/armature/Armature.cs:468)
DragonBones.UnityArmatureEditor.OnSceneGUI () (at Assets/Scripts/DragonBones/unity/Editor/UnityEditor.cs:471)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.SceneView.CallOnSceneGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2034)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1381)
UnityEditor.SceneView.OnGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1218)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
hi there seems to be an issue with z ordering i have to bump it to 2 for it to look correct, please advise.
If my camera is orthographic and perpendicular to the object it looks ok, but if i rotate like 10 on x you can see the z ordering a bit messed up.
im experimenting with dragonbones pro to create animations to use in unity. i created an animation and exported it as the default hoping it would work in unity. come to find out i need DragonBonesCsharp. So, not knowing what else to do i downloaded the zip file and selected only the folders and copy/pasted them into the dragonbonespro folder, saved my project and restarted the program. when i attempted to export again, i noticed that there was not an option to export for unity as i assumed there would be. do i need the .gitignore file in there? did i select the wrong folder destination? do i need to hit a button within a menu in the program? or is it something that i dont know enough to factor in?
UnityFactory.factory.LoadDragonBonesData("Ubbie/Ubbie"); // DragonBones file path (without suffix)
UnityFactory.factory.LoadTextureAtlasData("Ubbie/texture"); //Texture atlas file path (without suffix)
these functions have become obselete... how do i use the LoadData?
Can someone who know DragonBonesCsharp please make an effort to make a useful Tutorial.. T
This one doesnt work for me ,
https://www.youtube.com/watch?v=NoDR7iCnExw
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.