lvjincheng 3 年之前
父节点
当前提交
936bb7ca52
共有 2 个文件被更改,包括 44 次插入103 次删除
  1. 25 88
      Assets/BowArrow/Resources/Prefabs/Views/SideTipView.prefab
  2. 19 15
      Assets/BowArrow/Scripts/View/SideTipView.cs

+ 25 - 88
Assets/BowArrow/Resources/Prefabs/Views/SideTipView.prefab

@@ -31,7 +31,7 @@ RectTransform:
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 0, y: 0, z: 0}
   m_Children:
-  - {fileID: 8745548552644612890}
+  - {fileID: 8168598513995770684}
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -113,84 +113,6 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 115bb43ab0b8d6144aae3744dbb49548, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
---- !u!1 &2536229824174030564
-GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 8745548552644612890}
-  - component: {fileID: 3327669233003841910}
-  - component: {fileID: 7571701047568126791}
-  m_Layer: 5
-  m_Name: Container
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 1
---- !u!224 &8745548552644612890
-RectTransform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 2536229824174030564}
-  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
-  m_LocalPosition: {x: 0, y: 0, z: 0}
-  m_LocalScale: {x: 1, y: 1, z: 1}
-  m_Children:
-  - {fileID: 8168598513995770684}
-  m_Father: {fileID: 5811282618674645403}
-  m_RootOrder: 0
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 25, y: 75}
-  m_SizeDelta: {x: 0, y: 0}
-  m_Pivot: {x: 0, y: 0}
---- !u!114 &3327669233003841910
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 2536229824174030564}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_Padding:
-    m_Left: 0
-    m_Right: 0
-    m_Top: 0
-    m_Bottom: 0
-  m_ChildAlignment: 6
-  m_Spacing: 5
-  m_ChildForceExpandWidth: 0
-  m_ChildForceExpandHeight: 0
-  m_ChildControlWidth: 1
-  m_ChildControlHeight: 1
-  m_ChildScaleWidth: 0
-  m_ChildScaleHeight: 0
-  m_ReverseArrangement: 1
---- !u!114 &7571701047568126791
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 2536229824174030564}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  m_HorizontalFit: 2
-  m_VerticalFit: 2
 --- !u!1 &8168598513781563394
 GameObject:
   m_ObjectHideFlags: 0
@@ -258,12 +180,12 @@ MonoBehaviour:
       m_Calls: []
   m_FontData:
     m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
-    m_FontSize: 20
+    m_FontSize: 30
     m_FontStyle: 0
     m_BestFit: 0
     m_MinSize: 1
     m_MaxSize: 200
-    m_Alignment: 4
+    m_Alignment: 6
     m_AlignByGeometry: 0
     m_RichText: 1
     m_HorizontalOverflow: 0
@@ -282,6 +204,7 @@ GameObject:
   - component: {fileID: 8168598513995770816}
   - component: {fileID: 8168598513995770687}
   - component: {fileID: 8168598513995770685}
+  - component: {fileID: 1860152580080224160}
   m_Layer: 5
   m_Name: SideTip
   m_TagString: Untagged
@@ -301,14 +224,14 @@ RectTransform:
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children:
   - {fileID: 8168598513781563395}
-  m_Father: {fileID: 8745548552644612890}
+  m_Father: {fileID: 5811282618674645403}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 30, y: 70}
   m_SizeDelta: {x: 0, y: 0}
-  m_Pivot: {x: 0.5, y: 0.5}
+  m_Pivot: {x: 0, y: 0}
 --- !u!222 &8168598513995770816
 CanvasRenderer:
   m_ObjectHideFlags: 0
@@ -360,10 +283,10 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Padding:
-    m_Left: 5
-    m_Right: 5
-    m_Top: 5
-    m_Bottom: 5
+    m_Left: 10
+    m_Right: 10
+    m_Top: 10
+    m_Bottom: 10
   m_ChildAlignment: 4
   m_Spacing: 0
   m_ChildForceExpandWidth: 0
@@ -373,3 +296,17 @@ MonoBehaviour:
   m_ChildScaleWidth: 0
   m_ChildScaleHeight: 0
   m_ReverseArrangement: 0
+--- !u!114 &1860152580080224160
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8168598513995770683}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_HorizontalFit: 2
+  m_VerticalFit: 2

+ 19 - 15
Assets/BowArrow/Scripts/View/SideTipView.cs

@@ -6,16 +6,16 @@ using JCUnityLib;
 
 public class SideTipView : ViewBase
 {
-    Transform container;
-    GameObject sideTipPrefab;
+    GameObject sideTip;
+    Text sideTipText;
+    List<string> tipStrList = new List<string>(); 
     static SideTipView ins;
 
     void Awake()
     {
         ins = this;
-        container = transform.Find("Container");
-        sideTipPrefab = container.Find("SideTip").gameObject;
-        sideTipPrefab.SetActive(false);
+        sideTip = transform.Find("SideTip").gameObject;
+        sideTipText = sideTip.GetComponentInChildren<Text>();
     }
 
     void OnDestroy()
@@ -25,19 +25,23 @@ public class SideTipView : ViewBase
 
     void _ShowTip(string text, Color color)
     {
-        var o = Instantiate(sideTipPrefab);
-        var t = o.GetComponentInChildren<Text>();
-        t.text = text;
-        t.color = color;
-        o.transform.SetParent(container);
-        o.SetActive(true);
-        StartCoroutine(AutoDestroy(o));
+        string c = "white";
+        if (color == Color.yellow) c = "yellow";
+        string s = 
+            $"<color=#BBFFFF>{System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}</color>\n" +
+            $"<color={c}>{text}</color>";
+        tipStrList.Add(s);
+        sideTipText.text = string.Join("\n", tipStrList);
+        if (tipStrList.Count == 1) sideTip.SetActive(true);
+        StartCoroutine(AutoDestroy());
     }
 
-    IEnumerator AutoDestroy(GameObject o)
+    IEnumerator AutoDestroy()
     {
-        yield return new WaitForSeconds(5.0f);
-        Destroy(o);
+        yield return new WaitForSeconds(10.0f);
+        tipStrList.RemoveAt(0);
+        sideTipText.text = string.Join("\n", tipStrList);
+        if (tipStrList.Count == 0) sideTip.SetActive(false);
     }
 
     public static void ShowTip(string text, Color color)