Hi all,
I am the author of GoogleFu, and I’m attempting to update a deprecated call that worked in 4.x
First, I’ll explain what I’m doing. GoogleFu is an editor utility that downloads, parses, and generates custom classes based on Google Spreadsheets. Then it attaches those custom classes to a Game Object and adds the data from the spreadsheet to the GameObject via the custom class.
For instance if I have a spreadsheet named Demeanor, it has 2 rows of data in it with the first column being a string and the second being an int:
Demeanor | Name | Val
TYPE | string | int
ROW_0 | Happy | 0
ROW_1 | Sad | 1
Then GoogleFu will generate a Demeanor.cs that contains:
public class DemeanorRow {
public string Name;
public int Val;
public DemeanorRow( string inName, int inVal)
{
Name = inName;
Val = inVal;
}
public class Demeanor
{
List<DemeanorRow> Rows;
}
(of course this is extremely simplified, but shows a basic example of why I need this)
GoogleFu writes the Demeanor.cs to a Resources folder, and refreshes the AssetDatabase:
AssetDatabase.ImportAsset(dbInfo.ScriptName + ".cs", ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
Where dbInfo.ScriptName is “Demeanor”
In 4.x I would simply create a new GameObject and attach the freshly compiled script with
var component = go.AddComponent(dbInfo.ScriptName);
Once the new component has been attached, I could create new DemeanorRows and add them to the Demeanor.Rows variable.
In 5.x I can no longer use the dbInfo.ScriptName string. So I tried this:
var component = go.AddComponent(Type.GetType(dbInfo.ScriptName));
However I get this message:
AddComponent asking for invalid type
I’m also getting ‘Demeanor.cs’ does not exist when I call
AssetDatabase.ImportAsset(dbInfo.ScriptName + ".cs", ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
Demeanor.cs is generated, and does exist at:
Assets\GoogleFuGen\ObjDB\Resources\Demeanor\Demeanor.cs
I’m sure this is a combination of issues, as this seems pretty elementary but I’m at a bit of a loss here. Any help would be appreciated.