Click here to Skip to main content
15,566,160 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently using a string array to feed different descriptions (in order) into a text box in unity.

The format is
C#
string[] descriptionSheet = { "Whatever I put in here", "Other stuff in there"};

Some of these descriptions are multi parted and I would like to separate them visually once pasted into the text box
for example I want

" the box is very large and brown.
it cannot be crushed."

instead of

"The box is very large and brown. It cannot be crushed."

I need to be able to store that new line info inside of the string array individual parts but I honestly don't know where to start. Any help would be very much appreciated

What I have tried:

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DescriptionOfCard : MonoBehaviour
{

    public Text currentDescription;

    public Text description;

    public int frame = 0;

    string[] descriptionSheet = { "The box is very large and brown." + "It cannot be crushed.", "I literally have over 100 other descriptions" };
    

    void Start()
    {

    }

    public void ChangeDescription()
    {
        description.text = descriptionSheet[0 + frame];

        currentDescription.text = description.text;

        frame = frame + 1;

    }
}
Posted
Updated 14-Jul-22 14:03pm
v3

1 solution

Use:
C#
string[] descriptionSheet =
{
    "The box is very large and brown.\n" + "It cannot be crushed.",
    "I literally have over 100 other descriptions"
};
 
Share this answer
 
Comments
Maciej Los 17-Jul-22 10:50am    
5ed!
Graeme_Grant 17-Jul-22 19:35pm    
lol, thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900