From 728f3784515f8978425280f01a1b797a1d878dc0 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:39:54 +0200 Subject: [PATCH] Color reset support --- Assets/Scenes/Editor.unity | 40 +++++++++++++++++-- .../PropertyPrefabs/ColorPropertyPrefab.cs | 5 +++ Assets/Scripts/UI/RightClickDropdownObject.cs | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 9abd3825e..b29da39b2 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -21275,7 +21275,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1589389272} m_HandleRect: {fileID: 1589389271} m_Direction: 2 - m_Value: 1 + m_Value: 0 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -31505,7 +31505,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 459.58514, y: -185} + m_AnchoredPosition: {x: 459.58514, y: -25} m_SizeDelta: {x: 879.1703, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1443721748 @@ -33371,7 +33371,7 @@ MonoBehaviour: m_linkedTextComponent: {fileID: 0} parentLinkedComponent: {fileID: 0} m_enableKerning: 1 - m_ActiveFontFeatures: 00000000 + m_ActiveFontFeatures: 6e72656b m_enableExtraPadding: 0 checkPaddingRequired: 0 m_isRichText: 1 @@ -34048,6 +34048,7 @@ GameObject: - component: {fileID: 1535224919} - component: {fileID: 1535224918} - component: {fileID: 1535224921} + - component: {fileID: 1535224922} m_Layer: 5 m_Name: ColorBTN m_TagString: Untagged @@ -34172,6 +34173,37 @@ MonoBehaviour: previewGraphic: {fileID: 1535224919} colorPicker: {fileID: 1489888672} hex: {fileID: 426555699} +--- !u!114 &1535224922 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1535224916} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e4972b7ea15fb7943ad12ed39e229140, type: 3} + m_Name: + m_EditorClassIdentifier: + _events: + - name: Reset + action: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1443721748} + m_TargetAssemblyTypeName: HeavenStudio.Editor.ColorPropertyPrefab, Assembly-CSharp + m_MethodName: ResetValue + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + _masterTrans: {fileID: 1791483803} + _dropDown: {fileID: 8384641343036272350, guid: 56a45ac5cd0da2a4ab398d1a63e18d9f, type: 3} --- !u!1 &1536668598 GameObject: m_ObjectHideFlags: 0 @@ -34394,7 +34426,7 @@ MonoBehaviour: m_linkedTextComponent: {fileID: 0} parentLinkedComponent: {fileID: 0} m_enableKerning: 1 - m_ActiveFontFeatures: 00000000 + m_ActiveFontFeatures: 6e72656b m_enableExtraPadding: 1 checkPaddingRequired: 0 m_isRichText: 1 diff --git a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs index a7b894588..4e69b914d 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/PropertyPrefabs/ColorPropertyPrefab.cs @@ -57,6 +57,11 @@ namespace HeavenStudio.Editor ColorTable.gameObject.SetActive(false); } + public void ResetValue() + { + colorPreview.ChangeColor(_defaultColor); + } + public override void SetCollapses(object type) { colorPreview.colorPicker.onColorChanged += _ => UpdateCollapse(colorPreview.colorPicker.color); diff --git a/Assets/Scripts/UI/RightClickDropdownObject.cs b/Assets/Scripts/UI/RightClickDropdownObject.cs index f4ae10ca7..de95cf42e 100644 --- a/Assets/Scripts/UI/RightClickDropdownObject.cs +++ b/Assets/Scripts/UI/RightClickDropdownObject.cs @@ -57,7 +57,7 @@ namespace HeavenStudio.Common spawnedButton.onClick.AddListener(new UnityAction(() => { e.action.Invoke(); - Destroy(_currentDropDown.gameObject); + if (_currentDropDown != null) Destroy(_currentDropDown.gameObject); })); spawnedButton.transform.GetChild(0).GetComponent().text = e.name; spawnedButton.gameObject.SetActive(true);