Parcourir la source

提交一个抽象类

wartheking il y a 9 mois
Parent
commit
3a7206c682

+ 8 - 0
Assets/Scripts/UI/UIView/RKZY/RKZYLayer.cs

@@ -114,6 +114,7 @@ public class RKZYLayer : YZTRootLayer
     async void Start()
     {
         GameObject shaPan = GameObject.FindGameObjectWithTag("ShaPan");
+        beforeC.gameObject.SetActive(true);
         beforeC = shaPan.transform.GetChild(10);
         afterC = shaPan.transform.GetChild(11);
         lineInfoStatic = lineInfo;
@@ -124,6 +125,13 @@ public class RKZYLayer : YZTRootLayer
         InitAtten();
         await InitBaseData();
     }
+
+    public override void OnUILeave()
+    {
+        base.OnUILeave();
+        beforeC.gameObject.SetActive(false);
+        afterC.gameObject.SetActive(false);
+    }
     private void OnEnable()
     {
         CameraManager.SwitchCamera(1);

+ 7 - 1
Assets/Scripts/UI/UIView/YZT/OnePicNav.cs

@@ -31,7 +31,7 @@ public class OnePicNav : MonoBehaviour
 
     public GameObject shaPan;
 
-
+    public int lastIndex = -99;
     // Start is called before the first frame update
 
     void Start()
@@ -69,6 +69,11 @@ public class OnePicNav : MonoBehaviour
     }
 
     public void OnButtnClick(int index) {
+        if (lastIndex == index)
+            return;
+        if (lastIndex > -1) {
+            layers[lastIndex].GetComponent<YZTRootLayer>().OnUILeave();
+        }
         for (int j = 0; j < layers.Count; j++)
         {
             layers[j].gameObject.SetActive(false);
@@ -78,6 +83,7 @@ public class OnePicNav : MonoBehaviour
             btns[j].GetComponentInChildren<Text>().color = new Color32(137, 147, 173, 255);
         }
         btns[index].GetComponentInChildren<Text>().color = Color.white;
+        lastIndex = index;
         Tweener tw = s_image.GetComponent<RectTransform>().DOLocalMoveX(targetPos[index].x, 0.3f);
         tw.SetEase(Ease.OutBack);
         if (index < layers.Count)

+ 6 - 1
Assets/Scripts/UI/UIView/YZTRootLayer.cs

@@ -10,7 +10,12 @@ public enum ViewMode
 };
 
 
-public class YZTRootLayer : MonoBehaviour
+public abstract class YZTRootLayer : MonoBehaviour
 {
     public ViewMode viewMode = ViewMode.normal;
+
+
+    public virtual void OnUILeave() {
+        Debug.Log(this.gameObject.name + ":leave!");
+    }
 }