zhaoyang 3 years ago
parent
commit
c0fb47dab7

+ 2 - 2
FGUIProject/assets/DressUp/PhotographUI.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
-<component size="1080,1920" overflow="scroll" scroll="both">
+<component size="1080,1920" overflow="scroll" opaque="false" scroll="both">
   <displayList>
     <component id="n1_yd72" name="btnBack" src="9xlo8" fileName="components/ButtonBack1.xml" pkg="eg2y0ldp" xy="35,80"/>
-    <loader id="n3_yd72" name="loaBg" xy="113,369" size="50,50"/>
+    <loader id="n4_myd4" name="loaBg" xy="433,229" size="50,50" autoSize="true"/>
   </displayList>
 </component>

+ 1 - 1
GameClient/Assets/Game/CSShare

@@ -1 +1 @@
-Subproject commit 92db9cde3f5f90f000317e9075dfa77b3139ef2c
+Subproject commit 65ddd6c7b7ce902d6fec1c43d70ffb74dad295ac

+ 13 - 10
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -15,21 +15,24 @@ namespace GFGGame
         private const string FORMAT_EFFECT_OBJ_NAME = "T{0}_eff";
         private const string FORMAT_LAYER_RES_NAME_WITH_T = "{0}_t";
 
-        public static void AddItem(int itemID, GameObject sceneObj, bool needSetMask = false, bool showAni = true)
+        public static void AddItem(int itemID, GameObject sceneObj, bool needSetMask = false, bool showAni = true, GameObject parentObj = null)
         {
             ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
             if (itemCfg != null)
             {
-                GameObject parentObj = null;
-                if (itemCfg.subType == ConstDressUpItemType.BEI_JING)
-                {
-                    parentObj = sceneObj;
-                }
-                else
+                // GameObject parentObj = null;
+                if (parentObj == null)
                 {
-                    //角色
-                    Transform role = sceneObj.transform.Find(ROLE_OBJ_NAME);
-                    parentObj = role.gameObject;
+                    if (itemCfg.subType == ConstDressUpItemType.BEI_JING)
+                    {
+                        parentObj = sceneObj;
+                    }
+                    else
+                    {
+                        //角色
+                        Transform role = sceneObj.transform.Find(ROLE_OBJ_NAME);
+                        parentObj = role.gameObject;
+                    }
                 }
                 //普通层
                 if (itemCfg.resLayer1 > 0)

+ 2 - 2
GameClient/Assets/Game/HotUpdate/DressUp/SceneController.cs

@@ -42,7 +42,7 @@ namespace GFGGame
             }
         }
 
-        public static void UpdateRole(int[] equipDatas, GameObject sceneObj, bool needSetMask = false, int[] exceptTypes = null, bool showAni = true)
+        public static void UpdateRole(int[] equipDatas, GameObject sceneObj, bool needSetMask = false, int[] exceptTypes = null, bool showAni = true, GameObject parentObj = null)
         {
             Reset(sceneObj);
             int count = equipDatas.Length;
@@ -57,7 +57,7 @@ namespace GFGGame
                         continue;
                     }
                 }
-                DressUpUtil.AddItem(id, sceneObj, needSetMask, showAni);
+                DressUpUtil.AddItem(id, sceneObj, needSetMask, showAni, parentObj);
             }
             DressUpUtil.UpdateBody(null, sceneObj, false, null, needSetMask);
         }

+ 54 - 1
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -2,6 +2,7 @@ using FairyGUI;
 using System;
 using UI.DressUp;
 using UnityEngine;
+using UnityEngine.EventSystems;
 
 namespace GFGGame
 {
@@ -42,12 +43,61 @@ namespace GFGGame
             equipDataCache = EquipDataCache.cacher;
             UpdateBg();
             UpdateBody();
+
+            Timers.inst.Add(0.001f, 0, OnClickListener);
         }
+        private void OnClickListener(object param)
+        {
+            // Debug.Log("点击鼠标:" + Input.GetMouseButtonDown(0));
+            if (Input.GetMouseButtonDown(0))
+            {
+                if (Stage.isTouchOnUI) //点在了UI上
+                {
+                    Debug.Log("点击UI");
+                }
+                else //没有点在UI上
+                {
+                    Debug.Log("点击场景");
+                }
+                //从摄像机发出到点击坐标的射线
+                RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
+                Vector2 pos = Input.mousePosition;
+                // Debug.Log("pos:" + pos);
+
+                if (hit.collider != null)
+                {
+                    //划出射线,只有在scene视图中才能看到
+                    // Debug.DrawLine(ray.origin, hitInfo.point, Color.red);
+                    GameObject gameObj = hit.collider.gameObject;
+                    Debug.Log("click object name is :" + gameObj.name);
+                    //当射线碰撞目标为boot类型的物品,执行拾取操作
+                    if (gameObj.tag == "boot")
+                    {
+                        Debug.Log("pickup!");
+                    }
+                }
+            }
+        }
+
         //背景
         private void UpdateBg()
         {
+            Transform tf = _sceneObject.transform.Find("Bg");
+            SpriteRenderer spr = tf.GetComponent<SpriteRenderer>();
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(equipDataCache.bgId);
+            var resPath = ResPathUtil.GetDressUpPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType));
+            Sprite sp = GFGAsset.Load<Sprite>(resPath);
+            DressUpUtil.AddAssetReleaser(tf.gameObject, resPath);
+            spr.sprite = sp;
+
             int[] bgId = { equipDataCache.bgId };
-            SceneController.UpdateRole(bgId, _sceneObject, false, null, false);
+            GameObject obj = _sceneObject.transform.Find("Bg").gameObject;
+            SceneController.UpdateRole(bgId, _sceneObject, false, null, false, obj);
+            SetObjSize(obj.transform.GetChild(0).gameObject);
+        }
+        private void SetObjSize(GameObject obj)
+        {
+            obj.AddComponent<BoxCollider2D>();
         }
         //主角
         private void UpdateBody()
@@ -83,6 +133,9 @@ namespace GFGGame
         {
 
         }
+
+
+
         private void OnClickBtnBack()
         {
             this.Hide();

BIN
GameClient/Assets/ResIn/UI/DressUp/DressUp_fui.bytes