Importing Excel spreadsheets into Unity, using CSV format to read, easy tutorial

preview_player
Показать описание
Importing Excel spreadsheets into Unity, using CSV format to read, easy tutorial

As pointed out by @daxividium I forgot to adjust the + 1 to + 2 or + 3. This is the reason, why your health, Attack and defence value is the same in the Inspector at the end (I think this is the Thing, what OP mentioned)

Any comments or questions welcome. Enjoy the video!

Song: TheFatRat - Ascendancy, allowed to be used as per
Рекомендации по теме
Комментарии
Автор

As pointed out by @daxividium I forgot to adjust the + 1 to + 2 or + 3. This is the reason, why your health, Attack and defence value is the same in the Inspector at the end (I think this is the Thing, what OP mentioned)

DestinedToLearn
Автор

Thanks for the tutorial. *IMPORTANT to note:* CSV data seems to depend on the *region* you are living in.
So if you are for example in europe your data will have a *semicolon instead of a comma* and it will look like this:
*Orc;80;20;10* instead of: *Orc, 80, 20, 10*

Verweigert
Автор

Your tutorial gave me a good start. First time using a spreadsheet with Unity. Works great, thank you!

woodenfences
Автор

Excelente tutorial, me sirvió mucho, en un principio no había tomado en cuenta el formato de la hoja de calculo de Excel, fue de gran ayuda : D

kevinkomugi
Автор

Nice and straight forward. Focused on proof of concept rather than each granular detail. Great tutorial - thanks!!

brettabraham
Автор

You sir have a very soothing voice, also thanks for your help.

dravidk.p.
Автор

Great video! Still works like a charm.

chrismazino
Автор

An excellent and easy to understand tutorial, thank you!

Monkeynuts
Автор

Thank you so much for this video, although probably unnecessary (because this video is 2 years old) I went and add changed a thing,
using UnityEngine;
using System;

public class ReadSpreadSheet : MonoBehaviour
{
[SerializeField] private Vector2Int size = new(1, 1);
public TextAsset excellSheet;

[SerializeField] ExcelReading.ReadingType readingType;
[Tooltip("The search index will search the row or column you choose, Starts from 0")]
[SerializeField] private int searchIndex = 0;

void Start()
{
switch(readingType)
{
case
ReadAll();
break;
case
ReadColumn(searchIndex);
break;
case
ReadRow(searchIndex);
break;
}
}

public void ReadAll()
{
string[] data = excellSheet.text.Split(new string[] { ", ", "\n" }, StringSplitOptions.None);

int tableSize = data.Length - 1;

for (int i = 0; i < tableSize; i++)
{

}

}

public void ReadColumn(int columnIndex)
{
string[] data = excellSheet.text.Split(new string[] { ", ", "\n" }, StringSplitOptions.None);


for (int i = 0; i < size.y; i++ )
{
Debug.Log(data[columnIndex + (i * size.x)]);
}
}

public void ReadRow(int rowIndex)
{
string[] data = excellSheet.text.Split(new string[] { ", ", "\n" }, StringSplitOptions.None);

for (int i = 0; i < size.x; i++)
{
Debug.Log(data[i + (rowIndex * size.x)]);
}
}
}

[Serializable]
public class ExcelReading
{
[Serializable]
public enum ReadingType
{
ReadAll,
ReadColumn,
ReadRow,
}
}

gladiumcaeli
Автор

Hay and thanks.

I find your tutorial very helpful.

Pragma
Автор

@DestinedEducation i'm having issues with commas and trying to add a sentence of dialogue into a csv file. I've just adding a ", " around the comma and sentence should fix it, but it is breaking it. Any ideas?

WhiskeyPlott
Автор

Thank you very much! This was helpful!

mone
Автор

hmm my csv file is not shown in the inspector, there is no "textAsset" option

Hiedalle
Автор

Hi! Great lesson! Thank you! What keyboard do you use? Interesting sound of typing)

alexdeegames
Автор

I didnt know you could have multiple split conditions work like that.
I tend to make pseudo table class for imports since each character has a few hunderd variables stored.

A nice video would be the different ways to handle save data.
1. Internal Player Pref
2. External CSV/TXT
3. External XML (and its troubles)
4. Encripted savefiles (so that the player doesnt just alter them)

I have run into some data size troubles when using xml since even just saving a bool ends up needing 3 words of discspace <name>true</name>

mllhild
Автор

Hi, I'm getting this error at the first row of my own table:
FormatException: Input string was not in a correct format.
The line of code is * (i + 1)]));

I'm trying to float.Parse a float variable but I can't. Any ideas? (Great video tho)

maestradebobobo
Автор

Hi. It does not work. i do it step by step. That works on unity 2022.3.10f1 version unity ?

AgalyAbdyev
Автор

Lol check your received characteristics. There must be mistake in code. And thank you. Helpful!

chopper
Автор

shame is if you use a comma in the data fields then excel throws up "corn, apple" also with quotes too. "she said "stop" so i stopped"

ELF_Productions
Автор

Libre Office is perfect to make CSV files.

MetaversoJuliXR