//needs to assign the text asset as part of its creation static void ProcessAsset(string origLocation, TextAsset txt, DeadSimpleCSV csv) { //if matching file exists, then get it ExternalVarsSO extvar = ExternalVarsSOManager.Instance().FindByExternalFile(txt); var fileName = origLocation.Substring(0, origLocation.Length - (".csv".Length)) + ".asset"; bool createdAsset = false; //if not create it an if (extvar == null) { extvar = ExternalVarsSO.CreateInstance <ExternalVarsSO>(); extvar.localCSV = txt; AssetDatabase.CreateAsset(extvar, fileName); createdAsset = true; } try { extvar.GenerateVars(csv.ConvertRowsToObjects <ExternalVarsSO.VarSpec>()); } catch (Exception) { if (createdAsset) { AssetDatabase.DeleteAsset(fileName); UnityEngine.Object.DestroyImmediate(extvar); } } }
public override void Awake() { base.Awake(); ExternalVarsSOManager.Instance().NotifyExists(this); }