From 9b21b6af3158f0ea0ac527f069131d91a5d43fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20Rios?= Date: Fri, 1 Mar 2024 18:36:20 +0100 Subject: [PATCH] Toggle generic name (#473) * Added Generics name toggle button * Fixed cursor being idle when loading fbx * hide generics label by default * Remove print --- Assets/Prefabs/Room.prefab | 15 +- Assets/Scenes/Main.unity | 312 +++++++++++++++++++++- Assets/Scripts/ModelLoader.cs | 6 +- Assets/Scripts/ObjectDisplayController.cs | 5 +- Assets/Scripts/OgreeClasses/Room.cs | 12 + Assets/Scripts/UiManager.cs | 28 ++ 6 files changed, 367 insertions(+), 11 deletions(-) diff --git a/Assets/Prefabs/Room.prefab b/Assets/Prefabs/Room.prefab index b570c31a..85a8267f 100644 --- a/Assets/Prefabs/Room.prefab +++ b/Assets/Prefabs/Room.prefab @@ -54,8 +54,9 @@ MonoBehaviour: id: parentId: category: - description: [] + description: domain: + tags: [] attributesKeys: [] attributesValues: [] currentLod: 0 @@ -74,13 +75,13 @@ MonoBehaviour: reserved: left: 0 right: 0 - top: 0 - bottom: 0 + front: 0 + back: 0 technical: left: 0 right: 0 - top: 0 - bottom: 0 + front: 0 + back: 0 usableZone: {fileID: 1754386266534505231} reservedZone: {fileID: 18736379438063463} technicalZone: {fileID: 2859817786028861529} @@ -90,6 +91,10 @@ MonoBehaviour: tileColor: 0 barChart: 0 openedGroups: [] + separators: [] + sepNamesDisplayed: 0 + genNamesDisplayed: 0 + childrenOrigin: {fileID: 0} --- !u!1 &760801759331240274 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index c7bed3ad..6f07f250 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -3886,6 +3886,140 @@ RectTransform: m_AnchoredPosition: {x: 370.5, y: 254.4444} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &376546234 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 376546235} + - component: {fileID: 376546237} + - component: {fileID: 376546236} + 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 &376546235 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 376546234} + 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: 2023338576} + 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!114 &376546236 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 376546234} + 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: Toggle generics name + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4281479730 + m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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: 14 + m_fontSizeBase: 18 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 5 + m_fontSizeMax: 14 + 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_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 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: 1 + 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!222 &376546237 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 376546234} + m_CullTransparentMesh: 0 --- !u!1 &378271040 GameObject: m_ObjectHideFlags: 0 @@ -8110,6 +8244,7 @@ RectTransform: - {fileID: 1719855462} - {fileID: 1724230490} - {fileID: 1932232404} + - {fileID: 2023338576} - {fileID: 314828350} - {fileID: 577279988} - {fileID: 1286022686} @@ -9558,7 +9693,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: -58.700134, y: -206.89996} + m_AnchoredPosition: {x: -58.700073, y: -206.89996} m_SizeDelta: {x: -116, y: 257} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &821904126 @@ -15200,6 +15335,7 @@ MonoBehaviour: openedGroups: [] separators: [] sepNamesDisplayed: 0 + genNamesDisplayed: 1 childrenOrigin: {fileID: 0} --- !u!1 &1332719423 GameObject: @@ -18853,6 +18989,10 @@ MonoBehaviour: hideWhenUseless: 0 button: {fileID: 1932232406} toggledColor: {r: 0, g: 0, b: 0, a: 0} + toggleGenNamesBtn: + hideWhenUseless: 0 + button: {fileID: 2023338578} + toggledColor: {r: 0, g: 0, b: 0, a: 0} toggleUHelpersBtn: hideWhenUseless: 0 button: {fileID: 314828351} @@ -24037,8 +24177,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 741869394} m_HandleRect: {fileID: 741869393} m_Direction: 0 - m_Value: 0 - m_Size: 0.99999964 + m_Value: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -25678,6 +25818,172 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2001605689} m_CullTransparentMesh: 1 +--- !u!1 &2023338575 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2023338576} + - component: {fileID: 2023338580} + - component: {fileID: 2023338579} + - component: {fileID: 2023338578} + - component: {fileID: 2023338577} + m_Layer: 5 + m_Name: ButtonToggleGenName + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2023338576 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2023338575} + 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: 376546235} + m_Father: {fileID: 731465983} + 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_SizeDelta: {x: 166.7, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2023338577 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2023338575} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreLayout: 0 + m_MinWidth: -1 + m_MinHeight: -1 + m_PreferredWidth: 160 + m_PreferredHeight: 30 + m_FlexibleWidth: -1 + m_FlexibleHeight: -1 + m_LayoutPriority: 1 +--- !u!114 &2023338578 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2023338575} + 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.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, 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: 2023338579} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1595579791} + m_TargetAssemblyTypeName: UiManager, Assembly-CSharp + m_MethodName: ToggleGenericsName + 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 + - m_Target: {fileID: 1595579791} + m_TargetAssemblyTypeName: UiManager, Assembly-CSharp + m_MethodName: HideRightClickMenu + 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 +--- !u!114 &2023338579 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2023338575} + 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!222 &2023338580 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2023338575} + m_CullTransparentMesh: 0 --- !u!1 &2024169826 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ModelLoader.cs b/Assets/Scripts/ModelLoader.cs index fab1a1f2..9ae2d230 100644 --- a/Assets/Scripts/ModelLoader.cs +++ b/Assets/Scripts/ModelLoader.cs @@ -28,7 +28,7 @@ private void Awake() public async Task ReplaceBox(GameObject _object, string _modelPath) { isLocked = true; - + EventManager.instance.Raise(new ChangeCursorEvent(CursorChanger.CursorType.Loading)); Uri filePath = new($"{GameManager.instance.configHandler.GetCacheDir()}/{_object.name}.fbx"); await DownloadFile(_modelPath, filePath.AbsolutePath); @@ -53,8 +53,12 @@ public async Task ReplaceBox(GameObject _object, string _modelPath) _object, assetLoaderOptions, null, "fbx"); } while (isLocked) + { + EventManager.instance.Raise(new ChangeCursorEvent(CursorChanger.CursorType.Loading)); await Task.Delay(100); + } _object.GetComponent().Initialize(); + EventManager.instance.Raise(new ChangeCursorEvent(CursorChanger.CursorType.Idle)); } /// diff --git a/Assets/Scripts/ObjectDisplayController.cs b/Assets/Scripts/ObjectDisplayController.cs index 34215caf..e9321010 100644 --- a/Assets/Scripts/ObjectDisplayController.cs +++ b/Assets/Scripts/ObjectDisplayController.cs @@ -282,8 +282,9 @@ private void OnImportFinishedBasic(ImportFinishedEvent _e) return; } List selectionrefs = GameManager.instance.GetSelectedReferents(); - bool RendColAndLabels = !isHidden && ((isReferent && !selectionrefs.Contains(item) && !GameManager.instance.focusMode) || selection.Contains(transform.parent?.gameObject)); - Display(RendColAndLabels, RendColAndLabels, RendColAndLabels); + bool rendAndCol = !isHidden && ((isReferent && !selectionrefs.Contains(item) && !GameManager.instance.focusMode) || selection.Contains(transform.parent?.gameObject)); + bool hideLabels = item is GenericObject && item.transform.parent?.GetComponent() is Room room && !room.genNamesDisplayed; + Display(rendAndCol, !hideLabels, rendAndCol); foreach (string tagName in item.tags) { diff --git a/Assets/Scripts/OgreeClasses/Room.cs b/Assets/Scripts/OgreeClasses/Room.cs index 1d0ef30c..57d63f18 100644 --- a/Assets/Scripts/OgreeClasses/Room.cs +++ b/Assets/Scripts/OgreeClasses/Room.cs @@ -23,6 +23,7 @@ public class Room : Building public List openedGroups = new(); public List separators = new(); public bool sepNamesDisplayed = false; + public bool genNamesDisplayed = false; public GameObject childrenOrigin; /// @@ -567,6 +568,17 @@ public void ToggleSeparatorText() sep.ToggleTexts(sepNamesDisplayed); } + /// + /// Toggle texts of each generic object in the room>. + /// + public void ToggleGenericText() + { + genNamesDisplayed ^= true; + foreach (Transform child in transform) + if (child.TryGetComponent(out GenericObject _)) + child.GetComponent().ToggleLabel(genNamesDisplayed); + } + /// /// Toggle walls, separators and pillars Renderer & Collider according to . /// diff --git a/Assets/Scripts/UiManager.cs b/Assets/Scripts/UiManager.cs index 845f98f5..96589658 100644 --- a/Assets/Scripts/UiManager.cs +++ b/Assets/Scripts/UiManager.cs @@ -43,6 +43,7 @@ public class UiManager : MonoBehaviour [SerializeField] private ButtonHandler toggleTilesColorBtn; [SerializeField] private ButtonHandler toggleWallsBtn; [SerializeField] private ButtonHandler toggleSepNamesBtn; + [SerializeField] private ButtonHandler toggleGenNamesBtn; [SerializeField] private ButtonHandler toggleUHelpersBtn; [SerializeField] private ButtonHandler toggleLocalCSBtn; [SerializeField] private ButtonHandler toggleChildrenOriginBtn; @@ -373,6 +374,24 @@ item is not GenericObject }; toggleSepNamesBtn.Check(); + toggleGenNamesBtn = new(toggleGenNamesBtn.button, true) + { + interactCondition = () => menuTarget + && + menuTarget.GetComponent() is Room room + && + room.displayWalls + && + room.GetComponentsInChildren().Length > 0, + + toggledCondition = () => menuTarget + && + menuTarget.GetComponent() is Room room + && + room.genNamesDisplayed + }; + toggleGenNamesBtn.Check(); + toggleUHelpersBtn = new(toggleUHelpersBtn.button, true) { interactCondition = () => menuTarget @@ -1009,6 +1028,15 @@ public void ToggleSeparatorsName() toggleSepNamesBtn.Check(); } + /// + /// Called by GUI button: Toggle generics name of targeted room + /// + public void ToggleGenericsName() + { + menuTarget.GetComponent().ToggleGenericText(); + toggleGenNamesBtn.Check(); + } + /// /// Called by GUI button: if currentItem is a rack, toggle U helpers. ///