static int GetArmatureData(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1); string arg0 = ToLua.CheckString(L, 2); DragonBones.ArmatureData o = obj.GetArmatureData(arg0); ToLua.PushObject(L, o); return(1); } else if (count == 3) { DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); DragonBones.ArmatureData o = obj.GetArmatureData(arg0, arg1); ToLua.PushObject(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.GetArmatureData")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. /// This enables you to make a armature template so that other armature without animations can share it's animations. /// </summary> /// <param name="armature">- The armtaure.</param> /// <param name="armatureData">- The armature data.</param> /// <param name="isOverride">- Whether to completely overwrite the original animation. (Default: false)</param> /// <example> /// TypeScript style, for reference only. /// <pre> /// let armatureA = factory.buildArmature("armatureA", "dragonBonesA"); /// let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB"); /// if (armatureDataB) { /// factory.replaceAnimation(armatureA, armatureDataB); /// } /// </pre> /// </example> /// <see cref="DragonBones.Armature"/> /// <see cref="DragonBones.ArmatureData"/> /// <version>DragonBones 5.6</version> /// <language>en_US</language> /// <summary> /// - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 /// 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 /// </summary> /// <param name="armature">- 骨架。</param> /// <param name="armatureData">- 骨架数据。</param> /// <param name="isOverride">- 是否完全覆盖原来的动画。(默认: false)。</param> /// <example> /// TypeScript 风格,仅供参考。 /// <pre> /// let armatureA = factory.buildArmature("armatureA", "dragonBonesA"); /// let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB"); /// if (armatureDataB) { /// factory.replaceAnimation(armatureA, armatureDataB); /// } /// </pre> /// </example> /// <see cref="DragonBones.Armature"/> /// <see cref="DragonBones.ArmatureData"/> /// <version>DragonBones 5.6</version> /// <language>zh_CN</language> public bool ReplaceAnimation(Armature armature, ArmatureData armatureData, bool isOverride = true) { var skinData = armatureData.defaultSkin; if (skinData == null) { return(false); } if (isOverride) { armature.animation.animations = armatureData.animations; } else { var rawAnimations = armature.animation.animations; Dictionary <string, AnimationData> animations = new Dictionary <string, AnimationData>(); foreach (var k in rawAnimations.Keys) { animations[k] = rawAnimations[k]; } foreach (var k in armatureData.animations.Keys) { animations[k] = armatureData.animations[k]; } armature.animation.animations = animations; } foreach (var slot in armature.GetSlots()) { var index = 0; foreach (var display in slot.displayList) { if (display is Armature) { var displayDatas = skinData.GetDisplays(slot.name); if (displayDatas != null && index < displayDatas.Count) { var displayData = displayDatas[index]; if (displayData != null && displayData.type == DisplayType.Armature) { var childArmatureData = this.GetArmatureData(displayData.path, displayData.parent.parent.parent.name); if (childArmatureData != null) { this.ReplaceAnimation(display as Armature, childArmatureData, isOverride); } } } } } } return(true); }
static int ReplaceAnimation(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3) { DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1); DragonBones.Armature arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2); DragonBones.ArmatureData arg1 = (DragonBones.ArmatureData)ToLua.CheckObject <DragonBones.ArmatureData>(L, 3); bool o = obj.ReplaceAnimation(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 4) { DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1); DragonBones.Armature arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2); DragonBones.ArmatureData arg1 = (DragonBones.ArmatureData)ToLua.CheckObject <DragonBones.ArmatureData>(L, 3); bool arg2 = LuaDLL.luaL_checkboolean(L, 4); bool o = obj.ReplaceAnimation(arg0, arg1, arg2); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.ReplaceAnimation")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
internal UserData userData = null; // Initial value. protected override void _OnClear() { foreach (var k in this.armatures.Keys) { this.armatures[k].ReturnToPool(); } if (this.userData != null) { this.userData.ReturnToPool(); } this.autoSearch = false; this.frameRate = 0; this.version = ""; this.name = ""; this.stage = null; this.frameIndices.Clear(); this.cachedFrames.Clear(); this.armatureNames.Clear(); this.armatures.Clear(); this.binary = null; this.intArray = null; // this.floatArray = null; // this.frameIntArray = null; // this.frameFloatArray = null; // this.frameArray = null; // this.timelineArray = null; // this.userData = null; }
/// <inheritDoc/> protected override void _OnClear() { foreach (var pair in boneTimelines) { for (int i = 0; i < pair.Value.Count; ++i) { pair.Value[i].ReturnToPool(); } } foreach (var pair in slotTimelines) { for (int i = 0; i < pair.Value.Count; ++i) { pair.Value[i].ReturnToPool(); } } foreach (var pair in constraintTimelines) { for (int i = 0; i < pair.Value.Count; ++i) { pair.Value[i].ReturnToPool(); } } if (this.actionTimeline != null) { this.actionTimeline.ReturnToPool(); } if (this.zOrderTimeline != null) { this.zOrderTimeline.ReturnToPool(); } this.frameIntOffset = 0; this.frameFloatOffset = 0; this.frameOffset = 0; this.frameCount = 0; this.playTimes = 0; this.duration = 0.0f; this.scale = 1.0f; this.fadeInTime = 0.0f; this.cacheFrameRate = 0.0f; this.name = ""; this.boneTimelines.Clear(); this.slotTimelines.Clear(); this.constraintTimelines.Clear(); this.boneCachedFrameIndices.Clear(); this.slotCachedFrameIndices.Clear(); this.cachedFrames.Clear(); this.actionTimeline = null; this.zOrderTimeline = null; this.parent = null; }
/** * @private */ protected override void _OnClear() { if (this._clock != null) { // Remove clock first. this._clock.Remove(this); } foreach (var bone in this._bones) { bone.ReturnToPool(); } foreach (var slot in this._slots) { slot.ReturnToPool(); } if (this._animation != null) { this._animation.ReturnToPool(); } if (this._proxy != null) { this._proxy.DBClear(); } if (this._replaceTextureAtlasData != null) { this._replaceTextureAtlasData.ReturnToPool(); } this.inheritAnimation = true; this.armatureData = null; // this.userData = null; this._lockUpdate = false; this._bonesDirty = false; this._slotsDirty = false; this._zOrderDirty = false; this._flipX = false; this._flipY = false; this._cacheFrameIndex = -1; this._bones.Clear(); this._slots.Clear(); this._actions.Clear(); this._animation = null; // this._proxy = null; // this._display = null; this._replaceTextureAtlasData = null; this._replacedTexture = null; this._dragonBones = null; // this._clock = null; this._parent = null; }
public static void ReplaceAnimation(UnityArmatureComponent _armatureComponent, string armatureName) { _armatureComponent.armatureBaseName = armatureName; if (!string.IsNullOrEmpty(armatureName)) { string dragonBonesName = _armatureComponent.unityData.dataName; ArmatureData baseDiceArmature = UnityFactory.factory.GetArmatureData(armatureName, dragonBonesName); UnityFactory.factory.ReplaceAnimation(_armatureComponent.armature, baseDiceArmature); } }
/** * @private */ public void AddArmature(ArmatureData value) { if (this.armatures.ContainsKey(value.name)) { Helper.Assert(false, "Replace armature: " + value.name); this.armatures[value.name].ReturnToPool(); } value.parent = this; this.armatures[value.name] = value; this.armatureNames.Add(value.name); }
/** * @private */ public void AddArmature(ArmatureData value) { if (value != null && value.name != null && !armatures.ContainsKey(value.name)) { armatures[value.name] = value; _armatureNames.Add(value.name); value.parent = this; } else { DragonBones.Assert(false, DragonBones.ARGUMENT_ERROR); } }
/** * @private */ public void AddArmature(ArmatureData value) { if (value != null && value.name != null && !armatures.ContainsKey(value.name)) { armatures[value.name] = value; _armatureNames.Add(value.name); value.parent = this; } else { DragonBones.Warn(""); } }
/** * @private */ protected bool _fillBuildArmaturePackage(BuildArmaturePackage dataPackage, string dragonBonesName, string armatureName, string skinName, string textureAtlasName) { DragonBonesData dragonBonesData = null; ArmatureData armatureData = null; var isAvailableName = !string.IsNullOrEmpty(dragonBonesName); if (isAvailableName) { if (_dragonBonesDataMap.ContainsKey(dragonBonesName)) { dragonBonesData = _dragonBonesDataMap[dragonBonesName]; armatureData = dragonBonesData.GetArmature(armatureName); } } if (armatureData == null && (!isAvailableName || autoSearch)) // Will be search all data, if do not give a data name or the autoSearch is true. { foreach (var pair in _dragonBonesDataMap) { dragonBonesData = pair.Value; if (!isAvailableName || dragonBonesData.autoSearch) { armatureData = dragonBonesData.GetArmature(armatureName); if (armatureData != null) { dragonBonesName = dragonBonesData.name; break; } } } } if (armatureData != null) { dataPackage.dataName = dragonBonesName; dataPackage.textureAtlasName = textureAtlasName; dataPackage.data = dragonBonesData; dataPackage.armature = armatureData; dataPackage.skin = armatureData.GetSkin(skinName); if (dataPackage.skin == null) { dataPackage.skin = armatureData.defaultSkin; } return(true); } return(false); }
protected override void _OnClear() { foreach (var list in this.displays.Values) { foreach (var display in list) { display.ReturnToPool(); } } this.name = ""; this.displays.Clear(); this.parent = null; }
protected override void _OnClear() { base._OnClear(); foreach (var action in this.actions) { action.ReturnToPool(); } this.type = DisplayType.Armature; this.inheritAnimation = false; this.actions.Clear(); this.armature = null; }
static int AddArmature(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); DragonBones.DragonBonesData obj = (DragonBones.DragonBonesData)ToLua.CheckObject(L, 1, typeof(DragonBones.DragonBonesData)); DragonBones.ArmatureData arg0 = (DragonBones.ArmatureData)ToLua.CheckObject(L, 2, typeof(DragonBones.ArmatureData)); obj.AddArmature(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int CacheFrames(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)ToLua.CheckObject(L, 1, typeof(DragonBones.ArmatureData)); uint arg0 = (uint)LuaDLL.luaL_checknumber(L, 2); obj.CacheFrames(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetArmature(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); DragonBones.DragonBonesData obj = (DragonBones.DragonBonesData)ToLua.CheckObject(L, 1, typeof(DragonBones.DragonBonesData)); string arg0 = ToLua.CheckString(L, 2); DragonBones.ArmatureData o = obj.GetArmature(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetCacheFrame(IntPtr L) { try { ToLua.CheckArgsCount(L, 4); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)ToLua.CheckObject(L, 1, typeof(DragonBones.ArmatureData)); DragonBones.Matrix arg0 = (DragonBones.Matrix)ToLua.CheckObject(L, 2, typeof(DragonBones.Matrix)); DragonBones.Transform arg1 = (DragonBones.Transform)ToLua.CheckObject(L, 3, typeof(DragonBones.Transform)); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); obj.GetCacheFrame(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_scale(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; float ret = obj.scale; LuaDLL.lua_pushnumber(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index scale on a nil value" : e.Message)); } }
/// <internal/> /// <private/> internal void Init(ArmatureData armatureData, IArmatureProxy proxy, object display, DragonBones dragonBones) { if (this._armatureData != null) { return; } this._armatureData = armatureData; this._animation = BaseObject.BorrowObject <Animation>(); this._proxy = proxy; this._display = display; this._dragonBones = dragonBones; this._proxy.DBInit(this); this._animation.Init(this); this._animation.animations = this._armatureData.animations; }
static int get_name(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; string ret = obj.name; LuaDLL.lua_pushstring(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index name on a nil value" : e.Message)); } }
static int get_animationNames(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; System.Collections.Generic.List <string> ret = obj.animationNames; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index animationNames on a nil value" : e.Message)); } }
static int set_userData(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; DragonBones.CustomData arg0 = (DragonBones.CustomData)ToLua.CheckObject(L, 2, typeof(DragonBones.CustomData)); obj.userData = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index userData on a nil value" : e.Message)); } }
/** * @inheritDoc */ protected override void _onClear() { isRelativePivot = false; type = DisplayType.Image; name = null; texture = null; armature = null; if (mesh != null) { mesh.ReturnToPool(); mesh = null; } pivot.Clear(); transform.Identity(); }
static int get_armatureData(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.Armature obj = (DragonBones.Armature)o; DragonBones.ArmatureData ret = obj.armatureData; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index armatureData on a nil value" : e.Message)); } }
static int set_scale(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.scale = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index scale on a nil value" : e.Message)); } }
static int set__armatureData(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.Armature obj = (DragonBones.Armature)o; DragonBones.ArmatureData arg0 = (DragonBones.ArmatureData)ToLua.CheckObject <DragonBones.ArmatureData>(L, 2); obj._armatureData = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index _armatureData on a nil value")); } }
static int get_parent(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.AnimationData obj = (DragonBones.AnimationData)o; DragonBones.ArmatureData ret = obj.parent; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index parent on a nil value")); } }
static int set_name(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o; string arg0 = ToLua.CheckString(L, 2); obj.name = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index name on a nil value" : e.Message)); } }
static int SetCacheFrame(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); DragonBones.ArmatureData obj = (DragonBones.ArmatureData)ToLua.CheckObject(L, 1, typeof(DragonBones.ArmatureData)); DragonBones.Matrix arg0 = (DragonBones.Matrix)ToLua.CheckObject(L, 2, typeof(DragonBones.Matrix)); DragonBones.Transform arg1 = (DragonBones.Transform)ToLua.CheckObject(L, 3, typeof(DragonBones.Transform)); int o = obj.SetCacheFrame(arg0, arg1); LuaDLL.lua_pushinteger(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <private/> void Awake() { #if UNITY_EDITOR if (_IsPrefab()) { return; } #endif if (unityData != null && unityData.dragonBonesJSON != null && unityData.textureAtlas != null) { var dragonBonesData = UnityFactory.factory.LoadData(unityData, isUGUI); if (dragonBonesData != null && !string.IsNullOrEmpty(armatureName)) { UnityFactory.factory.BuildArmatureComponent(armatureName, unityData.dataName, null, null, gameObject, isUGUI); if (!string.IsNullOrEmpty(armatureBaseName)) { ArmatureData baseData = UnityFactory.factory.GetArmatureData(armatureBaseName, unityData.dataName); UnityFactory.factory.ReplaceAnimation(armature, baseData); } } } if (_armature != null) { #if UNITY_5_6_OR_NEWER if (!isUGUI) { _sortingGroup = GetComponent <UnityEngine.Rendering.SortingGroup>(); } #endif _UpdateSlotsSorting(); _armature.flipX = _flipX; _armature.flipY = _flipY; _armature.animation.timeScale = _timeScale; if (!string.IsNullOrEmpty(animationName)) { _armature.animation.Play(animationName, _playTimes); } } }