Ver código fonte

更新龙骨动画

jet 8 anos atrás
pai
commit
345be6bdc6

+ 3 - 2
Assets/Resource/DragonBones/DragonBones/src/DragonBones/armature/Armature.cs

@@ -15,7 +15,6 @@ namespace DragonBones
      */
     public class Armature : BaseObject, IAnimateble
     {
-		public UnityEngine.Transform UnityTransform;
 
         private static int _onSortSlots(Slot a, Slot b)
         {
@@ -27,6 +26,8 @@ namespace DragonBones
          * @default true
          * @version DragonBones 4.5
          */
+		public UnityEngine.Transform UnityTransform;
+
         public bool inheritAnimation;
         /**
          * @language zh_CN
@@ -70,7 +71,7 @@ namespace DragonBones
         /**
          * @private
          */
-        internal Slot _parent;
+		public Slot _parent;
         private WorldClock _clock;
         /**
          * @private

+ 3 - 1
Assets/Resource/DragonBones/DragonBones/src/DragonBones/armature/Slot.cs

@@ -636,13 +636,15 @@ namespace DragonBones
         /**
          * @private
          */
+		public UnityEngine.Transform UnityTransform;
+
         internal void _init(SkinSlotData skinSlotData, object rawDisplay, object meshDisplay)
         {
             if (_skinSlotData != null)
             {
                 return;
             }
-
+				
             _skinSlotData = skinSlotData;
 
             var slotData = _skinSlotData.slot;

+ 19 - 8
Assets/Resource/DragonBones/DragonBones/src/DragonBones/factory/BaseFactory.cs

@@ -182,7 +182,7 @@ namespace DragonBones
         /**
          * @private
          */
-        protected void _buildSlots(BuildArmaturePackage dataPackage, Armature armature)
+		protected void _buildSlots(BuildArmaturePackage dataPackage, Armature armature, bool asUAC)
         {
             var currentSkin = dataPackage.skin;
             var defaultSkin = dataPackage.armature.defaultSkin;
@@ -212,11 +212,22 @@ namespace DragonBones
 
                 var skinSlotData = skinSlotDatas[slotData.name];
                 var slot = _generateSlot(dataPackage, skinSlotData, armature);
-                if (slot != null)
-                {
-                    armature.AddSlot(slot, slotData.parent.name);
-                    slot._setDisplayIndex(slotData.displayIndex);
-                }
+				if (slot != null) {
+					armature.AddSlot (slot, slotData.parent.name);
+
+					if(!asUAC)
+					{
+						armature.UnityTransform = slot.UnityTransform;
+						UnityEngine.Debug.Log (armature.UnityTransform.name);
+					}
+					else if (slot.UnityTransform.parent.name == dataPackage.armature.name) {
+						armature.UnityTransform = slot.UnityTransform.parent;
+						UnityEngine.Debug.Log (armature.UnityTransform.name);
+					}
+				} else 
+				{
+					UnityEngine.Debug.LogError (dataPackage.armature.name);
+				}
             }
         }
         /**
@@ -516,14 +527,14 @@ namespace DragonBones
          * @see DragonBones.Armature
          * @version DragonBones 3.0
          */
-        public Armature BuildArmature(string armatureName, string dragonBonesName = null, string skinName = null, string textureAtlasName = null)
+		public Armature BuildArmature(string armatureName, string dragonBonesName = null, string skinName = null, string textureAtlasName = null, bool asUAC = false)
         {
             var dataPackage = new BuildArmaturePackage();
             if (_fillBuildArmaturePackage(dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName))
             {
                 var armature = _generateArmature(dataPackage);
                 _buildBones(dataPackage, armature);
-                _buildSlots(dataPackage, armature);
+				_buildSlots(dataPackage, armature, asUAC);
 
                 armature.InvalidUpdate(null, true);
                 armature.AdvanceTime(0.0f); // Update armature pose.

+ 7 - 6
Assets/Resource/DragonBones/Unity/src/DragonBones/unity/UnityFactory.cs

@@ -99,7 +99,7 @@ namespace DragonBones
             {
                 armatureComponent = armatureDisplay.AddComponent<UnityArmatureComponent>();
             }
-
+			//Debug.Log (armatureDisplay.transform.name);
             armatureComponent._armature = armature;
 
             armature._init(
@@ -109,8 +109,6 @@ namespace DragonBones
 
             _armatureGameObject = null;
 
-			armature.UnityTransform = _gameObject.transform;
-
             return armature;
         }
         /**
@@ -129,17 +127,20 @@ namespace DragonBones
             if (gameObject == null)
             {
                 gameObject = new GameObject(slotData.name);
-                gameObject.AddComponent<MeshRenderer>();
+				//Debug.Log (gameObject.transform.name);
+				gameObject.AddComponent<MeshRenderer>();
                 gameObject.AddComponent<MeshFilter>();
             }
+//			Debug.LogWarning (gameObject.transform.name);	
+			slot.UnityTransform = gameObject.transform; 
 
             slot._init(
                 skinSlotData,
                 gameObject,
                 gameObject
             );
-
-            for (int i = 0, l = skinSlotData.displays.Count; i < l; ++i) 
+            
+			for (int i = 0, l = skinSlotData.displays.Count; i < l; ++i) 
 			{
                 var displayData = skinSlotData.displays[i];
                 switch (displayData.type)

+ 139 - 82
Assets/Script/Object/Player.cs

@@ -394,27 +394,31 @@ public class Player : Regist , IPointerClickHandler
     private string Dress;
     private string Mouse;
     private string HeadWear;
+//	private string LeftLongSleeve;
+//	private string LeftShortSleeve;
+//	private string RightLongSleeve;
+//	private string RightShortSleeve;
     private string TempClose;
 
-    public DragonBones.Slot NeckSlot;
-    public DragonBones.Slot LeftHandSlot;
-    public DragonBones.Slot RightHandSlot;
-    public DragonBones.Slot LeftLegSlot;
-    public DragonBones.Slot RightLegSlot;
-	public DragonBones.Slot LeftLongSleeveSlot;
-	public DragonBones.Slot LeftShortSleeveSlot;
-	public DragonBones.Slot RightLongSleeveSlot;
-	public DragonBones.Slot RightShortSleeveSlot;
-
-    public DragonBones.Slot EyeSlot;
-    public DragonBones.Slot TopSlot;
-    public DragonBones.Slot HeadSlot;
-    public DragonBones.Slot DressSlot;
-    public DragonBones.Slot WingSlot;
-    public DragonBones.Slot MouseSlot;
-    public DragonBones.Slot LeftShoeSlot;
-    public DragonBones.Slot RightShoeSlot;
-    public DragonBones.Slot HeadWearSlot;
+	public Armature NeckSlot;
+	public Armature LeftHandSlot;
+	public Armature RightHandSlot;
+	public Armature LeftLegSlot;
+	public Armature RightLegSlot;
+	public Armature LeftLongSleeveSlot;
+	public Armature LeftShortSleeveSlot;
+	public Armature RightLongSleeveSlot;
+	public Armature RightShortSleeveSlot;
+
+	public Armature EyeArmature;
+	public Armature TopArmature;
+	public Armature HeadArmature;
+	public Armature DressArmature;
+	public Armature WingArmature;
+	public Armature MouseArmature;
+	public Armature LeftShoeArmature;
+	public Armature RightShoeArmature;
+	public Armature HeadWearArmature;
 
     public UnityArmatureComponent UAC;
 
@@ -816,16 +820,16 @@ public class Player : Regist , IPointerClickHandler
 		LeftShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子左");
 		RightLongSleeveSlot = UAC.armature.GetSlot("长袖右9");
 		RightShortSleeveSlot = UAC.armature.GetSlot("上衣1袖子右");
-		//Debug.Log (LeftLongSleeveSlot);
-        EyeSlot = UAC.armature.GetSlot("眼睛");
-        TopSlot = UAC.armature.GetSlot("上衣");
-        HeadSlot = UAC.armature.GetSlot("脑壳");
-        WingSlot = UAC.armature.GetSlot("翅膀");
-        DressSlot = UAC.armature.GetSlot("裙子");
-        MouseSlot = UAC.armature.GetSlot("嘴巴");
-        LeftShoeSlot = UAC.armature.GetSlot("鞋子左");
-        RightShoeSlot = UAC.armature.GetSlot("鞋子右");
-        HeadWearSlot = UAC.armature.GetSlot("头饰品");
+		
+        EyeArmature = UAC.armature.GetSlot("眼睛");
+        TopArmature = UAC.armature.GetSlot("上衣");
+        HeadArmature = UAC.armature.GetSlot("脑壳");
+        WingArmature = UAC.armature.GetSlot("翅膀");
+        DressArmature = UAC.armature.GetSlot("裙子");
+        MouseArmature = UAC.armature.GetSlot("嘴巴");
+        LeftShoeArmature = UAC.armature.GetSlot("鞋子左");
+        RightShoeArmature = UAC.armature.GetSlot("鞋子右");
+        HeadWearArmature = UAC.armature.GetSlot("头饰品");
 
 		ChangeClose(BodyPart.LeftLongSleeve, "Empty", false);
 		ChangeClose(BodyPart.LeftShortSleeve, "Empty", false);
@@ -840,6 +844,8 @@ public class Player : Regist , IPointerClickHandler
         ChangeClose(BodyPart.Mouse, "嘴巴1", false);
         ChangeClose(BodyPart.Headwear, "头饰品1", false);
 
+		//Debug.LogError("123");
+
         return UAC;
     }
 
@@ -893,49 +899,92 @@ public class Player : Regist , IPointerClickHandler
 
     public void ResetDepth()
     {
-        UAC.transform.SetLZ(2.5f);
-        
-        if (Wing != "Empty")
-        {
-            transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
-        }
-
-        transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
-        transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
-        transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
-        transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
-
-        Transform tempTra = transform.FindChild("Armature/" + Head);
-        
-        tempTra.SetLZ(0);
-        if (tempTra.childCount > 1)
-        {
-            tempTra.GetChild(0).SetLZ(0.002f);
-            tempTra.GetChild(1).SetLZ(0f);
-        }
-
-
-        tempTra = transform.FindChild("Armature/" + Dress);
-
-        tempTra.SetLZ(-0.002f);
-        if (tempTra.childCount > 1)
-        {
-            tempTra.GetChild(0).SetLZ(0.002f);
-            tempTra.GetChild(1).SetLZ(0f);
-        }
-
-
-        tempTra = transform.FindChild("Armature/" + Shoe);
-        tempTra.SetLZ(-0.001f);
-
-        transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
-
-
-        transform.FindChild("Armature/左腿").SetLZ(0);
-        transform.FindChild("Armature/右腿").SetLZ(0);
-        transform.FindChild("Armature/脖子").SetLZ(0.001f);
-        transform.FindChild("Armature/左手").SetLZ(-0.001f);
-        transform.FindChild("Armature/右手").SetLZ(-0.001f);
+		UAC.transform.SetLZ(2.5f);
+
+//		WingSlot.UnityTransform.SetLZ(0.003f);
+//
+//		EyeSlot.UnityTransform.SetLZ(-0.001f);
+//		TopSlot.UnityTransform.SetLZ(-0.003f);
+//		MouseSlot.UnityTransform.SetLZ(-0.001f);
+//		HeadWearSlot.UnityTransform.SetLZ(-0.001f);
+//
+//		HeadSlot.UnityTransform.SetLZ(0);
+//		if (HeadSlot.UnityTransform.childCount > 1)
+//		{
+//			HeadSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
+//			HeadSlot.UnityTransform.GetChild(1).SetLZ(0f);
+//		}
+//			
+//		DressSlot.UnityTransform.SetLZ(-0.002f);
+//		if (DressSlot.UnityTransform.childCount > 1)
+//		{
+//			DressSlot.UnityTransform.GetChild(0).SetLZ(0.002f);
+//			DressSlot.UnityTransform.GetChild(1).SetLZ(0f);
+//		}
+//			
+//		LeftShoeSlot.UnityTransform.SetLZ(-0.001f);
+//		RightShoeSlot.UnityTransform.SetLZ(-0.001f);
+//
+//		LeftLegSlot.UnityTransform.SetLZ(0);
+//		RightLegSlot.UnityTransform.SetLZ(0);
+//		NeckSlot.UnityTransform.SetLZ(0.001f);
+//		LeftHandSlot.UnityTransform.SetLZ(-0.001f);
+//		RightHandSlot.UnityTransform.SetLZ(-0.001f);
+//
+//		LeftLongSleeveSlot.UnityTransform.SetLZ(-0.0015f);
+//		LeftShortSleeveSlot.UnityTransform.SetLZ(-0.0015f);
+//		RightLongSleeveSlot.UnityTransform.SetLZ(-0.0015f);
+//		RightShortSleeveSlot.UnityTransform.SetLZ(-0.0015f);
+
+//		Debug.Log (LeftLongSleeveSlot.armature.UnityTransform.name);
+//		Debug.Log (LeftShortSleeveSlot.armature.UnityTransform.name);
+//		Debug.Log (RightLongSleeveSlot.armature.UnityTransform.name);
+//		Debug.Log (RightShortSleeveSlot.armature.UnityTransform.name);
+
+		//
+//        UAC.transform.SetLZ(2.5f);
+//        
+//        if (Wing != "Empty")
+//        {
+//            transform.FindChild("Armature/" + Wing).SetLZ(0.003f);
+//        }
+//
+//        transform.FindChild("Armature/" + Eye).SetLZ(-0.001f);
+//        transform.FindChild("Armature/" + Top).SetLZ(-0.003f);
+//        transform.FindChild("Armature/" + Mouse).SetLZ(-0.001f);
+//        transform.FindChild("Armature/" + HeadWear).SetLZ(-0.001f);
+//
+//        Transform tempTra = transform.FindChild("Armature/" + Head);
+//        
+//        tempTra.SetLZ(0);
+//        if (tempTra.childCount > 1)
+//        {
+//            tempTra.GetChild(0).SetLZ(0.002f);
+//            tempTra.GetChild(1).SetLZ(0f);
+//        }
+//
+//
+//        tempTra = transform.FindChild("Armature/" + Dress);
+//
+//        tempTra.SetLZ(-0.002f);
+//        if (tempTra.childCount > 1)
+//        {
+//            tempTra.GetChild(0).SetLZ(0.002f);
+//            tempTra.GetChild(1).SetLZ(0f);
+//        }
+//
+//
+//        tempTra = transform.FindChild("Armature/" + Shoe);
+//        tempTra.SetLZ(-0.001f);
+//
+//        transform.FindChild("Armature").GetChild(tempTra.GetSiblingIndex() + 1).SetLZ(-0.001f);
+//
+//
+//        transform.FindChild("Armature/左腿").SetLZ(0);
+//        transform.FindChild("Armature/右腿").SetLZ(0);
+//        transform.FindChild("Armature/脖子").SetLZ(0.001f);
+//        transform.FindChild("Armature/左手").SetLZ(-0.001f);
+//        transform.FindChild("Armature/右手").SetLZ(-0.001f);
     }
 
     public void ChangeClose(BodyPart bodyPart, string armatureName, bool setDepth = true)
@@ -947,26 +996,26 @@ public class Player : Regist , IPointerClickHandler
         {
             Eye = armatureName;
 
-            slotList.Add(EyeSlot);
+            slotList.Add(EyeArmature);
         }
         else if (bodyPart == BodyPart.Top)
         {
             Top = armatureName;
 
-            slotList.Add(TopSlot);
+            slotList.Add(TopArmature);
         }
         else if (bodyPart == BodyPart.Shoe)
         {
             Shoe = armatureName;
 
-            slotList.Add(LeftShoeSlot);
-            slotList.Add(RightShoeSlot);
+            slotList.Add(LeftShoeArmature);
+            slotList.Add(RightShoeArmature);
         }
         else if (bodyPart == BodyPart.Head)
         {
             Head = armatureName;
 
-            slotList.Add(HeadSlot);
+            slotList.Add(HeadArmature);
         }
         else if (bodyPart == BodyPart.Wing)
         {
@@ -978,26 +1027,26 @@ public class Player : Regist , IPointerClickHandler
             {
                 Wing = armatureName;
 
-                slotList.Add(WingSlot);
+                slotList.Add(WingArmature);
             }
         }
         else if (bodyPart == BodyPart.Dress)
         {
             Dress = armatureName;
 
-            slotList.Add(DressSlot);
+            slotList.Add(DressArmature);
         }
         else if (bodyPart == BodyPart.Mouse)
         {
             Mouse = armatureName;
             
-            slotList.Add(MouseSlot);
+            slotList.Add(MouseArmature);
         }
         else if (bodyPart == BodyPart.Headwear)
         {
             HeadWear = armatureName;
 
-            slotList.Add(HeadWearSlot);
+            slotList.Add(HeadWearArmature);
         }
         else if (bodyPart == BodyPart.Leg)
         {
@@ -1018,18 +1067,26 @@ public class Player : Regist , IPointerClickHandler
         }
 		else if (bodyPart == BodyPart.LeftLongSleeve)
 		{
+//			LeftLongSleeve = armatureName;
+
 			slotList.Add(LeftLongSleeveSlot);
 		}
 		else if (bodyPart == BodyPart.LeftShortSleeve)
 		{
+//			LeftShortSleeve = armatureName;
+		
 			slotList.Add(LeftShortSleeveSlot);
 		}
 		else if (bodyPart == BodyPart.RightLongSleeve)
 		{
+//			RightLongSleeve = armatureName;
+
 			slotList.Add(RightLongSleeveSlot);
 		}
 		else if (bodyPart == BodyPart.RightShortSleeve)
 		{
+//			RightShortSleeve = armatureName;
+
 			slotList.Add(RightShortSleeveSlot);
 		}
         else
@@ -1054,7 +1111,7 @@ public class Player : Regist , IPointerClickHandler
     {
         for (int i = 0; i < slotList.Count; i++)
         {
-            slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName);
+			slotList[i].childArmature = UnityFactory.factory.BuildArmature(armatureName, null, null, null, true);
         }
 
         if (setDepth)

+ 1 - 1
Assets/Script/Tool/Auxiliary.cs

@@ -140,7 +140,7 @@ public class Auxiliary : Regist
 
         if (Input.GetKeyDown(KeyCode.Z))
         {
-			ManaPlayer.Player.ChangeClose(BodyPart.LeftShortSleeve, "Empty");
+			//ManaPlayer.Player.LeftHandSlot._displayDirty
 
 //			Dictionary<string,SkinSlotData> slots = ManaPlayer.Player.LeftLegSlot.armature.armatureData.GetSkin("__default").slots;
 //