Browse Source

【+】
1.修改隐藏半透按钮样式
2.部分代码重构

lxd 5 months ago
parent
commit
86f01706b3

File diff suppressed because it is too large
+ 676 - 157
ModeDisplay/Assets/GameAssets/06.UIPrefabs/PartListPanel.prefab


+ 2 - 1
ModeDisplay/Assets/Scenes/220kV隔离开关-GW4A型.unity

@@ -38,7 +38,7 @@ RenderSettings:
   m_ReflectionIntensity: 1
   m_CustomReflection: {fileID: 0}
   m_Sun: {fileID: 0}
-  m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
+  m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
   m_UseRadianceAmbientProbe: 0
 --- !u!157 &3
 LightmapSettings:
@@ -79856,6 +79856,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 284a867e3cbd7b94791e29edc2b49f25, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  DeviceName: "\u9694\u79BB\u5F00\u5173_220kV_GW4A"
 --- !u!114 &2387416788012172753
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 8 - 1
ModeDisplay/Assets/Scripts/PartMark.cs

@@ -3,6 +3,13 @@ using System.Collections.Generic;
 using UnityEngine;
 using QFramework;
 
+public enum ShowState
+{
+    Hide,
+    Tran
+}
+
+
 public class PartMark : MonoBehaviour
 {
     public List<PartMark> m_ChildPartMarks;
@@ -42,7 +49,7 @@ public class PartMark : MonoBehaviour
         PartListPanel tmpPartListPanel = UIKit.GetPanel<PartListPanel>();
         SetInitState();
         
-        if (tmpPartListPanel.CheckDropdown.captionText.text == "部件半透")
+        if (tmpPartListPanel.m_ShowState == ShowState.Tran)
         {
             this.gameObject.SetActive(true);
 

+ 8 - 0
ModeDisplay/Assets/Scripts/UI/ButtonEffect.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7e48e7200ce4015488c31870d7942f2c
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 67 - 0
ModeDisplay/Assets/Scripts/UI/ButtonEffect/ButtonEffect.cs

@@ -0,0 +1,67 @@
+using QFramework;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+public class ButtonEffect : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
+{
+    public GameObject normailState, selectState, highlighterState;
+
+    public void OnPointerEnter(PointerEventData eventData)
+    {
+        highlighterState.SetActive(true);
+        normailState.SetActive(false);
+    }
+
+    public void OnPointerExit(PointerEventData eventData)
+    {
+        highlighterState.SetActive(false);
+        normailState.SetActive(true);
+    }
+    float tmpTime = 0;
+    public void Flashing(float time)
+    {
+        tmpTime += Time.deltaTime;
+        if (tmpTime >= 0 && tmpTime <= 1)
+        {
+            SetLibraryBtnState(BtnState.highter);
+        }
+        else if (tmpTime > 1 && tmpTime <= 2)
+        {
+            SetLibraryBtnState(BtnState.normal);
+        }
+        else
+        {
+            tmpTime = 0;
+        }
+    }
+
+    /// <summary>
+    /// 设置工具库按钮状态
+    /// </summary>
+    /// <param name="select"></param>
+    public void SetLibraryBtnState(BtnState state)
+    {
+        switch (state)
+        {
+            case BtnState.normal:
+                normailState.SetActive(true);
+                selectState.SetActive(false);
+                highlighterState.SetActive(false);
+                break;
+            case BtnState.highter:
+                normailState.SetActive(false);
+                selectState.SetActive(false);
+                highlighterState.SetActive(true);
+                break;
+            case BtnState.select:
+                normailState.SetActive(false);
+                selectState.SetActive(true);
+                highlighterState.SetActive(false);
+                break;
+            default:
+                break;
+        }
+    }
+}

+ 11 - 0
ModeDisplay/Assets/Scripts/UI/ButtonEffect/ButtonEffect.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 90f913e218adede488521cc35f5cf97d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 209 - 0
ModeDisplay/Assets/Scripts/UI/ButtonEffect/DownBGButton.cs

@@ -0,0 +1,209 @@
+using DG.Tweening;
+using QFramework;
+using Sirenix.OdinInspector;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+
+public enum BtnState
+{
+    normal,
+    highter,
+    select
+}
+
+/// <summary>
+/// 底部按钮
+/// </summary>
+public class DownBGButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
+{
+    private RectTransform m_RectTransform;
+    private Button m_Btn;
+    private Text m_BtnText;
+    private Image m_BtnIcon;
+    private Image m_PromptIcon;
+    private Image m_HighlighterArea;
+    private Image m_SelectLine;
+    public Button Button
+    {
+        get
+        {
+            if (m_Btn == null)
+            {
+                m_Btn = GetComponent<Button>();
+            }
+            return m_Btn;
+        }
+    }
+
+    [LabelText("常态Icon")]
+    public Sprite m_NormalIcon;
+    [LabelText("划入Icon")]
+    public Sprite m_HoverIcon;
+    [LabelText("选中Icon")]
+    public Sprite m_SelectIcon;
+
+    [LabelText("常态颜色")]
+    public Color m_NormalColor;
+    [LabelText("划入颜色")]
+    public Color m_HoverColor;
+    [LabelText("选中字体颜色")]
+    public Color m_SelectColor;
+
+    [LabelText("常态字体")]
+    public Font m_NormalFont;
+    [LabelText("划入字体")]
+    public Font m_HoverFont;
+    [LabelText("选中字体")]
+    public Font m_SelectFont;
+
+
+    //是否是状态切换类按钮  true:状态切换 false :点击类
+    private bool isSelect = false;
+    private bool isPrompting = false;
+    private bool isHover = false;
+
+    public void Awake()
+    {
+        Load();
+    }
+
+    private void Load()
+    {
+        m_RectTransform = GetComponent<RectTransform>();
+        m_Btn = GetComponent<Button>();
+        m_BtnIcon = this.transform.Find("Icon").GetComponent<Image>();
+        m_BtnText = m_BtnIcon.transform.Find("Text").GetComponent<Text>();
+        m_HighlighterArea = this.transform.Find("SelectArea").GetComponent<Image>();
+        m_SelectLine = this.transform.Find("Line").GetComponent<Image>();
+        m_PromptIcon = this.transform.Find("PromptIcon").GetComponent<Image>();
+
+        m_HighlighterArea.gameObject.SetActive(false);
+        m_SelectLine.gameObject.SetActive(false);
+    }
+
+    public void RefrushButonSize()
+    {
+        m_PromptIcon.rectTransform.sizeDelta = m_RectTransform.sizeDelta;
+    }
+
+    public void SetBtnState(BtnState state)
+    {
+        isHover = false;
+        switch (state)
+        {
+            case BtnState.normal:
+                m_BtnIcon.sprite = m_NormalIcon;
+                m_BtnText.font = m_NormalFont;
+                m_BtnText.color = m_NormalColor;
+                m_HighlighterArea.gameObject.SetActive(false);
+                m_SelectLine.gameObject.SetActive(false);
+                isSelect = false;
+                break;
+            case BtnState.highter:
+                m_BtnIcon.sprite = m_HoverIcon;
+                m_BtnText.font = m_HoverFont;
+                m_BtnText.color = m_HoverColor;
+                m_HighlighterArea.gameObject.SetActive(true);
+                m_SelectLine.gameObject.SetActive(true);
+
+                isHover = true;
+                break;
+            case BtnState.select:
+                m_BtnIcon.sprite = m_SelectIcon;
+                m_BtnText.font = m_SelectFont;
+                m_BtnText.color = m_SelectColor;
+                m_HighlighterArea.gameObject.SetActive(false);
+                m_SelectLine.gameObject.SetActive(true);
+                isSelect = true;
+                break;
+        }
+    }
+    public void OnPointerEnter(PointerEventData eventData)
+    {
+        //HoverClosePrompt();
+
+        if (!isSelect)
+        {
+            SetBtnState(BtnState.highter);
+        }else
+        {
+            SetBtnState(BtnState.select);
+        }
+    }
+
+    public void OnPointerExit(PointerEventData eventData)
+    {
+        if (isSelect)
+        {
+            SetBtnState(BtnState.select);
+        }
+        else
+        {
+            SetBtnState(BtnState.normal);
+        }
+    }
+
+    void OnEnable()
+    {
+        LocalizationManager_OnLocalizeEvent();
+    }
+
+
+    private void LocalizationManager_OnLocalizeEvent()
+    {
+        RefrushButonSize();
+
+        if(isPrompting)
+        {
+            m_PromptIcon.rectTransform.DOKill();
+            m_PromptIcon.rectTransform.sizeDelta = m_RectTransform.sizeDelta;
+            m_PromptIcon.rectTransform.DOSizeDelta(new Vector2(m_RectTransform.sizeDelta.x - 34, m_BtnText.rectTransform.sizeDelta.y + 2), 1).SetLoops(-1, LoopType.Yoyo);
+        }
+    }
+
+    /// <summary>
+    /// 开启按钮提示
+    /// </summary>
+    public void OpenPrompt()
+    {   
+        if (isPrompting) return;
+
+        m_PromptIcon.gameObject.SetActive(true);
+        m_PromptIcon.rectTransform.sizeDelta = m_RectTransform.sizeDelta;
+        m_PromptIcon.rectTransform.DOSizeDelta(new Vector2(m_RectTransform.sizeDelta.x - 34, m_BtnText.rectTransform.sizeDelta.y + 2), 1).SetLoops(-1, LoopType.Yoyo);
+        isPrompting=true;
+    }
+
+    /// <summary>
+    /// 关闭按钮提示
+    /// </summary>
+    public void ClosePrompt()
+    {
+        if (!isPrompting || !m_PromptIcon.gameObject.activeSelf) return;
+
+        isPrompting=false;
+        m_PromptIcon.rectTransform.DOKill();
+        m_PromptIcon.gameObject.SetActive(false);
+        m_PromptIcon.rectTransform.sizeDelta = m_RectTransform.sizeDelta;
+    }
+
+    public void HoverOpenPrompt()
+    {
+        if (isPrompting)
+        {
+            m_PromptIcon.rectTransform.DOPlay();
+            m_PromptIcon.gameObject.SetActive(true);
+        }
+    }
+    public void HoverClosePrompt()
+    {
+        if (isPrompting)
+        {
+            m_PromptIcon.rectTransform.DOPause();
+            m_PromptIcon.gameObject.SetActive(false);
+        }
+    }
+}

+ 11 - 0
ModeDisplay/Assets/Scripts/UI/ButtonEffect/DownBGButton.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1505a3e801c2552418096985593d4746
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 7 - 1
ModeDisplay/Assets/Scripts/UI/QFramework/PartListPanel.Designer.cs

@@ -5,7 +5,7 @@ using QFramework;
 
 namespace QFramework
 {
-	// Generate Id:cf6934ce-2f59-412a-bfe9-eff0d98ec762
+	// Generate Id:8bbb3e8b-e347-461e-ae9a-f989ef1ded4d
 	public partial class PartListPanel
 	{
 		public const string Name = "PartListPanel";
@@ -62,6 +62,10 @@ namespace QFramework
 		public UnityEngine.UI.Text UserName;
 		[SerializeField]
 		public UnityEngine.UI.Text ScheduleText;
+		[SerializeField]
+		public UnityEngine.UI.Button HidetBtn;
+		[SerializeField]
+		public UnityEngine.UI.Button TransflectiveBtn;
 		
 		private PartListPanelData mPrivateData = null;
 		
@@ -93,6 +97,8 @@ namespace QFramework
 			HeadPortraitText = null;
 			UserName = null;
 			ScheduleText = null;
+			HidetBtn = null;
+			TransflectiveBtn = null;
 			
 			mData = null;
 		}

+ 42 - 0
ModeDisplay/Assets/Scripts/UI/QFramework/PartListPanel.cs

@@ -14,6 +14,8 @@ namespace QFramework
 	{
 		bool m_Expand = false;
 
+		public ShowState m_ShowState;
+
 		protected override void ProcessMsg(int eventId, QMsg msg)
 		{
 			throw new System.NotImplementedException();
@@ -28,6 +30,12 @@ namespace QFramework
 			OperationTitle.text = DeviceController.instance.DeviceName;
 
 			CloseBtn.onClick.AddListener(() => Application.Quit());
+
+			HidetBtn.onClick.AddListener(OnHideBtnClick);
+
+			TransflectiveBtn.onClick.AddListener(OnTransflectiveBtnClick);
+
+			OnHideBtnClick();
 		}
 		
 		protected override void OnOpen(IUIData uiData = null)
@@ -44,6 +52,7 @@ namespace QFramework
 			tmpPartItem.InitData(mData.m_PartInfo);
 
 			tmpPartItem.OnSelectToggleChange(true, true);
+			tmpPartItem.ExpandChildPartItem();
 
 			CameraSurround.instance.SetCameraPosition(true);
 		}
@@ -102,5 +111,38 @@ namespace QFramework
 			}
 
 		}
+
+		private void OnHideBtnClick()
+        {
+			HidetBtn.GetComponent<DownBGButton>().SetBtnState(BtnState.select);
+			TransflectiveBtn.GetComponent<DownBGButton>().SetBtnState(BtnState.normal);
+
+			m_ShowState = ShowState.Hide;
+
+			PartItem[] tmpPartItems = transform.GetComponentsInChildren<PartItem>(false);
+
+			foreach (var item in tmpPartItems)
+			{
+				Debug.LogError(item.name + item.m_PartMark == null);
+				item.m_PartMark.RefreshState();
+			}
+		}
+
+		private void OnTransflectiveBtnClick()
+		{
+			HidetBtn.GetComponent<DownBGButton>().SetBtnState(BtnState.normal);
+			TransflectiveBtn.GetComponent<DownBGButton>().SetBtnState(BtnState.select);
+
+			m_ShowState = ShowState.Tran;
+
+			PartItem[] tmpPartItems = transform.GetComponentsInChildren<PartItem>(false);
+
+			foreach (var item in tmpPartItems)
+			{
+				Debug.LogError(item.name + item.m_PartMark == null);
+				item.m_PartMark.RefreshState();
+			}
+
+		}
 	}
 }

+ 4 - 4
ModeDisplay/Assets/Scripts/UI/QFramework/PartListPanel/PartItem.Designer.cs

@@ -13,20 +13,20 @@ namespace QFramework
 		[SerializeField] public UnityEngine.UI.Image Position;
 		[SerializeField] public UnityEngine.UI.Button ExpandBtn;
 		[SerializeField] public UnityEngine.UI.Button UnExpandBtn;
-		[SerializeField] public UnityEngine.UI.Button UnSelectBtn;
-		[SerializeField] public UnityEngine.UI.Button SelectBtn;
 		[SerializeField] public UnityEngine.UI.Text Text;
 		[SerializeField] public UnityEngine.UI.Button ClickBtn;
+		[SerializeField] public UnityEngine.UI.Button UnSelectBtn;
+		[SerializeField] public UnityEngine.UI.Button SelectBtn;
 
 		public void Clear()
 		{
 			Position = null;
 			ExpandBtn = null;
 			UnExpandBtn = null;
-			UnSelectBtn = null;
-			SelectBtn = null;
 			Text = null;
 			ClickBtn = null;
+			UnSelectBtn = null;
+			SelectBtn = null;
 		}
 
 		public override string ComponentName

Some files were not shown because too many files changed in this diff