feature: Message generator
This commit is contained in:
parent
359543952e
commit
c66047cd26
4 changed files with 53 additions and 5 deletions
3
Assets/Scripts/Messaging.meta
Normal file
3
Assets/Scripts/Messaging.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cdd4ba91d34e452991f5ea43cc32922e
|
||||
timeCreated: 1706296714
|
26
Assets/Scripts/Messaging/MessageStructureGenerator.cs
Normal file
26
Assets/Scripts/Messaging/MessageStructureGenerator.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Messaging {
|
||||
public class MessageStructureGenerator : MonoBehaviour {
|
||||
|
||||
[SerializeField, Min(0)] private int maxVisibleMessages = 3;
|
||||
[SerializeField, Min(0)] private int messageHeight = 16;
|
||||
|
||||
[SerializeField] private RectTransform messagePrefab;
|
||||
|
||||
private void Awake() {
|
||||
GenerateMessages();
|
||||
}
|
||||
|
||||
private void GenerateMessages() {
|
||||
for (int i = 0; i < maxVisibleMessages; i++) {
|
||||
GenerateMessage(i * messageHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateMessage(int offsetY) {
|
||||
RectTransform message = Instantiate(messagePrefab, Vector2.zero, Quaternion.identity, transform);
|
||||
message.anchoredPosition = new Vector2(0, -offsetY);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ce276be77304236a23df45b19b4cc08
|
||||
timeCreated: 1706296726
|
Loading…
Add table
Add a link
Reference in a new issue