Skip to content

Commit

Permalink
Modifications to stamina bar
Browse files Browse the repository at this point in the history
Thee is  a bug in the stamina bar that it does not get de stamina max value by method, it has to be done by a literal. Later I will search on this bug. (It is a problem because it is only in the build, not in the editor mode).
  • Loading branch information
carlos96mdq committed Mar 25, 2022
1 parent 1a9119e commit 5a8ac6f
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 14 deletions.
166 changes: 157 additions & 9 deletions Assets/Scenes/FirstLevel.unity
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ RectTransform:
m_Children:
- {fileID: 1908453303}
- {fileID: 1323092485}
- {fileID: 2023944283}
m_Father: {fileID: 1549897050}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand All @@ -697,7 +698,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_Mode: 0
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
Expand Down Expand Up @@ -1588,6 +1589,17 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 3610214649350316593, guid: 6cab9064187271f4980c4e6d7f3393ef, type: 3}
m_PrefabInstance: {fileID: 3610214651033019249}
m_PrefabAsset: {fileID: 0}
--- !u!114 &528795044 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1822936373560601385, guid: 6cab9064187271f4980c4e6d7f3393ef, type: 3}
m_PrefabInstance: {fileID: 3610214651033019249}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 528795040}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4a24e372b08a8b74691a73b62a18449b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &530311054
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -3673,10 +3685,10 @@ RectTransform:
m_Father: {fileID: 330651265}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.25}
m_AnchorMax: {x: 1, y: 0.75}
m_AnchoredPosition: {x: -5, y: 0}
m_SizeDelta: {x: -20, y: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: -5, y: 35}
m_SizeDelta: {x: 480, y: 34}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &1391216409
PrefabInstance:
Expand Down Expand Up @@ -4114,6 +4126,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
staminaBar: {fileID: 330651266}
player: {fileID: 528795040}
playerStamina: {fileID: 528795044}
sliderValue: {fileID: 2023944282}
--- !u!114 &1549897054
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4996,10 +5010,10 @@ RectTransform:
m_Father: {fileID: 330651265}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.25}
m_AnchorMax: {x: 1, y: 0.75}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 35}
m_SizeDelta: {x: 500, y: 34}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1908453304
MonoBehaviour:
Expand Down Expand Up @@ -5332,6 +5346,140 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 8899730730638617468, guid: cbb10fd619e4c604e9484722548d4cff, type: 3}
m_PrefabInstance: {fileID: 2013288980}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2023944282
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2023944283}
- component: {fileID: 2023944285}
- component: {fileID: 2023944284}
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 &2023944283
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2023944282}
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: []
m_Father: {fileID: 330651265}
m_RootOrder: 2
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: 800, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2023944284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2023944282}
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: New Text
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: 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: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
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: 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!222 &2023944285
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2023944282}
m_CullTransparentMesh: 1
--- !u!1 &2028354097
GameObject:
m_ObjectHideFlags: 0
Expand Down
13 changes: 9 additions & 4 deletions Assets/Scripts/Hud/StaminaBar.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro; // Necesario para usar TextMeshProUGUI


public class StaminaBar : MonoBehaviour
{
public Slider staminaBar; // Referencia a la barra de stamina en el HUD
public GameObject player; // Referencia al player cuya stamina es representada en la barra
PlayerStamina playerStamina;// Script de la stamina dentro del player
public Slider staminaBar; // Referencia a la barra de stamina en el HUD
public GameObject player; // Referencia al player cuya stamina es representada en la barra
public PlayerStamina playerStamina; // Script de la stamina dentro del player

// Start is called before the first frame update
void Start()
{
playerStamina = player.GetComponent<PlayerStamina>();
staminaBar.maxValue = playerStamina.GetMaxStamina();
// BUG: POR MOTIVO DESCONOCIDO ESTA FUNCIÓN DEVUELVE O Y NO 100 COMO DEBERIA (ESTO PASA SOLO EN LA BUILD)
// staminaBar.maxValue = playerStamina.GetMaxStamina();
staminaBar.maxValue = 100f;
staminaBar.value = playerStamina.GetStamina();
}

Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.1.0-beta
bundleVersion: 0.1.1-beta
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 5a8ac6f

Please sign in to comment.