Reset Event Property Value + Right Click Dropdown API + Confirm Quit (#563)

* * in name when changing value

* Popup UI and quit basics

* Quit button finalized, i think

* fix

* fixed

* right click dropdown prefab

* tryna getit to work

* woohoo it works

* value reset support for text areas

* Color reset support

* Enums and numbers supported

* catchy tune fix
This commit is contained in:
Rapandrasmus 2023-10-14 03:43:44 +02:00 committed by GitHub
parent 943e129904
commit cbb912772f
17 changed files with 2019 additions and 87 deletions

View file

@ -0,0 +1,440 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1069446853043438909
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8384641343036272350}
- component: {fileID: 5892063193686803625}
m_Layer: 5
m_Name: RightClickDropdown
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8384641343036272350
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069446853043438909}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 957154786397146521}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 12}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5892063193686803625
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069446853043438909}
m_CullTransparentMesh: 1
--- !u!1 &2304285986814012682
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1187626560509100645}
- component: {fileID: 5548373997629452713}
- component: {fileID: 6009602095063593120}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1187626560509100645
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2304285986814012682}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6907741928570761706}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5548373997629452713
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2304285986814012682}
m_CullTransparentMesh: 1
--- !u!114 &6009602095063593120
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2304285986814012682}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Option
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 00ba8359d55aea94799b54c203adf38f, type: 2}
m_sharedMaterial: {fileID: -1034967165085496816, guid: 00ba8359d55aea94799b54c203adf38f, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &6068898642408905715
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 957154786397146521}
- component: {fileID: 7068493347926292236}
- component: {fileID: 1343412359289404708}
- component: {fileID: 7980774898327048575}
- component: {fileID: 6566328886501881416}
m_Layer: 5
m_Name: RightClickDropdown
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &957154786397146521
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6068898642408905715}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6907741928570761706}
m_Father: {fileID: 8384641343036272350}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 160, y: -60}
m_SizeDelta: {x: 160, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7068493347926292236
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6068898642408905715}
m_CullTransparentMesh: 1
--- !u!114 &1343412359289404708
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6068898642408905715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 1401309272, guid: bd48ded17f064414eb670529c2375358, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7980774898327048575
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6068898642408905715}
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: 70
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &6566328886501881416
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6068898642408905715}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &8337216749316256214
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6907741928570761706}
- component: {fileID: 154936598456533904}
- component: {fileID: 5155450919514646833}
- component: {fileID: 6604080304440396267}
- component: {fileID: 8296619418044947051}
m_Layer: 5
m_Name: Option
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &6907741928570761706
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8337216749316256214}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1187626560509100645}
m_Father: {fileID: 957154786397146521}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 80, y: -17.5}
m_SizeDelta: {x: 160, y: 35}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &154936598456533904
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8337216749316256214}
m_CullTransparentMesh: 1
--- !u!114 &5155450919514646833
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8337216749316256214}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &6604080304440396267
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8337216749316256214}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.4811321, g: 0.4811321, b: 0.4811321, a: 1}
m_PressedColor: {r: 0.2264151, g: 0.2264151, b: 0.2264151, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 5155450919514646833}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &8296619418044947051
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8337216749316256214}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates: []

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 56a45ac5cd0da2a4ab398d1a63e18d9f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@ namespace HeavenStudio.Games.Loaders
{ {
new Param.CollapseParam(x => (bool)x, new string[] { "endSmile" }) new Param.CollapseParam(x => (bool)x, new string[] { "endSmile" })
}), }),
new Param("endSmile", new EntityTypes.Float(2, 100), "End Smile Beat", "How many beats after the catch should the smile end?") new Param("endSmile", new EntityTypes.Float(2, 100, 2), "End Smile Beat", "How many beats after the catch should the smile end?")
}, },
preFunction = delegate {var e = eventCaller.currentEntity; CatchyTune.PreDropFruit(e.beat, e["side"], e["smile"], false, e["endSmile"]); }, preFunction = delegate {var e = eventCaller.currentEntity; CatchyTune.PreDropFruit(e.beat, e["side"], e["smile"], false, e["endSmile"]); },
}, },
@ -39,7 +39,7 @@ namespace HeavenStudio.Games.Loaders
{ {
new Param.CollapseParam(x => (bool)x, new string[] { "endSmile" }) new Param.CollapseParam(x => (bool)x, new string[] { "endSmile" })
}), }),
new Param("endSmile", new EntityTypes.Float(2, 100), "End Smile Beat", "How many beats after the catch should the smile end?") new Param("endSmile", new EntityTypes.Float(2, 100, 2), "End Smile Beat", "How many beats after the catch should the smile end?")
}, },
preFunction = delegate {var e = eventCaller.currentEntity; CatchyTune.PreDropFruit(e.beat, e["side"], e["smile"], true, e["endSmile"]); }, preFunction = delegate {var e = eventCaller.currentEntity; CatchyTune.PreDropFruit(e.beat, e["side"], e["smile"], true, e["endSmile"]); },
}, },

View file

@ -76,6 +76,8 @@ namespace HeavenStudio
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void Init() public static void Init()
{ {
Application.wantsToQuit += WantsToQuit;
BasicCheck(); BasicCheck();
Minigames.InitPreprocessor(); Minigames.InitPreprocessor();
@ -384,5 +386,12 @@ namespace HeavenStudio
Debug.Log("Clearing RIQ Cache..."); Debug.Log("Clearing RIQ Cache...");
Jukebox.RiqFileHandler.ClearCache(); Jukebox.RiqFileHandler.ClearCache();
} }
private static bool WantsToQuit()
{
if (SceneManager.GetActiveScene().name != "Editor") return true;
Editor.Editor.instance.ShowQuitPopUp(true);
return Editor.Editor.instance.ShouldQuit;
}
} }
} }

View file

@ -55,6 +55,11 @@ namespace HeavenStudio.Editor
[SerializeField] private Button SortChronologicBTN; [SerializeField] private Button SortChronologicBTN;
[SerializeField] private TMP_InputField SearchBar; [SerializeField] private TMP_InputField SearchBar;
[Header("Confirm Quit")]
[SerializeField] private GameObject _confirmQuitMain;
[SerializeField] private Button _quitYes;
[SerializeField] private Button _quitNo;
[SerializeField] private Button EditorThemeBTN; [SerializeField] private Button EditorThemeBTN;
[SerializeField] private Button EditorSettingsBTN; [SerializeField] private Button EditorSettingsBTN;
@ -144,6 +149,19 @@ namespace HeavenStudio.Editor
(minigame.fxOnly ? ggs.fxActive : ggs.mgsActive).Add(GameIcon_.GetComponent<RectTransform>()); (minigame.fxOnly ? ggs.fxActive : ggs.mgsActive).Add(GameIcon_.GetComponent<RectTransform>());
} }
public void ShowQuitPopUp(bool show)
{
_confirmQuitMain.SetActive(show);
}
public bool ShouldQuit = false;
public void QuitGame()
{
ShouldQuit = true;
Application.Quit();
}
public void LateUpdate() public void LateUpdate()
{ {
if (lastScreenSize != new Vector2(UnityEngine.Screen.width, UnityEngine.Screen.height)) if (lastScreenSize != new Vector2(UnityEngine.Screen.width, UnityEngine.Screen.height))

View file

@ -105,11 +105,8 @@ namespace HeavenStudio.Editor
ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip)); ePrefabs.Add(propertyName, AddParam(propertyName, param, caption, tooltip));
} }
Debug.Log(action.parameters);
foreach (var p in action.parameters) foreach (var p in action.parameters)
{ {
Debug.Log(p.collapseParams);
if (p.collapseParams == null || p.collapseParams.Count == 0) continue; if (p.collapseParams == null || p.collapseParams.Count == 0) continue;
EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent<EventPropertyPrefab>(); EventPropertyPrefab input = ePrefabs[p.propertyName].GetComponent<EventPropertyPrefab>();
foreach (var c in p.collapseParams) foreach (var c in p.collapseParams)

View file

@ -14,6 +14,7 @@ namespace HeavenStudio.Editor
public class EventPropertyPrefab : MonoBehaviour public class EventPropertyPrefab : MonoBehaviour
{ {
public TMP_Text caption; public TMP_Text caption;
protected string _captionText;
public EventParameterManager parameterManager; public EventParameterManager parameterManager;
public string propertyName; public string propertyName;
public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>(); public List<PropertyCollapse> propertyCollapses = new List<PropertyCollapse>();
@ -25,7 +26,10 @@ namespace HeavenStudio.Editor
{ {
this.parameterManager = EventParameterManager.instance; this.parameterManager = EventParameterManager.instance;
this.propertyName = propertyName; this.propertyName = propertyName;
this.caption.text = caption;
_captionText = caption;
this.caption.text = _captionText;
} }
public void UpdateCollapse(object type) public void UpdateCollapse(object type)
@ -34,7 +38,7 @@ namespace HeavenStudio.Editor
{ {
foreach (var c in p.collapseables) foreach (var c in p.collapseables)
{ {
c.SetActive(p.collapseOn(type) && gameObject.activeSelf); if (c != null) c.SetActive(p.collapseOn(type) && gameObject.activeSelf);
} }
} }
} }

View file

@ -18,18 +18,36 @@ namespace HeavenStudio.Editor
[Space(10)] [Space(10)]
public Toggle toggle; public Toggle toggle;
private bool _defaultValue;
new public void SetProperties(string propertyName, object type, string caption) new public void SetProperties(string propertyName, object type, string caption)
{ {
InitProperties(propertyName, caption); InitProperties(propertyName, caption);
// ' (bool)type ' always results in false _defaultValue = (bool)type;
toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]); toggle.isOn = Convert.ToBoolean(parameterManager.entity[propertyName]);
toggle.onValueChanged.AddListener( toggle.onValueChanged.AddListener(
_ => parameterManager.entity[propertyName] = toggle.isOn _ =>
{
parameterManager.entity[propertyName] = toggle.isOn;
if (toggle.isOn != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
); );
} }
public void ResetValue()
{
toggle.isOn = _defaultValue;
}
public override void SetCollapses(object type) public override void SetCollapses(object type)
{ {
toggle.onValueChanged.AddListener( toggle.onValueChanged.AddListener(
@ -37,9 +55,5 @@ namespace HeavenStudio.Editor
); );
UpdateCollapse(toggle.isOn); UpdateCollapse(toggle.isOn);
} }
private void Update()
{
}
} }
} }

View file

@ -21,12 +21,26 @@ namespace HeavenStudio.Editor
public bool colorTableActive; public bool colorTableActive;
public ColorPreview colorPreview; public ColorPreview colorPreview;
private Color _defaultColor;
new public void SetProperties(string propertyName, object type, string caption) new public void SetProperties(string propertyName, object type, string caption)
{ {
InitProperties(propertyName, caption); InitProperties(propertyName, caption);
colorPreview.colorPicker.onColorChanged += _ => colorPreview.colorPicker.onColorChanged += _ =>
{
parameterManager.entity[propertyName] = colorPreview.colorPicker.color; parameterManager.entity[propertyName] = colorPreview.colorPicker.color;
if (colorPreview.colorPicker.color != _defaultColor)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
};
_defaultColor = (Color)type;
Color paramCol = parameterManager.entity[propertyName]; Color paramCol = parameterManager.entity[propertyName];
@ -43,6 +57,11 @@ namespace HeavenStudio.Editor
ColorTable.gameObject.SetActive(false); ColorTable.gameObject.SetActive(false);
} }
public void ResetValue()
{
colorPreview.ChangeColor(_defaultColor);
}
public override void SetCollapses(object type) public override void SetCollapses(object type)
{ {
colorPreview.colorPicker.onColorChanged += _ => UpdateCollapse(colorPreview.colorPicker.color); colorPreview.colorPicker.onColorChanged += _ => UpdateCollapse(colorPreview.colorPicker.color);

View file

@ -9,6 +9,7 @@ using Starpelly;
using HeavenStudio.Util; using HeavenStudio.Util;
using HeavenStudio.Editor; using HeavenStudio.Editor;
using HeavenStudio.Common;
namespace HeavenStudio.Editor namespace HeavenStudio.Editor
{ {
@ -16,9 +17,11 @@ namespace HeavenStudio.Editor
{ {
[Header("Dropdown")] [Header("Dropdown")]
[Space(10)] [Space(10)]
public TMP_Dropdown dropdown; public LeftClickTMP_Dropdown dropdown;
private Array enumVals; private Array enumVals;
private int _defaultValue;
private bool openedDropdown = false; private bool openedDropdown = false;
new public void SetProperties(string propertyName, object type, string caption) new public void SetProperties(string propertyName, object type, string caption)
@ -28,6 +31,7 @@ namespace HeavenStudio.Editor
var enumType = type.GetType(); var enumType = type.GetType();
enumVals = Enum.GetValues(enumType); enumVals = Enum.GetValues(enumType);
var enumNames = Enum.GetNames(enumType).ToList(); var enumNames = Enum.GetNames(enumType).ToList();
_defaultValue = (int)type;
// Can we assume non-holey enum? // Can we assume non-holey enum?
// If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName] // If we can we can simplify to dropdown.value = (int) parameterManager.entity[propertyName]
@ -41,10 +45,25 @@ namespace HeavenStudio.Editor
dropdown.value = selected; dropdown.value = selected;
dropdown.onValueChanged.AddListener(_ => dropdown.onValueChanged.AddListener(_ =>
parameterManager.entity[propertyName] = (int) enumVals.GetValue(dropdown.value) {
parameterManager.entity[propertyName] = (int)enumVals.GetValue(dropdown.value);
if ((int)enumVals.GetValue(dropdown.value) != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
}
); );
} }
public void ResetValue()
{
dropdown.value = _defaultValue;
}
public override void SetCollapses(object type) public override void SetCollapses(object type)
{ {
dropdown.onValueChanged.AddListener(_ => UpdateCollapse((int)enumVals.GetValue(dropdown.value))); dropdown.onValueChanged.AddListener(_ => UpdateCollapse((int)enumVals.GetValue(dropdown.value)));

View file

@ -9,6 +9,7 @@ using Starpelly;
using HeavenStudio.Util; using HeavenStudio.Util;
using HeavenStudio.Editor; using HeavenStudio.Editor;
using static HeavenStudio.EntityTypes;
namespace HeavenStudio.Editor namespace HeavenStudio.Editor
{ {
@ -19,6 +20,8 @@ namespace HeavenStudio.Editor
public Slider slider; public Slider slider;
public TMP_InputField inputField; public TMP_InputField inputField;
private float _defaultValue;
new public void SetProperties(string propertyName, object type, string caption) new public void SetProperties(string propertyName, object type, string caption)
{ {
InitProperties(propertyName, caption); InitProperties(propertyName, caption);
@ -28,6 +31,7 @@ namespace HeavenStudio.Editor
case EntityTypes.Integer integer: case EntityTypes.Integer integer:
slider.minValue = integer.min; slider.minValue = integer.min;
slider.maxValue = integer.max; slider.maxValue = integer.max;
_defaultValue = integer.val;
slider.wholeNumbers = true; slider.wholeNumbers = true;
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]); slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
@ -38,6 +42,14 @@ namespace HeavenStudio.Editor
{ {
inputField.text = slider.value.ToString(); inputField.text = slider.value.ToString();
parameterManager.entity[propertyName] = (int) slider.value; parameterManager.entity[propertyName] = (int) slider.value;
if (slider.value != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
} }
); );
@ -52,6 +64,14 @@ namespace HeavenStudio.Editor
slider.value = Convert.ToSingle(inputField.text); slider.value = Convert.ToSingle(inputField.text);
parameterManager.entity[propertyName] = (int) slider.value; parameterManager.entity[propertyName] = (int) slider.value;
Editor.instance.editingInputField = false; Editor.instance.editingInputField = false;
if (slider.value != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
} }
); );
break; break;
@ -59,6 +79,7 @@ namespace HeavenStudio.Editor
case EntityTypes.Float fl: case EntityTypes.Float fl:
slider.minValue = fl.min; slider.minValue = fl.min;
slider.maxValue = fl.max; slider.maxValue = fl.max;
_defaultValue = fl.val;
slider.value = Convert.ToSingle(parameterManager.entity[propertyName]); slider.value = Convert.ToSingle(parameterManager.entity[propertyName]);
inputField.text = slider.value.ToString("G"); inputField.text = slider.value.ToString("G");
@ -69,6 +90,14 @@ namespace HeavenStudio.Editor
var newValue = (float) Math.Round(slider.value, 4); var newValue = (float) Math.Round(slider.value, 4);
inputField.text = newValue.ToString("G"); inputField.text = newValue.ToString("G");
parameterManager.entity[propertyName] = newValue; parameterManager.entity[propertyName] = newValue;
if (newValue != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
} }
); );
@ -83,6 +112,14 @@ namespace HeavenStudio.Editor
slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4); slider.value = (float) Math.Round(Convert.ToSingle(inputField.text), 4);
parameterManager.entity[propertyName] = slider.value; parameterManager.entity[propertyName] = slider.value;
Editor.instance.editingInputField = false; Editor.instance.editingInputField = false;
if (slider.value != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
} }
); );
break; break;
@ -94,6 +131,11 @@ namespace HeavenStudio.Editor
} }
} }
public void ResetValue()
{
slider.value = _defaultValue;
}
public override void SetCollapses(object type) public override void SetCollapses(object type)
{ {
switch (type) switch (type)

View file

@ -9,6 +9,7 @@ using Starpelly;
using HeavenStudio.Util; using HeavenStudio.Util;
using HeavenStudio.Editor; using HeavenStudio.Editor;
using UnityEngine.UIElements;
namespace HeavenStudio.Editor namespace HeavenStudio.Editor
{ {
@ -18,10 +19,14 @@ namespace HeavenStudio.Editor
[Space(10)] [Space(10)]
public TMP_InputField inputFieldString; public TMP_InputField inputFieldString;
private string _defaultValue;
new public void SetProperties(string propertyName, object type, string caption) new public void SetProperties(string propertyName, object type, string caption)
{ {
InitProperties(propertyName, caption); InitProperties(propertyName, caption);
_defaultValue = (string)type;
inputFieldString.text = (string) parameterManager.entity[propertyName]; inputFieldString.text = (string) parameterManager.entity[propertyName];
inputFieldString.onSelect.AddListener( inputFieldString.onSelect.AddListener(
@ -30,10 +35,19 @@ namespace HeavenStudio.Editor
); );
inputFieldString.onValueChanged.AddListener( inputFieldString.onValueChanged.AddListener(
_ => _ =>
{; {
parameterManager.entity[propertyName] = inputFieldString.text; parameterManager.entity[propertyName] = inputFieldString.text;
if (inputFieldString.text != _defaultValue)
{
this.caption.text = _captionText + "*";
}
else
{
this.caption.text = _captionText;
}
} }
); );
inputFieldString.onEndEdit.AddListener( inputFieldString.onEndEdit.AddListener(
_ => _ =>
{; {;
@ -42,6 +56,11 @@ namespace HeavenStudio.Editor
); );
} }
public void ResetValue()
{
inputFieldString.text = _defaultValue;
}
public override void SetCollapses(object type) public override void SetCollapses(object type)
{ {
inputFieldString.onValueChanged.AddListener( inputFieldString.onValueChanged.AddListener(

View file

@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine.EventSystems;
namespace HeavenStudio.Common
{
public class LeftClickTMP_Dropdown : TMP_Dropdown
{
public override void OnPointerClick(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right) return;
base.OnPointerClick(eventData);
}
}
}

View file

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

View file

@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace HeavenStudio.Common
{
public class RightClickDropdownObject : MonoBehaviour, IPointerClickHandler
{
[SerializeField] private Event[] _events;
[Header("Components")]
[SerializeField] private Transform _masterTrans;
[SerializeField] private RectTransform _dropDown;
private Button _dropDownButton;
private RectTransform _currentDropDown;
private bool _beingHovered;
private void Awake()
{
_dropDownButton = _dropDown.GetChild(0).GetChild(0).GetComponent<Button>();
}
private void OnDestroy()
{
if (_currentDropDown != null) Destroy(_currentDropDown.gameObject);
}
private void OnDisable()
{
if (_currentDropDown != null) Destroy(_currentDropDown.gameObject);
}
private void Update()
{
if (_beingHovered) return;
if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
{
if (_currentDropDown != null) Destroy(_currentDropDown.gameObject);
}
}
public void OnPointerClick(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Right || _events.Length == 0) return;
_currentDropDown = Instantiate(_dropDown, _masterTrans);
_currentDropDown.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10));
foreach(var e in _events)
{
Button spawnedButton = Instantiate(_dropDownButton, _currentDropDown.GetChild(0));
spawnedButton.onClick.AddListener(new UnityAction(() =>
{
e.action.Invoke();
if (_currentDropDown != null) Destroy(_currentDropDown.gameObject);
}));
spawnedButton.transform.GetChild(0).GetComponent<TMP_Text>().text = e.name;
spawnedButton.gameObject.SetActive(true);
EventTrigger eventTrigger = spawnedButton.GetComponent<EventTrigger>();
EventTrigger.Entry enter = new();
enter.eventID = EventTriggerType.PointerEnter;
enter.callback.AddListener(new UnityAction<BaseEventData>((BaseEventData e) => { _beingHovered = true; }));
eventTrigger.triggers.Add(enter);
EventTrigger.Entry exit = new();
exit.eventID = EventTriggerType.PointerExit;
exit.callback.AddListener(new UnityAction<BaseEventData>((BaseEventData e) => { _beingHovered = false; }));
eventTrigger.triggers.Add(exit);
}
}
[System.Serializable]
private struct Event
{
public string name;
public UnityEvent action;
}
}
}

View file

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