public void Save() { string path = BotDirectory.BotPath(name); #if UNITY_EDITOR && !BUILD_MODE && !BUILD_MODE BotData existingAsset = AssetDatabase.LoadAssetAtPath <BotData>(path); if (existingAsset == null) { AssetDatabase.CreateAsset(this, path); } else { existingAsset.builtInProgram = builtInProgram; existingAsset.customProgramName = customProgramName; existingAsset.weaponData = weaponData; } #else StreamWriter file = File.CreateText(path); file.WriteLine(customProgramName); if (weaponData == null) { file.WriteLine(); } else { file.WriteLine(weaponData.name); } file.Close(); #endif }
public void DeleteOnDisk() { string path = BotDirectory.BotPath(name); #if UNITY_EDITOR && !BUILD_MODE AssetDatabase.DeleteAsset(path); #else File.Delete(path); #endif }
public void Rename(string newName) { string fromPath = BotDirectory.BotPath(name); string toPath = BotDirectory.BotPath(newName); #if UNITY_EDITOR && !BUILD_MODE AssetDatabase.RenameAsset(fromPath, newName); #else File.Move(fromPath, toPath); #endif name = newName; }
public BotData GetBotData(int index) { if (builtInBotDatas != null) { return(builtInBotDatas[index]); } else if (customBotNames != null && customBotNames[index] != "") { return(BotData.Load(BotDirectory.BotPath(customBotNames[index]))); } else { return(null); } }
public void SetBotName(int index, string name) { #if UNITY_EDITOR && !BUILD_MODE if (name == null) { builtInBotDatas[index] = null; } else { string path = BotDirectory.BotPath(name); builtInBotDatas[index] = AssetDatabase.LoadAssetAtPath <BotData>(path); } #else customBotNames[index] = name; #endif Save(); OnBotChanged?.Invoke(index); }