Hello! Thank you for taking the time to read this.
I am currently working on a custom Unity editor tool that will allow me to press a button at the the top of the Unity window and create GameObjects. I’m in need of this tool because each time I create a GameObject I have to attach a script and then manually fill in all the fields and attach the related GameObjects, mp3 files, etc.
Currently I have the tool setup so when I press Generate Monsters at the top, Unity will take an excel spread sheet, generate new game objects and attach my script to those GameObjects. I am now in the process of attempting to figure out how to make it fill out/attach the rest of my data related to that script (automatically) once this script has been attached. I am currently using a CSV file to create the objects.
Are there any tools that currently do this? I have looked around on the Asset Store, YouTube, and the forums and can’t seem to find what I’m looking for. I’m still relatively new to Unity and am willing to continue my own script, but I’ve been spinning my wheels in the mud for a while now.
I have attached a screenshot of my Unity Inspector (so you can kind of see what I’m talking about) and my Excel CSV (this is just a quick example).
For the type of game that I’m creating I really need to create objects in this way. (I know there are other ways to do monster spawns and things)
Any feedback to assist me in this matter is greatly appreciated - thank you for your time. Have a blessed day.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System;
using UnityEngine.Networking;
public class MonsterMaker : MonoBehaviour
{
private static string monsterStatsCSV = "Editor/CSVs/monsterStats.csv";
public GameObject monsterNames;
private string m_Directory = string.Empty;
public MonsterAttributes monAtt;
[MenuItem("Utilities/Create Monsters")]
public static void GenerateMonsterNames()
{
string[] allLines = File.ReadAllLines(Application.dataPath + monsterStatsCSV);
foreach (string s in allLines)
{
string[] splitData = s.Split(',');
GameObject monsterNames = new GameObject("monsterNames");
monsterNames.gameObject.name = splitData[0];
monsterNames.AddComponent<MonsterAttributes>();
}
AssetDatabase.SaveAssets();
}
}