Added info text

This commit is contained in:
2026-01-14 12:03:15 +00:00
parent c3a0e39c65
commit 0c43fc1112
5 changed files with 101 additions and 6 deletions

View File

@@ -75,6 +75,85 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &2265690506723964757
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2762027888324636750}
- component: {fileID: 1362071040755362419}
- component: {fileID: 2038821404454815492}
m_Layer: 5
m_Name: InfoText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2762027888324636750
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2265690506723964757}
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: 25269235060726753}
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: -15, y: 0}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1362071040755362419
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2265690506723964757}
m_CullTransparentMesh: 1
--- !u!114 &2038821404454815492
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2265690506723964757}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, 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_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 20
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 40
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!1 &3890928559484794403 --- !u!1 &3890928559484794403
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -106,6 +185,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2035964200443923097} - {fileID: 2035964200443923097}
- {fileID: 2762027888324636750}
m_Father: {fileID: 7011418079103154681} m_Father: {fileID: 7011418079103154681}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
@@ -336,6 +416,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
<WindowImage>k__BackingField: {fileID: 3009414327569646558} <WindowImage>k__BackingField: {fileID: 3009414327569646558}
<Transform>k__BackingField: {fileID: 7011418079103154681} <Transform>k__BackingField: {fileID: 7011418079103154681}
<InfoText>k__BackingField: {fileID: 2038821404454815492}
--- !u!114 &3265764588146964386 --- !u!114 &3265764588146964386
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -1,6 +1,5 @@
using TreeEditor; using UnityEngine.UI;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
namespace InterfaceOff namespace InterfaceOff
{ {
@@ -8,6 +7,7 @@ namespace InterfaceOff
{ {
[field: SerializeField] public Image WindowImage { get; private set; } [field: SerializeField] public Image WindowImage { get; private set; }
[field: SerializeField] public RectTransform Transform { get; private set; } [field: SerializeField] public RectTransform Transform { get; private set; }
[field: SerializeField] public Text InfoText { get; private set; }
public Rect Rect => new public Rect Rect => new
( (

View File

@@ -2,6 +2,11 @@
{ {
public class BasicWindow : WindowBase public class BasicWindow : WindowBase
{ {
public override void OnWindowInstantiation()
{
Components.InfoText.text = "Close";
}
public override void OnWindowClicked() public override void OnWindowClicked()
{ {
Destroy(gameObject); Destroy(gameObject);

View File

@@ -17,10 +17,14 @@ namespace InterfaceOff
public override void OnWindowInstantiation() public override void OnWindowInstantiation()
{ {
Sprite[] sprites = CanvasManager.Instance.Images.GetRandomSpriteSet(); /* Lets the player know what to do via text */
Components.InfoText.text = "Rotate";
/* Creates the images to rotate */
Sprite[] sprites = CanvasManager.Instance.Images.GetRandomSpriteSet();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
/* Fetches/Creates needed components */
GameObject go = Instantiate(CanvasManager.Instance.ImagePrefab, transform); GameObject go = Instantiate(CanvasManager.Instance.ImagePrefab, transform);
RectTransform t = go.GetComponent<RectTransform>(); RectTransform t = go.GetComponent<RectTransform>();
@@ -32,6 +36,7 @@ namespace InterfaceOff
img.material = new Material(Shader.Find("UI/Default")); img.material = new Material(Shader.Find("UI/Default"));
img.sprite = sprites[i]; img.sprite = sprites[i];
/* Adds a function to the buttons for them to rotate */
Button button = go.GetComponent<Button>(); Button button = go.GetComponent<Button>();
button.onClick.AddListener(() => button.onClick.AddListener(() =>
{ {
@@ -54,7 +59,7 @@ namespace InterfaceOff
} }
} }
private void Update() public override void OnWindowClicked()
{ {
if (m_TilesRotatedCorrectly == 4) if (m_TilesRotatedCorrectly == 4)
{ {

View File

@@ -4,17 +4,21 @@ namespace InterfaceOff
{ {
public class MovingWindow : WindowBase public class MovingWindow : WindowBase
{ {
private int m_Health = 5; private int m_Health = int.MaxValue;
public override void OnWindowInstantiation() public override void OnWindowInstantiation()
{ {
Components.WindowImage.color = Color.blue; /* Creates a random health value */
m_Health = Random.Range(2, 6);
Components.InfoText.text = $"{m_Health}";
} }
public override void OnWindowClicked() public override void OnWindowClicked()
{ {
/* Decreases health and destroys if at 0 */ /* Decreases health and destroys if at 0 */
m_Health--; m_Health--;
Components.InfoText.text = $"{m_Health}";
if (m_Health <= 0) if (m_Health <= 0)
{ {
Destroy(gameObject); Destroy(gameObject);